summaryrefslogtreecommitdiff
path: root/randpkt_core
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2017-02-04 16:26:34 +0100
committerDario Lombardo <lomato@gmail.com>2017-02-14 10:22:20 +0000
commit7c0c580c4b0093437ee81e11934ef5b8d27a5bb4 (patch)
tree45d46758e2ce26b82b8a5d066bd9b1f23e1165ec /randpkt_core
parentae0bdcc78c6cb2719e7aa5ae24e80584dec488a3 (diff)
downloadwireshark-7c0c580c4b0093437ee81e11934ef5b8d27a5bb4.tar.gz
wiretap: add cleanup routine.
The cleanup routine has been added to exit section of the applications. Those which required a exit restyle have been patched as well. Change-Id: I3a8787f0718ac7fef00dc58176869c7510fda7b1 Reviewed-on: https://code.wireshark.org/review/19949 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'randpkt_core')
-rw-r--r--randpkt_core/randpkt_core.c11
-rw-r--r--randpkt_core/randpkt_core.h2
2 files changed, 9 insertions, 4 deletions
diff --git a/randpkt_core/randpkt_core.c b/randpkt_core/randpkt_core.c
index e84cb39d3c..3233d625a9 100644
--- a/randpkt_core/randpkt_core.c
+++ b/randpkt_core/randpkt_core.c
@@ -34,6 +34,9 @@
#define array_length(x) (sizeof x / sizeof x[0])
+#define INVALID_LEN 1
+#define WRITE_ERROR 2
+
GRand *pkt_rand = NULL;
/* Types of produceable packets */
@@ -696,7 +699,7 @@ gboolean randpkt_example_close(randpkt_example* example)
return ok;
}
-void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes)
+int randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes)
{
int err;
@@ -718,7 +721,7 @@ void randpkt_example_init(randpkt_example* example, char* produce_filename, int
}
if (!example->dump) {
fprintf(stderr, "randpkt: Error writing to %s\n", example->filename);
- exit(2);
+ return WRITE_ERROR;
}
/* reduce max_bytes by # of bytes already in sample */
@@ -726,10 +729,12 @@ void randpkt_example_init(randpkt_example* example, char* produce_filename, int
fprintf(stderr, "randpkt: Sample packet length is %d, which is greater than "
"or equal to\n", example->sample_length);
fprintf(stderr, "your requested max_bytes value of %d\n", produce_max_bytes);
- exit(1);
+ return INVALID_LEN;
} else {
example->produce_max_bytes = produce_max_bytes - example->sample_length;
}
+
+ return EXIT_SUCCESS;
}
/* Parse command-line option "type" and return enum type */
diff --git a/randpkt_core/randpkt_core.h b/randpkt_core/randpkt_core.h
index 4b5b73a276..36764764e8 100644
--- a/randpkt_core/randpkt_core.h
+++ b/randpkt_core/randpkt_core.h
@@ -55,7 +55,7 @@ int randpkt_parse_type(char *string);
randpkt_example* randpkt_find_example(int type);
/* Init a new example */
-void randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes);
+int randpkt_example_init(randpkt_example* example, char* produce_filename, int produce_max_bytes);
/* Loop the packet generation */
void randpkt_loop(randpkt_example* example, guint64 produce_count);