forked from osmocom/wireshark
replace all appearances of 'fprintf(stderr, "tethereal: ' with 'cmdarg_err("', this is:
a) smaller b) makes it possible to use some functions for Ethereal too c) is the wrong name now, as some outputs are not command line related :-( use capture_opts_trim() svn path=/trunk/; revision=16685
This commit is contained in:
parent
792584c211
commit
a1dc531677
271
tethereal.c
271
tethereal.c
|
@ -414,7 +414,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
|
|
||||||
remaining_param = strchr(table_name, '=');
|
remaining_param = strchr(table_name, '=');
|
||||||
if (remaining_param == NULL) {
|
if (remaining_param == NULL) {
|
||||||
fprintf(stderr, "tethereal: Parameter \"%s\" doesn't follow the template \"%s\"\n", cl_param, decode_as_arg_template);
|
cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template);
|
||||||
/* If the argument does not follow the template, carry on anyway to check
|
/* If the argument does not follow the template, carry on anyway to check
|
||||||
if the table name is at least correct. If remaining_param is NULL,
|
if the table name is at least correct. If remaining_param is NULL,
|
||||||
we'll exit anyway further down */
|
we'll exit anyway further down */
|
||||||
|
@ -434,19 +434,19 @@ add_decode_as(const gchar *cl_param)
|
||||||
|
|
||||||
/* Look for the requested table */
|
/* Look for the requested table */
|
||||||
if ( !(*(table_name)) ) { /* Is the table name empty, if so, don't even search for anything, display a message */
|
if ( !(*(table_name)) ) { /* Is the table name empty, if so, don't even search for anything, display a message */
|
||||||
fprintf(stderr, "tethereal: No layer type specified\n"); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */
|
cmdarg_err("No layer type specified"); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
table_matching = find_dissector_table(table_name);
|
table_matching = find_dissector_table(table_name);
|
||||||
if (!table_matching) {
|
if (!table_matching) {
|
||||||
fprintf(stderr, "tethereal: Unknown layer type -- %s\n", table_name); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */
|
cmdarg_err("Unknown layer type -- %s", table_name); /* Note, we don't exit here, but table_matching will remain NULL, so we exit below */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!table_matching) {
|
if (!table_matching) {
|
||||||
/* Display a list of supported layer types to help the user, if the
|
/* Display a list of supported layer types to help the user, if the
|
||||||
specified layer type was not found */
|
specified layer type was not found */
|
||||||
fprintf(stderr, "tethereal: Valid layer types are:\n");
|
cmdarg_err("Valid layer types are:");
|
||||||
fprint_all_layer_types(stderr);
|
fprint_all_layer_types(stderr);
|
||||||
}
|
}
|
||||||
if (remaining_param == NULL || !table_matching) {
|
if (remaining_param == NULL || !table_matching) {
|
||||||
|
@ -457,7 +457,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(remaining_param + 1) != '=') { /* Check for "==" and not only '=' */
|
if (*(remaining_param + 1) != '=') { /* Check for "==" and not only '=' */
|
||||||
fprintf(stderr, "tethereal: WARNING: -d requires \"==\" instead of \"=\". Option will be treated as \"%s==%s\"\n", table_name, remaining_param + 1);
|
cmdarg_err("WARNING: -d requires \"==\" instead of \"=\". Option will be treated as \"%s==%s\"", table_name, remaining_param + 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
remaining_param++; /* Move to the second '=' */
|
remaining_param++; /* Move to the second '=' */
|
||||||
|
@ -471,7 +471,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
|
|
||||||
remaining_param = strchr(selector_str, ',');
|
remaining_param = strchr(selector_str, ',');
|
||||||
if (remaining_param == NULL) {
|
if (remaining_param == NULL) {
|
||||||
fprintf(stderr, "tethereal: Parameter \"%s\" doesn't follow the template \"%s\"\n", cl_param, decode_as_arg_template);
|
cmdarg_err("Parameter \"%s\" doesn't follow the template \"%s\"", cl_param, decode_as_arg_template);
|
||||||
/* If the argument does not follow the template, carry on anyway to check
|
/* If the argument does not follow the template, carry on anyway to check
|
||||||
if the selector value is at least correct. If remaining_param is NULL,
|
if the selector value is at least correct. If remaining_param is NULL,
|
||||||
we'll exit anyway further down */
|
we'll exit anyway further down */
|
||||||
|
@ -492,7 +492,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
There's no need to remove leading and trailing spaces from the
|
There's no need to remove leading and trailing spaces from the
|
||||||
selector number string, because sscanf will do that for us. */
|
selector number string, because sscanf will do that for us. */
|
||||||
if ( sscanf(selector_str, "%u", &selector) != 1 ) {
|
if ( sscanf(selector_str, "%u", &selector) != 1 ) {
|
||||||
fprintf(stderr, "tethereal: Invalid selector number \"%s\"\n", selector_str);
|
cmdarg_err("Invalid selector number \"%s\"", selector_str);
|
||||||
g_free(decoded_param);
|
g_free(decoded_param);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
|
|
||||||
if (remaining_param == NULL) {
|
if (remaining_param == NULL) {
|
||||||
/* Exit if no ',' separator was found (see above) */
|
/* Exit if no ',' separator was found (see above) */
|
||||||
fprintf(stderr, "tethereal: Valid protocols for layer type \"%s\" are:\n", table_name);
|
cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name);
|
||||||
fprint_all_protocols_for_layer_types(stderr, table_name);
|
fprint_all_protocols_for_layer_types(stderr, table_name);
|
||||||
g_free(decoded_param);
|
g_free(decoded_param);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -533,7 +533,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
|
|
||||||
/* We now have a pointer to the handle for the requested table inside the variable table_matching */
|
/* We now have a pointer to the handle for the requested table inside the variable table_matching */
|
||||||
if ( ! (*dissector_str) ) { /* Is the dissector name empty, if so, don't even search for a matching dissector and display all dissectors found for the selected table */
|
if ( ! (*dissector_str) ) { /* Is the dissector name empty, if so, don't even search for a matching dissector and display all dissectors found for the selected table */
|
||||||
fprintf(stderr, "tethereal: No protocol name specified\n"); /* Note, we don't exit here, but dissector_matching will remain NULL, so we exit below */
|
cmdarg_err("No protocol name specified"); /* Note, we don't exit here, but dissector_matching will remain NULL, so we exit below */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
user_protocol_name.nb_match = 0;
|
user_protocol_name.nb_match = 0;
|
||||||
|
@ -545,7 +545,7 @@ add_decode_as(const gchar *cl_param)
|
||||||
if (user_protocol_name.nb_match != 0) {
|
if (user_protocol_name.nb_match != 0) {
|
||||||
dissector_matching = user_protocol_name.matched_handle;
|
dissector_matching = user_protocol_name.matched_handle;
|
||||||
if (user_protocol_name.nb_match > 1) {
|
if (user_protocol_name.nb_match > 1) {
|
||||||
fprintf(stderr, "tethereal: WARNING: Protocol \"%s\" matched %u dissectors, first one will be used\n", dissector_str, user_protocol_name.nb_match);
|
cmdarg_err("WARNING: Protocol \"%s\" matched %u dissectors, first one will be used", dissector_str, user_protocol_name.nb_match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -556,16 +556,16 @@ add_decode_as(const gchar *cl_param)
|
||||||
so we exit below */
|
so we exit below */
|
||||||
if (proto_get_id_by_filter_name(dissector_str) == -1) {
|
if (proto_get_id_by_filter_name(dissector_str) == -1) {
|
||||||
/* No such protocol */
|
/* No such protocol */
|
||||||
fprintf(stderr, "tethereal: Unknown protocol -- \"%s\"\n", dissector_str);
|
cmdarg_err("Unknown protocol -- \"%s\"", dissector_str);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "tethereal: Protocol \"%s\" isn't valid for layer type \"%s\"\n",
|
cmdarg_err("Protocol \"%s\" isn't valid for layer type \"%s\"",
|
||||||
dissector_str, table_name);
|
dissector_str, table_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dissector_matching) {
|
if (!dissector_matching) {
|
||||||
fprintf(stderr, "tethereal: Valid protocols for layer type \"%s\" are:\n", table_name);
|
cmdarg_err("Valid protocols for layer type \"%s\" are:", table_name);
|
||||||
fprint_all_protocols_for_layer_types(stderr, table_name);
|
fprint_all_protocols_for_layer_types(stderr, table_name);
|
||||||
g_free(decoded_param);
|
g_free(decoded_param);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -747,21 +747,21 @@ main(int argc, char *argv[])
|
||||||
&pf_open_errno, &pf_read_errno, &pf_path);
|
&pf_open_errno, &pf_read_errno, &pf_path);
|
||||||
if (gpf_path != NULL) {
|
if (gpf_path != NULL) {
|
||||||
if (gpf_open_errno != 0) {
|
if (gpf_open_errno != 0) {
|
||||||
fprintf(stderr, "Can't open global preferences file \"%s\": %s.\n",
|
cmdarg_err("Can't open global preferences file \"%s\": %s.",
|
||||||
pf_path, strerror(gpf_open_errno));
|
pf_path, strerror(gpf_open_errno));
|
||||||
}
|
}
|
||||||
if (gpf_read_errno != 0) {
|
if (gpf_read_errno != 0) {
|
||||||
fprintf(stderr, "I/O error reading global preferences file \"%s\": %s.\n",
|
cmdarg_err("I/O error reading global preferences file \"%s\": %s.",
|
||||||
pf_path, strerror(gpf_read_errno));
|
pf_path, strerror(gpf_read_errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pf_path != NULL) {
|
if (pf_path != NULL) {
|
||||||
if (pf_open_errno != 0) {
|
if (pf_open_errno != 0) {
|
||||||
fprintf(stderr, "Can't open your preferences file \"%s\": %s.\n", pf_path,
|
cmdarg_err("Can't open your preferences file \"%s\": %s.", pf_path,
|
||||||
strerror(pf_open_errno));
|
strerror(pf_open_errno));
|
||||||
}
|
}
|
||||||
if (pf_read_errno != 0) {
|
if (pf_read_errno != 0) {
|
||||||
fprintf(stderr, "I/O error reading your preferences file \"%s\": %s.\n",
|
cmdarg_err("I/O error reading your preferences file \"%s\": %s.",
|
||||||
pf_path, strerror(pf_read_errno));
|
pf_path, strerror(pf_read_errno));
|
||||||
}
|
}
|
||||||
g_free(pf_path);
|
g_free(pf_path);
|
||||||
|
@ -776,26 +776,26 @@ main(int argc, char *argv[])
|
||||||
&dp_path, &dp_open_errno, &dp_read_errno);
|
&dp_path, &dp_open_errno, &dp_read_errno);
|
||||||
if (gdp_path != NULL) {
|
if (gdp_path != NULL) {
|
||||||
if (gdp_open_errno != 0) {
|
if (gdp_open_errno != 0) {
|
||||||
fprintf(stderr,
|
cmdarg_err(
|
||||||
"Could not open global disabled protocols file\n\"%s\": %s.\n",
|
"Could not open global disabled protocols file\n\"%s\": %s.",
|
||||||
gdp_path, strerror(gdp_open_errno));
|
gdp_path, strerror(gdp_open_errno));
|
||||||
}
|
}
|
||||||
if (gdp_read_errno != 0) {
|
if (gdp_read_errno != 0) {
|
||||||
fprintf(stderr,
|
cmdarg_err(
|
||||||
"I/O error reading global disabled protocols file\n\"%s\": %s.\n",
|
"I/O error reading global disabled protocols file\n\"%s\": %s.",
|
||||||
gdp_path, strerror(gdp_read_errno));
|
gdp_path, strerror(gdp_read_errno));
|
||||||
}
|
}
|
||||||
g_free(gdp_path);
|
g_free(gdp_path);
|
||||||
}
|
}
|
||||||
if (dp_path != NULL) {
|
if (dp_path != NULL) {
|
||||||
if (dp_open_errno != 0) {
|
if (dp_open_errno != 0) {
|
||||||
fprintf(stderr,
|
cmdarg_err(
|
||||||
"Could not open your disabled protocols file\n\"%s\": %s.\n", dp_path,
|
"Could not open your disabled protocols file\n\"%s\": %s.", dp_path,
|
||||||
strerror(dp_open_errno));
|
strerror(dp_open_errno));
|
||||||
}
|
}
|
||||||
if (dp_read_errno != 0) {
|
if (dp_read_errno != 0) {
|
||||||
fprintf(stderr,
|
cmdarg_err(
|
||||||
"I/O error reading your disabled protocols file\n\"%s\": %s.\n", dp_path,
|
"I/O error reading your disabled protocols file\n\"%s\": %s.", dp_path,
|
||||||
strerror(dp_read_errno));
|
strerror(dp_read_errno));
|
||||||
}
|
}
|
||||||
g_free(dp_path);
|
g_free(dp_path);
|
||||||
|
@ -852,12 +852,12 @@ main(int argc, char *argv[])
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr =
|
cant_get_if_list_errstr =
|
||||||
cant_get_if_list_error_message(err_str);
|
cant_get_if_list_error_message(err_str);
|
||||||
fprintf(stderr, "tethereal: %s\n", cant_get_if_list_errstr);
|
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||||
g_free(cant_get_if_list_errstr);
|
g_free(cant_get_if_list_errstr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
|
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -881,7 +881,7 @@ main(int argc, char *argv[])
|
||||||
case 'F':
|
case 'F':
|
||||||
out_file_type = wtap_short_string_to_file_type(optarg);
|
out_file_type = wtap_short_string_to_file_type(optarg);
|
||||||
if (out_file_type < 0) {
|
if (out_file_type < 0) {
|
||||||
fprintf(stderr, "tethereal: \"%s\" isn't a valid capture file type\n",
|
cmdarg_err("\"%s\" isn't a valid capture file type",
|
||||||
optarg);
|
optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -903,18 +903,16 @@ main(int argc, char *argv[])
|
||||||
adapter_index = strtol(optarg, &p, 10);
|
adapter_index = strtol(optarg, &p, 10);
|
||||||
if (p != NULL && *p == '\0') {
|
if (p != NULL && *p == '\0') {
|
||||||
if (adapter_index < 0) {
|
if (adapter_index < 0) {
|
||||||
fprintf(stderr,
|
cmdarg_err("The specified adapter index is a negative number");
|
||||||
"tethereal: The specified adapter index is a negative number\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (adapter_index > INT_MAX) {
|
if (adapter_index > INT_MAX) {
|
||||||
fprintf(stderr,
|
cmdarg_err("The specified adapter index is too large (greater than %d)",
|
||||||
"tethereal: The specified adapter index is too large (greater than %d)\n",
|
|
||||||
INT_MAX);
|
INT_MAX);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (adapter_index == 0) {
|
if (adapter_index == 0) {
|
||||||
fprintf(stderr, "tethereal: there is no interface with that adapter index\n");
|
cmdarg_err("there is no interface with that adapter index");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if_list = get_interface_list(&err, err_str);
|
if_list = get_interface_list(&err, err_str);
|
||||||
|
@ -924,19 +922,19 @@ main(int argc, char *argv[])
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr =
|
cant_get_if_list_errstr =
|
||||||
cant_get_if_list_error_message(err_str);
|
cant_get_if_list_error_message(err_str);
|
||||||
fprintf(stderr, "tethereal: %s\n", cant_get_if_list_errstr);
|
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||||
g_free(cant_get_if_list_errstr);
|
g_free(cant_get_if_list_errstr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
|
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if_info = g_list_nth_data(if_list, adapter_index - 1);
|
if_info = g_list_nth_data(if_list, adapter_index - 1);
|
||||||
if (if_info == NULL) {
|
if (if_info == NULL) {
|
||||||
fprintf(stderr, "tethereal: there is no interface with that adapter index\n");
|
cmdarg_err("there is no interface with that adapter index");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
capture_opts.iface = g_strdup(if_info->name);
|
capture_opts.iface = g_strdup(if_info->name);
|
||||||
|
@ -980,7 +978,7 @@ main(int argc, char *argv[])
|
||||||
g_resolv_flags = RESOLV_NONE;
|
g_resolv_flags = RESOLV_NONE;
|
||||||
badopt = string_to_name_resolve(optarg, &g_resolv_flags);
|
badopt = string_to_name_resolve(optarg, &g_resolv_flags);
|
||||||
if (badopt != '\0') {
|
if (badopt != '\0') {
|
||||||
fprintf(stderr, "tethereal: -N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'\n",
|
cmdarg_err("-N specifies unknown resolving option '%c'; valid options are 'm', 'n', and 't'",
|
||||||
badopt);
|
badopt);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -989,13 +987,13 @@ main(int argc, char *argv[])
|
||||||
switch (prefs_set_pref(optarg)) {
|
switch (prefs_set_pref(optarg)) {
|
||||||
|
|
||||||
case PREFS_SET_SYNTAX_ERR:
|
case PREFS_SET_SYNTAX_ERR:
|
||||||
fprintf(stderr, "tethereal: Invalid -o flag \"%s\"\n", optarg);
|
cmdarg_err("Invalid -o flag \"%s\"", optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PREFS_SET_NO_SUCH_PREF:
|
case PREFS_SET_NO_SUCH_PREF:
|
||||||
case PREFS_SET_OBSOLETE:
|
case PREFS_SET_OBSOLETE:
|
||||||
fprintf(stderr, "tethereal: -o flag \"%s\" specifies unknown preference\n",
|
cmdarg_err("-o flag \"%s\" specifies unknown preference",
|
||||||
optarg);
|
optarg);
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
@ -1023,10 +1021,10 @@ main(int argc, char *argv[])
|
||||||
else if (strcmp(optarg, "d") == 0)
|
else if (strcmp(optarg, "d") == 0)
|
||||||
timestamp_set_type(TS_DELTA);
|
timestamp_set_type(TS_DELTA);
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "tethereal: Invalid time stamp type \"%s\"\n",
|
cmdarg_err("Invalid time stamp type \"%s\"",
|
||||||
optarg);
|
optarg);
|
||||||
fprintf(stderr, "It must be \"r\" for relative, \"a\" for absolute,\n");
|
cmdarg_err_cont("It must be \"r\" for relative, \"a\" for absolute,");
|
||||||
fprintf(stderr, "\"ad\" for absolute with date, or \"d\" for delta.\n");
|
cmdarg_err_cont("\"ad\" for absolute with date, or \"d\" for delta.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1044,8 +1042,8 @@ main(int argc, char *argv[])
|
||||||
output_action = WRITE_XML;
|
output_action = WRITE_XML;
|
||||||
verbose = FALSE;
|
verbose = FALSE;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "tethereal: Invalid -T parameter.\n");
|
cmdarg_err("Invalid -T parameter.");
|
||||||
fprintf(stderr, "It must be \"ps\", \"text\", \"pdml\", or \"psml\".\n");
|
cmdarg_err_cont("It must be \"ps\", \"text\", \"pdml\", or \"psml\".");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1070,8 +1068,8 @@ main(int argc, char *argv[])
|
||||||
part of a tap filter. Instead, we just add the argument
|
part of a tap filter. Instead, we just add the argument
|
||||||
to a list of stat arguments. */
|
to a list of stat arguments. */
|
||||||
if (!process_stat_cmd_arg(optarg)) {
|
if (!process_stat_cmd_arg(optarg)) {
|
||||||
fprintf(stderr,"tethereal: invalid -z argument.\n");
|
cmdarg_err("invalid -z argument.");
|
||||||
fprintf(stderr," -z argument must be one of :\n");
|
cmdarg_err_cont(" -z argument must be one of :");
|
||||||
list_stat_cmd_args();
|
list_stat_cmd_args();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -1090,16 +1088,16 @@ main(int argc, char *argv[])
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
if (cf_name != NULL) {
|
if (cf_name != NULL) {
|
||||||
if (rfilter != NULL) {
|
if (rfilter != NULL) {
|
||||||
fprintf(stderr,
|
cmdarg_err("Read filters were specified both with \"-R\" "
|
||||||
"tethereal: Read filters were specified both with \"-R\" and with additional command-line arguments\n");
|
"and with additional command-line arguments");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
rfilter = get_args_as_string(argc, argv, optind);
|
rfilter = get_args_as_string(argc, argv, optind);
|
||||||
} else {
|
} else {
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
if (capture_filter_specified) {
|
if (capture_filter_specified) {
|
||||||
fprintf(stderr,
|
cmdarg_err("Capture filters were specified both with \"-f\""
|
||||||
"tethereal: Capture filters were specified both with \"-f\" and with additional command-line arguments\n");
|
" and with additional command-line arguments");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
capture_opts.cfilter = get_args_as_string(argc, argv, optind);
|
capture_opts.cfilter = get_args_as_string(argc, argv, optind);
|
||||||
|
@ -1142,8 +1140,7 @@ main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* couldn't stat it */
|
default: /* couldn't stat it */
|
||||||
fprintf(stderr,
|
cmdarg_err("Error testing whether capture file is a pipe: %s",
|
||||||
"tethereal: Error testing whether capture file is a pipe: %s\n",
|
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1155,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifndef HAVE_LIBPCAP
|
#ifndef HAVE_LIBPCAP
|
||||||
if (capture_option_specified)
|
if (capture_option_specified)
|
||||||
fprintf(stderr, "This version of Tethereal was not built with support for capturing packets.\n");
|
cmdarg_err("This version of Tethereal was not built with support for capturing packets.");
|
||||||
#endif
|
#endif
|
||||||
if (arg_error) {
|
if (arg_error) {
|
||||||
print_usage(FALSE);
|
print_usage(FALSE);
|
||||||
|
@ -1171,8 +1168,8 @@ main(int argc, char *argv[])
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
if (cf_name != NULL) {
|
if (cf_name != NULL) {
|
||||||
if (capture_filter_specified) {
|
if (capture_filter_specified) {
|
||||||
fprintf(stderr,
|
cmdarg_err("Only read filters, not capture filters, "
|
||||||
"tethereal: Only read filters, not capture filters, can be specified when reading a capture file.\n");
|
"can be specified when reading a capture file.");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1180,7 +1177,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
if (print_hex) {
|
if (print_hex) {
|
||||||
if (output_action != WRITE_TEXT) {
|
if (output_action != WRITE_TEXT) {
|
||||||
fprintf(stderr, "tethereal: Raw packet hex data can only be printed as text or PostScript\n");
|
cmdarg_err("Raw packet hex data can only be printed as text or PostScript");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1191,20 +1188,20 @@ main(int argc, char *argv[])
|
||||||
did the user also specify a capture file to be read? */
|
did the user also specify a capture file to be read? */
|
||||||
if (cf_name) {
|
if (cf_name) {
|
||||||
/* Yes - that's bogus. */
|
/* Yes - that's bogus. */
|
||||||
fprintf(stderr, "tethereal: You can't specify -L and a capture file to be read.\n");
|
cmdarg_err("You can't specify -L and a capture file to be read.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
/* No - did they specify a ring buffer option? */
|
/* No - did they specify a ring buffer option? */
|
||||||
if (capture_opts.multi_files_on) {
|
if (capture_opts.multi_files_on) {
|
||||||
fprintf(stderr, "tethereal: Ring buffer requested, but a capture isn't being done.\n");
|
cmdarg_err("Ring buffer requested, but a capture isn't being done.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* If they didn't specify a "-w" flag, but specified a maximum capture
|
/* If they didn't specify a "-w" flag, but specified a maximum capture
|
||||||
file size, tell them that this doesn't work, and exit. */
|
file size, tell them that this doesn't work, and exit. */
|
||||||
if (capture_opts.has_autostop_filesize && save_file == NULL) {
|
if (capture_opts.has_autostop_filesize && save_file == NULL) {
|
||||||
fprintf(stderr, "tethereal: Maximum capture file size specified, but "
|
cmdarg_err("Maximum capture file size specified, but "
|
||||||
"capture isn't being saved to a file.\n");
|
"capture isn't being saved to a file.");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,23 +1214,21 @@ main(int argc, char *argv[])
|
||||||
file size is set to "infinite";
|
file size is set to "infinite";
|
||||||
d) file must not be a pipe. */
|
d) file must not be a pipe. */
|
||||||
if (save_file == NULL) {
|
if (save_file == NULL) {
|
||||||
fprintf(stderr, "tethereal: Ring buffer requested, but "
|
cmdarg_err("Ring buffer requested, but capture isn't being saved to a file.");
|
||||||
"capture isn't being saved to a file.\n");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (out_file_type != WTAP_FILE_PCAP) {
|
if (out_file_type != WTAP_FILE_PCAP) {
|
||||||
fprintf(stderr, "tethereal: Ring buffer requested, but "
|
cmdarg_err("Ring buffer requested, but "
|
||||||
"capture isn't being saved in libpcap format.\n");
|
"capture isn't being saved in libpcap format.");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (!capture_opts.has_autostop_filesize) {
|
if (!capture_opts.has_autostop_filesize) {
|
||||||
fprintf(stderr, "tethereal: Ring buffer requested, but "
|
cmdarg_err("Ring buffer requested, but "
|
||||||
"no maximum capture file size was specified.\n");
|
"no maximum capture file size was specified.");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if (ld.output_to_pipe) {
|
if (ld.output_to_pipe) {
|
||||||
fprintf(stderr, "tethereal: Ring buffer requested, but "
|
cmdarg_err("Ring buffer requested, but capture file is a pipe.");
|
||||||
"capture file is a pipe.\n");
|
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1292,23 +1287,12 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBPCAP
|
#ifdef HAVE_LIBPCAP
|
||||||
if (capture_opts.snaplen < 1)
|
capture_opts_trim(&capture_opts, MIN_PACKET_SIZE);
|
||||||
capture_opts.snaplen = WTAP_MAX_PACKET_SIZE;
|
|
||||||
else if (capture_opts.snaplen < MIN_PACKET_SIZE)
|
|
||||||
capture_opts.snaplen = MIN_PACKET_SIZE;
|
|
||||||
|
|
||||||
/* Check the value range of the ring_num_files parameter */
|
|
||||||
if (capture_opts.ring_num_files > RINGBUFFER_MAX_NUM_FILES)
|
|
||||||
capture_opts.ring_num_files = RINGBUFFER_MAX_NUM_FILES;
|
|
||||||
#if RINGBUFFER_MIN_NUM_FILES > 0
|
|
||||||
else if (capture_opts.ring_num_files < RINGBUFFER_MIN_NUM_FILES)
|
|
||||||
capture_opts.ring_num_files = RINGBUFFER_MIN_NUM_FILES;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (rfilter != NULL) {
|
if (rfilter != NULL) {
|
||||||
if (!dfilter_compile(rfilter, &rfcode)) {
|
if (!dfilter_compile(rfilter, &rfcode)) {
|
||||||
fprintf(stderr, "tethereal: %s\n", dfilter_error_msg);
|
cmdarg_err("%s", dfilter_error_msg);
|
||||||
epan_cleanup();
|
epan_cleanup();
|
||||||
#ifdef HAVE_PCAP_OPEN_DEAD
|
#ifdef HAVE_PCAP_OPEN_DEAD
|
||||||
{
|
{
|
||||||
|
@ -1317,9 +1301,10 @@ main(int argc, char *argv[])
|
||||||
pc = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE);
|
pc = pcap_open_dead(DLT_EN10MB, MIN_PACKET_SIZE);
|
||||||
if (pc != NULL) {
|
if (pc != NULL) {
|
||||||
if (pcap_compile(pc, &fcode, rfilter, 0, 0) != -1) {
|
if (pcap_compile(pc, &fcode, rfilter, 0, 0) != -1) {
|
||||||
fprintf(stderr,
|
cmdarg_err_cont(
|
||||||
" Note: That display filter code looks like a valid capture filter;\n"
|
" Note: That display filter code looks like a valid capture filter;"
|
||||||
" maybe you mixed them up?\n");
|
cmdarg_err_cont(
|
||||||
|
" maybe you mixed them up?");
|
||||||
}
|
}
|
||||||
pcap_close(pc);
|
pcap_close(pc);
|
||||||
}
|
}
|
||||||
|
@ -1421,9 +1406,9 @@ main(int argc, char *argv[])
|
||||||
if (!has_wpcap) {
|
if (!has_wpcap) {
|
||||||
char *detailed_err;
|
char *detailed_err;
|
||||||
|
|
||||||
fprintf(stderr, "tethereal: WinPcap couldn't be found.\n");
|
cmdarg_err("WinPcap couldn't be found.");
|
||||||
detailed_err = cant_load_winpcap_err("Tethereal");
|
detailed_err = cant_load_winpcap_err("Tethereal");
|
||||||
fprintf(stderr, "%s\n", detailed_err);
|
cmdarg_err_cont("%s", detailed_err);
|
||||||
g_free(detailed_err);
|
g_free(detailed_err);
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
@ -1448,12 +1433,12 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
case CANT_GET_INTERFACE_LIST:
|
case CANT_GET_INTERFACE_LIST:
|
||||||
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
cant_get_if_list_errstr = cant_get_if_list_error_message(err_str);
|
||||||
fprintf(stderr, "tethereal: %s\n", cant_get_if_list_errstr);
|
cmdarg_err("%s", cant_get_if_list_errstr);
|
||||||
g_free(cant_get_if_list_errstr);
|
g_free(cant_get_if_list_errstr);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_INTERFACES_FOUND:
|
case NO_INTERFACES_FOUND:
|
||||||
fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
|
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exit(2);
|
exit(2);
|
||||||
|
@ -1470,23 +1455,20 @@ main(int argc, char *argv[])
|
||||||
lt_list = get_pcap_linktype_list(capture_opts.iface, err_str);
|
lt_list = get_pcap_linktype_list(capture_opts.iface, err_str);
|
||||||
if (lt_list == NULL) {
|
if (lt_list == NULL) {
|
||||||
if (err_str[0] != '\0') {
|
if (err_str[0] != '\0') {
|
||||||
fprintf(stderr, "tethereal: The list of data link types for the capture device could not be obtained (%s).\n"
|
cmdarg_err("The list of data link types for the capture device could not be obtained (%s).\n"
|
||||||
"Please check to make sure you have sufficient permissions, and that\n"
|
"Please check to make sure you have sufficient permissions, and that\n"
|
||||||
"you have the proper interface or pipe specified.\n", err_str);
|
"you have the proper interface or pipe specified.", err_str);
|
||||||
} else
|
} else
|
||||||
fprintf(stderr, "tethereal: The capture device has no data link types.\n");
|
cmdarg_err("The capture device has no data link types.");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
fprintf(stderr, "Data link types (use option -y to set):\n");
|
cmdarg_err_cont("Data link types (use option -y to set):");
|
||||||
for (lt_entry = lt_list; lt_entry != NULL;
|
for (lt_entry = lt_list; lt_entry != NULL;
|
||||||
lt_entry = g_list_next(lt_entry)) {
|
lt_entry = g_list_next(lt_entry)) {
|
||||||
data_link_info = lt_entry->data;
|
data_link_info = lt_entry->data;
|
||||||
fprintf(stderr, " %s", data_link_info->name);
|
cmdarg_err_cont(" %s (%s)",
|
||||||
if (data_link_info->description != NULL)
|
data_link_info->name,
|
||||||
fprintf(stderr, " (%s)", data_link_info->description);
|
(data_link_info->description != NULL) ? data_link_info->description : "not supported");
|
||||||
else
|
|
||||||
fprintf(stderr, " (not supported)");
|
|
||||||
putchar('\n');
|
|
||||||
}
|
}
|
||||||
free_pcap_linktype_list(lt_list);
|
free_pcap_linktype_list(lt_list);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -1510,7 +1492,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* No - complain. */
|
/* No - complain. */
|
||||||
fprintf(stderr, "This version of Tethereal was not built with support for capturing packets.\n");
|
cmdarg_err("This version of Tethereal was not built with support for capturing packets.");
|
||||||
exit(2);
|
exit(2);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1579,12 +1561,12 @@ capture(char *save_file, int out_file_type)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* try to set the capture buffer size */
|
/* try to set the capture buffer size */
|
||||||
if (pcap_setbuff(ld.pch, capture_opts.buffer_size * 1024 * 1024) != 0) {
|
if (pcap_setbuff(ld.pch, capture_opts.buffer_size * 1024 * 1024) != 0) {
|
||||||
fprintf(stderr, "tethereal: Couldn't set the capture buffer size!\n"
|
cmdarg_err("Couldn't set the capture buffer size!\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The capture buffer size of %luMB seems to be too high for your machine,\n"
|
"The capture buffer size of %luMB seems to be too high for your machine,\n"
|
||||||
"the default of 1MB will be used.\n"
|
"the default of 1MB will be used.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Nonetheless, the capture is started.\n",
|
"Nonetheless, the capture is started.",
|
||||||
capture_opts.buffer_size);
|
capture_opts.buffer_size);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1705,8 +1687,8 @@ capture(char *save_file, int out_file_type)
|
||||||
* only for filters that check for broadcast IP addresses, so
|
* only for filters that check for broadcast IP addresses, so
|
||||||
* we just warn the user, and punt and use 0.
|
* we just warn the user, and punt and use 0.
|
||||||
*/
|
*/
|
||||||
fprintf(stderr,
|
cmdarg_err(
|
||||||
"Warning: Couldn't obtain netmask info (%s).\n", lookup_net_err_str);
|
"Warning: Couldn't obtain netmask info (%s).", lookup_net_err_str);
|
||||||
netmask = 0;
|
netmask = 0;
|
||||||
}
|
}
|
||||||
if (pcap_compile(ld.pch, &fcode, capture_opts.cfilter, 1, netmask) < 0) {
|
if (pcap_compile(ld.pch, &fcode, capture_opts.cfilter, 1, netmask) < 0) {
|
||||||
|
@ -1782,7 +1764,7 @@ capture(char *save_file, int out_file_type)
|
||||||
/* Does "open_err_str" contain a non-empty string? If so, "pcap_open_live()"
|
/* Does "open_err_str" contain a non-empty string? If so, "pcap_open_live()"
|
||||||
returned a warning; print it, but keep capturing. */
|
returned a warning; print it, but keep capturing. */
|
||||||
if (open_err_str[0] != '\0')
|
if (open_err_str[0] != '\0')
|
||||||
fprintf(stderr, "tethereal: WARNING: %s.\n", open_err_str);
|
cmdarg_err("WARNING: %s.", open_err_str);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Catch a CTRL+C event and, if we get it, clean up and exit. */
|
/* Catch a CTRL+C event and, if we get it, clean up and exit. */
|
||||||
|
@ -1959,13 +1941,13 @@ capture(char *save_file, int out_file_type)
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (ld.from_pipe) {
|
if (ld.from_pipe) {
|
||||||
if (ld.pipe_err == PIPERR) {
|
if (ld.pipe_err == PIPERR) {
|
||||||
fprintf(stderr, "tethereal: Error while capturing packets: %s\n",
|
cmdarg_err("Error while capturing packets: %s",
|
||||||
errmsg);
|
errmsg);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
fprintf(stderr, "tethereal: Error while capturing packets: %s\n",
|
cmdarg_err("Error while capturing packets: %s",
|
||||||
pcap_geterr(ld.pch));
|
pcap_geterr(ld.pch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2003,7 +1985,7 @@ capture(char *save_file, int out_file_type)
|
||||||
fprintf(stderr, "%u packets dropped\n", stats.ps_drop);
|
fprintf(stderr, "%u packets dropped\n", stats.ps_drop);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "tethereal: Can't get packet-drop statistics: %s\n",
|
cmdarg_err("Can't get packet-drop statistics: %s",
|
||||||
pcap_geterr(ld.pch));
|
pcap_geterr(ld.pch));
|
||||||
}
|
}
|
||||||
pcap_close(ld.pch);
|
pcap_close(ld.pch);
|
||||||
|
@ -2021,7 +2003,7 @@ error:
|
||||||
}
|
}
|
||||||
g_free(save_file);
|
g_free(save_file);
|
||||||
save_file = NULL;
|
save_file = NULL;
|
||||||
fprintf(stderr, "tethereal: %s\n", errmsg);
|
cmdarg_err("%s", errmsg);
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (ld.from_pipe) {
|
if (ld.from_pipe) {
|
||||||
if (pipe_fd >= 0)
|
if (pipe_fd >= 0)
|
||||||
|
@ -2212,33 +2194,28 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNSUPPORTED_FILE_TYPE:
|
case WTAP_ERR_UNSUPPORTED_FILE_TYPE:
|
||||||
fprintf(stderr,
|
cmdarg_err("Capture files can't be written in that format.");
|
||||||
"tethereal: Capture files can't be written in that format.\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
||||||
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
|
case WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED:
|
||||||
fprintf(stderr,
|
cmdarg_err("The capture file being read can't be written in "
|
||||||
"tethereal: The capture file being read can't be written in "
|
"that format.");
|
||||||
"that format.\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_CANT_OPEN:
|
case WTAP_ERR_CANT_OPEN:
|
||||||
fprintf(stderr,
|
cmdarg_err("The file \"%s\" couldn't be created for some "
|
||||||
"tethereal: The file \"%s\" couldn't be created for some "
|
"unknown reason.",
|
||||||
"unknown reason.\n",
|
|
||||||
*save_file == '\0' ? "stdout" : save_file);
|
*save_file == '\0' ? "stdout" : save_file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_SHORT_WRITE:
|
case WTAP_ERR_SHORT_WRITE:
|
||||||
fprintf(stderr,
|
cmdarg_err("A full header couldn't be written to the file \"%s\".",
|
||||||
"tethereal: A full header couldn't be written to the file \"%s\".\n",
|
|
||||||
*save_file == '\0' ? "stdout" : save_file);
|
*save_file == '\0' ? "stdout" : save_file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
cmdarg_err("The file \"%s\" could not be created: %s.",
|
||||||
"tethereal: The file \"%s\" could not be created: %s\n.",
|
|
||||||
*save_file == '\0' ? "stdout" : save_file,
|
*save_file == '\0' ? "stdout" : save_file,
|
||||||
wtap_strerror(err));
|
wtap_strerror(err));
|
||||||
break;
|
break;
|
||||||
|
@ -2270,32 +2247,27 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
case WTAP_ERR_UNSUPPORTED_ENCAP:
|
||||||
fprintf(stderr,
|
cmdarg_err("\"%s\" has a packet with a network type that Tethereal doesn't support.\n(%s)",
|
||||||
"tethereal: \"%s\" has a packet with a network type that Tethereal doesn't support.\n(%s)\n",
|
|
||||||
cf->filename, err_info);
|
cf->filename, err_info);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_CANT_READ:
|
case WTAP_ERR_CANT_READ:
|
||||||
fprintf(stderr,
|
cmdarg_err("An attempt to read from \"%s\" failed for some unknown reason.",
|
||||||
"tethereal: An attempt to read from \"%s\" failed for some unknown reason.\n",
|
|
||||||
cf->filename);
|
cf->filename);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_SHORT_READ:
|
case WTAP_ERR_SHORT_READ:
|
||||||
fprintf(stderr,
|
cmdarg_err("\"%s\" appears to have been cut short in the middle of a packet.",
|
||||||
"tethereal: \"%s\" appears to have been cut short in the middle of a packet.\n",
|
|
||||||
cf->filename);
|
cf->filename);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_BAD_RECORD:
|
case WTAP_ERR_BAD_RECORD:
|
||||||
fprintf(stderr,
|
cmdarg_err("\"%s\" appears to be damaged or corrupt.\n(%s)",
|
||||||
"tethereal: \"%s\" appears to be damaged or corrupt.\n(%s)\n",
|
|
||||||
cf->filename, err_info);
|
cf->filename, err_info);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
cmdarg_err("An error occurred while reading \"%s\": %s.",
|
||||||
"tethereal: An error occurred while reading \"%s\": %s.\n",
|
|
||||||
cf->filename, wtap_strerror(err));
|
cf->filename, wtap_strerror(err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2527,41 +2499,35 @@ show_capture_file_io_error(const char *fname, int err, gboolean is_close)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case ENOSPC:
|
case ENOSPC:
|
||||||
fprintf(stderr,
|
cmdarg_err("Not all the packets could be written to \"%s\" because there is "
|
||||||
"tethereal: Not all the packets could be written to \"%s\" because there is "
|
"no space left on the file system.",
|
||||||
"no space left on the file system.\n",
|
|
||||||
fname);
|
fname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef EDQUOT
|
#ifdef EDQUOT
|
||||||
case EDQUOT:
|
case EDQUOT:
|
||||||
fprintf(stderr,
|
cmdarg_err("Not all the packets could be written to \"%s\" because you are "
|
||||||
"tethereal: Not all the packets could be written to \"%s\" because you are "
|
"too close to, or over your disk quota.",
|
||||||
"too close to, or over your disk quota.\n",
|
|
||||||
fname);
|
fname);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case WTAP_ERR_CANT_CLOSE:
|
case WTAP_ERR_CANT_CLOSE:
|
||||||
fprintf(stderr,
|
cmdarg_err("\"%s\" couldn't be closed for some unknown reason.",
|
||||||
"tethereal: \"%s\" couldn't be closed for some unknown reason.\n",
|
|
||||||
fname);
|
fname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WTAP_ERR_SHORT_WRITE:
|
case WTAP_ERR_SHORT_WRITE:
|
||||||
fprintf(stderr,
|
cmdarg_err("Not all the packets could be written to \"%s\".",
|
||||||
"tethereal: Not all the packets could be written to \"%s\".\n",
|
|
||||||
fname);
|
fname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (is_close) {
|
if (is_close) {
|
||||||
fprintf(stderr,
|
cmdarg_err("\"%s\" could not be closed: %s.",
|
||||||
"tethereal: \"%s\" could not be closed: %s.\n",
|
|
||||||
fname, wtap_strerror(err));
|
fname, wtap_strerror(err));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
cmdarg_err("An error occurred while writing to \"%s\": %s.",
|
||||||
"tethereal: An error occurred while writing to \"%s\": %s.\n",
|
|
||||||
fname, wtap_strerror(err));
|
fname, wtap_strerror(err));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2930,22 +2896,19 @@ show_print_file_io_error(int err)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
|
|
||||||
case ENOSPC:
|
case ENOSPC:
|
||||||
fprintf(stderr,
|
cmdarg_err("Not all the packets could be printed because there is "
|
||||||
"tethereal: Not all the packets could be printed because there is "
|
"no space left on the file system.");
|
||||||
"no space left on the file system.\n");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef EDQUOT
|
#ifdef EDQUOT
|
||||||
case EDQUOT:
|
case EDQUOT:
|
||||||
fprintf(stderr,
|
cmdarg_err("Not all the packets could be printed because you are "
|
||||||
"tethereal: Not all the packets could be printed because you are "
|
"too close to, or over your disk quota.");
|
||||||
"too close to, or over your disk quota.\n");
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
cmdarg_err("An error occurred while printing packets: %s.",
|
||||||
"tethereal: An error occurred while printing packets: %s.\n",
|
|
||||||
strerror(err));
|
strerror(err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3111,7 +3074,7 @@ cf_open(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
|
||||||
fail:
|
fail:
|
||||||
g_snprintf(err_msg, sizeof err_msg,
|
g_snprintf(err_msg, sizeof err_msg,
|
||||||
cf_open_error_message(*err, err_info, FALSE, 0), fname);
|
cf_open_error_message(*err, err_info, FALSE, 0), fname);
|
||||||
fprintf(stderr, "tethereal: %s\n", err_msg);
|
cmdarg_err("%s", err_msg);
|
||||||
return CF_ERROR;
|
return CF_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3420,7 +3383,7 @@ failure_message(const char *msg_format, va_list ap)
|
||||||
static void
|
static void
|
||||||
read_failure_message(const char *filename, int err)
|
read_failure_message(const char *filename, int err)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "tethereal: An error occurred while reading from the file \"%s\": %s.\n",
|
cmdarg_err("An error occurred while reading from the file \"%s\": %s.",
|
||||||
filename, strerror(err));
|
filename, strerror(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue