diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2021-06-15 00:06:02 +0100 |
---|---|---|
committer | Wireshark GitLab Utility <gerald+gitlab-utility@wireshark.org> | 2021-06-16 12:50:27 +0000 |
commit | 39df3ae3c0ff12da5f5630b89a147b65588cc4c2 (patch) | |
tree | 280be0d508116a8fdb3d3a719f249497868a12c2 /extcap | |
parent | 4c4bb915c866f234e527ae0a5fc296ef3f732a0e (diff) |
Replace g_log() calls with ws_log()
Diffstat (limited to 'extcap')
-rw-r--r-- | extcap/androiddump.c | 274 | ||||
-rw-r--r-- | extcap/ciscodump.c | 58 | ||||
-rw-r--r-- | extcap/dpauxmon.c | 60 | ||||
-rw-r--r-- | extcap/etw_message.c | 4 | ||||
-rw-r--r-- | extcap/etwdump.c | 26 | ||||
-rw-r--r-- | extcap/extcap-base.c | 6 | ||||
-rw-r--r-- | extcap/randpktdump.c | 26 | ||||
-rw-r--r-- | extcap/sdjournal.c | 66 | ||||
-rw-r--r-- | extcap/ssh-base.c | 2 | ||||
-rw-r--r-- | extcap/sshdump.c | 54 | ||||
-rw-r--r-- | extcap/udpdump.c | 42 |
11 files changed, 314 insertions, 304 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c index 164ddebf17..afd13c1c4a 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -354,10 +354,10 @@ static const char* interface_to_logbuf(char* interface) } /* - * General errors and warnings are reported through g_warning() in + * General errors and warnings are reported through ws_warning() in * androiddump. * - * Unfortunately, g_warning() may be a macro, so we do it by calling + * Unfortunately, ws_warning() may be a macro, so we do it by calling * g_logv() with the appropriate arguments. */ static void @@ -381,7 +381,7 @@ static void useSndTimeout(socket_handle_t sock) { res = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &socket_timeout, (socklen_t)sizeof(socket_timeout)); #endif if (res != 0) - g_debug("Can't set socket timeout, using default"); + ws_debug("Can't set socket timeout, using default"); } static void useNonBlockingConnectTimeout(socket_handle_t sock) { @@ -406,9 +406,9 @@ static void useNonBlockingConnectTimeout(socket_handle_t sock) { res_rcv = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &socket_timeout, sizeof(socket_timeout)); #endif if (res_snd != 0) - g_debug("Can't set socket timeout, using default"); + ws_debug("Can't set socket timeout, using default"); if (res_rcv != 0) - g_debug("Can't set socket timeout, using default"); + ws_debug("Can't set socket timeout, using default"); } static void useNormalConnectTimeout(socket_handle_t sock) { @@ -428,7 +428,7 @@ static void useNormalConnectTimeout(socket_handle_t sock) { res_rcv = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &socket_timeout, sizeof(socket_timeout)); #endif if (res_rcv != 0) - g_debug("Can't set socket timeout, using default"); + ws_debug("Can't set socket timeout, using default"); } static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { @@ -440,13 +440,13 @@ static struct extcap_dumper extcap_dumper_open(char *fifo, int encap) { pcap = pcap_open_dead_with_tstamp_precision(encap, PACKET_LENGTH, PCAP_TSTAMP_PRECISION_NANO); extcap_dumper.dumper.pcap = pcap_dump_open(pcap, fifo); if (!extcap_dumper.dumper.pcap) { - g_warning("Can't open %s for saving packets: %s", fifo, pcap_geterr(pcap)); + ws_warning("Can't open %s for saving packets: %s", fifo, pcap_geterr(pcap)); pcap_close(pcap); exit(EXIT_CODE_CANNOT_SAVE_LIBPCAP_DUMP); } extcap_dumper.encap = encap; if (pcap_dump_flush(extcap_dumper.dumper.pcap) == -1) { - g_warning("Write to %s failed: %s", fifo, g_strerror(errno)); + ws_warning("Write to %s failed: %s", fifo, g_strerror(errno)); } #else wtap_dump_params params = WTAP_DUMP_PARAMS_INIT; @@ -488,7 +488,7 @@ static gboolean extcap_dumper_dump(struct extcap_dumper extcap_dumper, pcap_dump((u_char *) extcap_dumper.dumper.pcap, &pcap_header, buffer); if (pcap_dump_flush(extcap_dumper.dumper.pcap) == -1) { - g_warning("Write to %s failed: %s", fifo, g_strerror(errno)); + ws_warning("Write to %s failed: %s", fifo, g_strerror(errno)); } #else int err = 0; @@ -555,7 +555,7 @@ static socket_handle_t adb_connect(const char *server_ip, unsigned short *server ws_inet_pton4(server_ip, &(server.sin_addr.s_addr)); if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { - g_warning("Cannot open system TCP socket: %s", strerror(errno)); + ws_warning("Cannot open system TCP socket: %s", strerror(errno)); return INVALID_SOCKET; } @@ -605,12 +605,12 @@ static socket_handle_t adb_connect(const char *server_ip, unsigned short *server }; if (connect(sock, (struct sockaddr *) &server, (socklen_t)sizeof(server)) == SOCKET_ERROR) { - g_warning("Cannot connect to ADB: <%s> Please check that adb daemon is running.", strerror(errno)); + ws_warning("Cannot connect to ADB: <%s> Please check that adb daemon is running.", strerror(errno)); closesocket(sock); return INVALID_SOCKET; } #else - g_debug("Cannot connect to ADB: <%s> Please check that adb daemon is running.", strerror(errno)); + ws_debug("Cannot connect to ADB: <%s> Please check that adb daemon is running.", strerror(errno)); closesocket(sock); return INVALID_SOCKET; #endif @@ -618,18 +618,18 @@ static socket_handle_t adb_connect(const char *server_ip, unsigned short *server length = sizeof(client); if (getsockname(sock, (struct sockaddr *) &client, &length)) { - g_warning("getsockname: %s", strerror(errno)); + ws_warning("getsockname: %s", strerror(errno)); closesocket(sock); return INVALID_SOCKET; } if (length != sizeof(client)) { - g_warning("incorrect length"); + ws_warning("incorrect length"); closesocket(sock); return INVALID_SOCKET; } - g_debug("Client port %u", GUINT16_FROM_BE(client.sin_port)); + ws_debug("Client port %u", GUINT16_FROM_BE(client.sin_port)); return sock; } @@ -647,7 +647,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, adb_service_length = strlen(adb_service); if (adb_service_length > INT_MAX) { - g_warning("Service name too long when sending <%s> to ADB daemon", adb_service); + ws_warning("Service name too long when sending <%s> to ADB daemon", adb_service); if (data_length) *data_length = 0; return NULL; @@ -655,7 +655,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, /* 8 bytes of hex length + terminating NUL */ if (buffer_length < 9) { - g_warning("Buffer for response too short while sending <%s> to ADB daemon", adb_service); + ws_warning("Buffer for response too short while sending <%s> to ADB daemon", adb_service); if (data_length) *data_length = 0; return NULL; @@ -664,13 +664,13 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, g_snprintf(buffer, (gulong)buffer_length, ADB_HEX4_FORMAT, adb_service_length); result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { - g_warning("Error while sending <%s> length to ADB daemon", adb_service); + ws_warning("Error while sending <%s> length to ADB daemon", adb_service); return NULL; } result = send(sock, adb_service, (int) adb_service_length, 0); if (result != (gssize) adb_service_length) { - g_warning("Error while sending <%s> to ADB daemon", adb_service); + ws_warning("Error while sending <%s> to ADB daemon", adb_service); if (data_length) *data_length = 0; return NULL; @@ -684,7 +684,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, result = recv(sock, buffer + used_buffer_length, (int)bytes_to_read, 0); if (result <= 0) { - g_warning("Broken socket connection while fetching reply status for <%s>", adb_service); + ws_warning("Broken socket connection while fetching reply status for <%s>", adb_service); if (data_length) *data_length = 0; return NULL; @@ -697,7 +697,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, tmp_buffer = buffer[8]; buffer[8] = '\0'; if (!ws_hexstrtou32(buffer + 4, NULL, &length)) { - g_warning("Invalid reply length <%s> while reading reply for <%s>", buffer + 4, adb_service); + ws_warning("Invalid reply length <%s> while reading reply for <%s>", buffer + 4, adb_service); if (data_length) *data_length = 0; return NULL; @@ -705,7 +705,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, buffer[8] = tmp_buffer; if (buffer_length < length + 8) { - g_warning("Buffer for response too short while sending <%s> to ADB daemon", adb_service); + ws_warning("Buffer for response too short while sending <%s> to ADB daemon", adb_service); if (data_length) *data_length = 0; return NULL; @@ -718,7 +718,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, result = recv(sock, buffer + used_buffer_length, (int)bytes_to_read, 0); if (result <= 0) { - g_warning("Broken socket connection while reading reply for <%s>", adb_service); + ws_warning("Broken socket connection while reading reply for <%s>", adb_service); if (data_length) *data_length = 0; return NULL; @@ -731,7 +731,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service, *data_length = used_buffer_length - 8; if (memcmp(status, "OKAY", 4)) { - g_warning("Error while receiving by ADB for <%s>", adb_service); + ws_warning("Error while receiving by ADB for <%s>", adb_service); if (data_length) *data_length = 0; return NULL; @@ -753,13 +753,13 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { - g_warning("Error while sending <%s> to ADB daemon", adb_service); + ws_warning("Error while sending <%s> to ADB daemon", adb_service); return NULL; } result = send(sock, adb_service, (int) adb_service_length, 0); if (result != (gssize) adb_service_length) { - g_warning("Error while sending <%s> to ADB", adb_service); + ws_warning("Error while sending <%s> to ADB", adb_service); if (data_length) *data_length = 0; return NULL; @@ -770,7 +770,7 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch result = recv(sock, buffer + used_buffer_length, (int)(buffer_length - used_buffer_length), 0); if (result <= 0) { - g_warning("Broken socket connection while fetching reply status for <%s>", adb_service); + ws_warning("Broken socket connection while fetching reply status for <%s>", adb_service); return NULL; } @@ -784,7 +784,7 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch result= recv(sock, buffer + used_buffer_length, (int)(buffer_length - used_buffer_length), 0); if (result < 0) { - g_warning("Broken socket connection while reading reply for <%s>", adb_service); + ws_warning("Broken socket connection while reading reply for <%s>", adb_service); return NULL; } else if (result == 0) { @@ -798,7 +798,7 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch *data_length = used_buffer_length - 4; if (memcmp(status, "OKAY", 4)) { - g_warning("Error while receiving by ADB for <%s>", adb_service); + ws_warning("Error while receiving by ADB for <%s>", adb_service); if (data_length) *data_length = 0; return NULL; @@ -819,13 +819,13 @@ static int adb_send(socket_handle_t sock, const char *adb_service) { result = send(sock, buffer, ADB_HEX4_LEN, 0); if (result < ADB_HEX4_LEN) { - g_warning("Error while sending <%s> to ADB daemon", adb_service); + ws_warning("Error while sending <%s> to ADB daemon", adb_service); return EXIT_CODE_ERROR_WHILE_SENDING_ADB_PACKET_1; } result = send(sock, adb_service, (int) adb_service_length, 0); if (result != (gssize) adb_service_length) { - g_warning("Error while sending <%s> to ADB", adb_service); + ws_warning("Error while sending <%s> to ADB", adb_service); return EXIT_CODE_ERROR_WHILE_SENDING_ADB_PACKET_1; } @@ -834,7 +834,7 @@ static int adb_send(socket_handle_t sock, const char *adb_service) { result = recv(sock, buffer + used_buffer_length, 4 - used_buffer_length, 0); if (result <= 0) { - g_warning("Broken socket connection while fetching reply status for <%s>", adb_service); + ws_warning("Broken socket connection while fetching reply status for <%s>", adb_service); return EXIT_CODE_ERROR_WHILE_RECEIVING_ADB_PACKET_STATUS; } @@ -843,7 +843,7 @@ static int adb_send(socket_handle_t sock, const char *adb_service) { } if (memcmp(buffer, "OKAY", 4)) { - g_debug("Error while receiving by ADB for <%s>", adb_service); + ws_debug("Error while receiving by ADB for <%s>", adb_service); return EXIT_CODE_ERROR_WHILE_RECEIVING_ADB_PACKET_DATA; } @@ -865,7 +865,7 @@ adb_connect_transport(const char *server_ip, unsigned short *server_tcp_port, sock = adb_connect(server_ip, server_tcp_port); if (sock == INVALID_SOCKET) { - g_warning("Error while connecting to adb server"); + ws_warning("Error while connecting to adb server"); return sock; } @@ -874,7 +874,7 @@ adb_connect_transport(const char *server_ip, unsigned short *server_tcp_port, } else { result = g_snprintf(transport_buf, sizeof(transport_buf), adb_transport_serial_templace, serial_number); if (result <= 0 || result > (int)sizeof(transport_buf)) { - g_warning("Error while completing adb packet for transport"); + ws_warning("Error while completing adb packet for transport"); closesocket(sock); return INVALID_SOCKET; } @@ -882,7 +882,7 @@ adb_connect_transport(const char *server_ip, unsigned short *server_tcp_port, result = adb_send(sock, transport); if (result) { - g_warning("Error while setting adb transport for <%s>", transport_buf); + ws_warning("Error while setting adb transport for <%s>", transport_buf); closesocket(sock); return INVALID_SOCKET; } @@ -943,7 +943,7 @@ static int add_tcpdump_interfaces(extcap_parameters * extcap_conf, const char *a sock = adb_connect_transport(adb_server_ip, adb_server_tcp_port, serial_number); if (sock == INVALID_SOCKET) { - g_warning("Failed to connect to adb server"); + ws_warning("Failed to connect to adb server"); return EXIT_CODE_GENERIC; } @@ -951,14 +951,14 @@ static int add_tcpdump_interfaces(extcap_parameters * extcap_conf, const char *a closesocket(sock); if (!response) { - g_warning("Failed to get list of available tcpdump interfaces"); + ws_warning("Failed to get list of available tcpdump interfaces"); return EXIT_CODE_GENERIC; } response[data_length] = '\0'; regex = g_regex_new(regex_ifaces, G_REGEX_RAW, (GRegexMatchFlags)0, &err); if (!regex) { - g_warning("Failed to compile regex for tcpdump interface matching"); + ws_warning("Failed to compile regex for tcpdump interface matching"); return EXIT_CODE_GENERIC; } @@ -1025,7 +1025,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ closesocket(sock); if (!device_list) { - g_warning("Cannot get list of interfaces from devices"); + ws_warning("Cannot get list of interfaces from devices"); return EXIT_CODE_CANNOT_GET_INTERFACES_LIST; } @@ -1040,7 +1040,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ result = (int) (pos - prev_pos); pos = strchr(pos, '\n') + 1; if (result >= (int) sizeof(serial_number)) { - g_warning("Serial number too long, ignore device"); + ws_warning("Serial number too long, ignore device"); continue; } memcpy(serial_number, prev_pos, result); @@ -1059,12 +1059,12 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ if (model_name[0] == '\0') strcpy(model_name, "unknown"); - g_debug("Processing device: \"%s\" <%s>" , serial_number, model_name); + ws_debug("Processing device: \"%s\" <%s>" , serial_number, model_name); /* Function will only add tcpdump interfaces if tcpdump is present on the device */ result = add_tcpdump_interfaces(extcap_conf, adb_server_ip, adb_server_tcp_port, serial_number ); if (result) { - g_warning("Error while adding tcpdump interfaces"); + ws_warning("Error while adding tcpdump interfaces"); } sock = adb_connect_transport(adb_server_ip, adb_server_tcp_port, serial_number); @@ -1074,13 +1074,13 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ closesocket(sock); if (!response) { - g_warning("Error on socket: <%s>", helpful_packet); + ws_warning("Error on socket: <%s>", helpful_packet); continue; } response[data_length] = '\0'; api_level = (int) g_ascii_strtoll(response, NULL, 10); - g_debug("Android API Level for %s is %i", serial_number, api_level); + ws_debug("Android API Level for %s is %i", serial_number, api_level); if (api_level < 21) { new_interface(extcap_conf, INTERFACE_ANDROID_LOGCAT_MAIN, model_name, serial_number, "Android Logcat Main"); @@ -1110,18 +1110,18 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ closesocket(sock); if (!response || data_length < 1) { - g_warning("Error while getting hcidump version by <%s> (%p len=%"G_GSSIZE_FORMAT")", + ws_warning("Error while getting hcidump version by <%s> (%p len=%"G_GSSIZE_FORMAT")", adb_hcidump_version, (void*)response, data_length); - g_debug("Android hcidump version for %s is unknown", serial_number); + ws_debug("Android hcidump version for %s is unknown", serial_number); disable_interface = 1; } else { response[data_length] = '\0'; if (g_ascii_strtoull(response, NULL, 10) == 0) { - g_debug("Android hcidump version for %s is unknown", serial_number); + ws_debug("Android hcidump version for %s is unknown", serial_number); disable_interface = 1; } else { - g_debug("Android hcidump version for %s is %s", serial_number, response); + ws_debug("Android hcidump version for %s is %s", serial_number, response); } } @@ -1138,9 +1138,9 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ response = adb_send_and_read(sock, adb_ps_droid_bluetooth, helpful_packet, sizeof(helpful_packet), &data_length); closesocket(sock); if (!response || data_length < 1) { - g_warning("Error while getting Bluetooth application process id by <%s> " + ws_warning("Error while getting Bluetooth application process id by <%s> " "(%p len=%"G_GSSIZE_FORMAT")", adb_ps_droid_bluetooth, (void*)response, data_length); - g_debug( "Android Bluetooth application PID for %s is unknown", serial_number); + ws_debug( "Android Bluetooth application PID for %s is unknown", serial_number); disable_interface = 1; } else { char *data_str; @@ -1151,11 +1151,11 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ data_str = strchr(response, '\n'); if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) { - g_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); + ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); if (result <= 0 || result > (int)sizeof(check_port_buf)) { - g_warning("Error while completing adb packet"); + ws_warning("Error while completing adb packet"); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_6; } @@ -1172,15 +1172,15 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ data_str = strchr(response, '\n'); if (data_str && sscanf(data_str, "%*s %15s", pid) == 1 && strlen(pid) > 10 && strcmp(pid + 9, "10EA") == 0) { - g_debug("Bluedroid External Parser Port for %s is %s", serial_number, pid + 9); + ws_debug("Bluedroid External Parser Port for %s is %s", serial_number, pid + 9); } else { disable_interface = 1; - g_debug("Bluedroid External Parser Port for %s is unknown", serial_number); + ws_debug("Bluedroid External Parser Port for %s is unknown", serial_number); } } } else { disable_interface = 1; - g_debug("Android Bluetooth application PID for %s is unknown", serial_number); + ws_debug("Android Bluetooth application PID for %s is unknown", serial_number); } } @@ -1209,9 +1209,9 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ closesocket(sock); if (!response || data_length < 1) { - g_warning("Error while getting Bluetooth application process id by <%s> " + ws_warning("Error while getting Bluetooth application process id by <%s> " "(%p len=%"G_GSSIZE_FORMAT")", ps_cmd, (void*)response, data_length); - g_debug("Android Bluetooth application PID for %s is unknown", serial_number); + ws_debug("Android Bluetooth application PID for %s is unknown", serial_number); disable_interface = 1; } else { char *data_str; @@ -1226,11 +1226,11 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ data_str = strchr(response, '\n'); if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) { - g_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); + ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid); result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid); if (result <= 0 || result > (int)sizeof(check_port_buf)) { - g_warning("Error while completing adb packet"); + ws_warning("Error while completing adb packet"); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_9; } @@ -1247,19 +1247,19 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_ data_str = strtok(response, "\n"); while (data_str != NULL) { if (sscanf(data_str, "%*s %15s", pid) == 1 && strlen(pid) > 10 && strcmp(pid + 9, "22A8") == 0) { - g_debug("Btsnoop Net Port for %s is %s", serial_number, pid + 9); + ws_debug("Btsnoop Net Port for %s is %s", serial_number, pid + 9); break; } data_str = strtok(NULL, "\n"); } if (data_str == NULL) { disable_interface = 1; - g_debug("Btsnoop Net Port for %s is unknown", serial_number); + ws_debug("Btsnoop Net Port for %s is unknown", serial_number); } } } else { disable_interface = 1; - g_debug("Android Bluetooth application PID for %s is unknown", serial_number); + ws_debug("Android Bluetooth application PID for %s is unknown", serial_number); } } @@ -1277,7 +1277,7 @@ static int list_config(char *interface) { unsigned inc = 0; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_CODE_NO_INTERFACE_SPECIFIED; } @@ -1311,7 +1311,7 @@ static int list_config(char *interface) { } if (ret != EXIT_CODE_SUCCESS) - g_warning("Invalid interface: <%s>", interface); + ws_warning("Invalid interface: <%s>", interface); else extcap_config_debug(&inc); @@ -1357,7 +1357,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, result = adb_send(sock, adb_shell_hcidump); if (result) { - g_warning("Error while starting capture by sending command: %s", adb_shell_hcidump); + ws_warning("Error while starting capture by sending command: %s", adb_shell_hcidump); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1375,13 +1375,13 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1392,7 +1392,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, char *state_line_position = i_position + 1; if (!strncmp(data, "/system/bin/sh: hcidump: not found", 34)) { - g_warning("Command not found for <%s>", adb_shell_hcidump); + ws_warning("Command not found for <%s>", adb_shell_hcidump); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1401,7 +1401,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, if (i_position) { i_position += 1; if (!strncmp(state_line_position, "Can't access device: Permission denied", 38)) { - g_warning("No permission for command <%s>", adb_shell_hcidump); + ws_warning("No permission for command <%s>", adb_shell_hcidump); used_buffer_length = 0; closesocket(sock); sock = INVALID_SOCKET; @@ -1421,7 +1421,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, result = adb_send(sock, adb_shell_su_hcidump); if (result) { - g_warning("Error while starting capture by sending command: <%s>", adb_shell_su_hcidump); + ws_warning("Error while starting capture by sending command: <%s>", adb_shell_su_hcidump); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1440,13 +1440,13 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1455,7 +1455,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, i_position = (char *) memchr(data, '\n', used_buffer_length); if (i_position && i_position < data + used_buffer_length) { if (!strncmp(data, "/system/bin/sh: su: not found", 29)) { - g_warning("Command 'su' not found for <%s>", adb_shell_su_hcidump); + ws_warning("Command 'su' not found for <%s>", adb_shell_su_hcidump); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1482,13 +1482,13 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1506,7 +1506,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, hex_data = new_hex_data; hex = g_ascii_strtoll(hex_data, &new_hex_data, 16); if (hex < 0 || hex >= 256 || hex_data == new_hex_data) { - g_warning("data format %s", strerror(errno)); + ws_warning("data format %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1514,7 +1514,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, hex_data = new_hex_data; hex = g_ascii_strtoll(hex_data, &new_hex_data, 16); if (hex < 0 || hex >= 256 || hex_data == new_hex_data) { - g_warning("data format %s", strerror(errno)); + ws_warning("data format %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1527,7 +1527,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, hex_data = new_hex_data; hex = g_ascii_strtoll(hex_data, &new_hex_data, 16); if (hex < 0 || hex >= 256 || hex_data == new_hex_data) { - g_warning("data format %s", strerror(errno)); + ws_warning("data format %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1540,7 +1540,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, hex_data = new_hex_data; hex = g_ascii_strtoll(hex_data, &new_hex_data, 16); if (hex < 0 || hex >= 256 || hex_data == new_hex_data) { - g_warning("data format %s", strerror(errno)); + ws_warning("data format %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1548,7 +1548,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, hex_data = new_hex_data; hex = g_ascii_strtoll(hex_data, &new_hex_data, 16); if (hex < 0 || hex >= 256 || hex_data == new_hex_data) { - g_warning("data format %s", strerror(errno)); + ws_warning("data format %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1563,7 +1563,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, } } else { - g_warning("bad raw stream"); + ws_warning("bad raw stream"); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1583,7 +1583,7 @@ static int capture_android_bluetooth_hcidump(char *interface, char *fifo, &date.tm_year, &date.tm_mon, &date.tm_mday, &date.tm_hour, &date.tm_min, &date.tm_sec, &ms, &direction_character)) { - g_debug("time %04d-%02d-%02d %02d:%02d:%02d.%06d %c", + ws_debug("time %04d-%02d-%02d %02d:%02d:%02d.%06d %c", date.tm_year, date.tm_mon, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec, ms, direction_character); date.tm_mon -= 1; @@ -1653,7 +1653,7 @@ static int adb_forward(char *serial_number, const char *adb_server_ip, unsigned result = g_snprintf(helpful_packet, PACKET_LENGTH, adb_forward_template, (serial_number) ? "host-serial:" : "host", (serial_number) ? serial_number: "", local_tcp_port, server_tcp_port); if (result <= 0 || result > PACKET_LENGTH) { - g_warning("Error while completing adb packet"); + ws_warning("Error while completing adb packet"); closesocket(sock); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_12; } @@ -1694,18 +1694,18 @@ static int capture_android_bluetooth_external_parser(char *interface, if (bt_forward_socket) { if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { - g_warning("Cannot open system TCP socket: %s", strerror(errno)); + ws_warning("Cannot open system TCP socket: %s", strerror(errno)); return EXIT_CODE_GENERIC; } - g_debug("Using config: Server TCP Port=%u, Local IP=%s, Local TCP Port=%u", + ws_debug("Using config: Server TCP Port=%u, Local IP=%s, Local TCP Port=%u", *bt_server_tcp_port, bt_local_ip, *bt_local_tcp_port); if (*bt_local_tcp_port != 0) { int result; result = adb_forward(serial_number, adb_server_ip, adb_server_tcp_port, *bt_local_tcp_port, *bt_server_tcp_port); - g_debug("DO: adb forward tcp:%u (local) tcp:%u (remote) result=%i", + ws_debug("DO: adb forward tcp:%u (local) tcp:%u (remote) result=%i", *bt_local_tcp_port, *bt_server_tcp_port, result); } @@ -1717,25 +1717,25 @@ static int capture_android_bluetooth_external_parser(char *interface, useSndTimeout(sock); if (connect(sock, (struct sockaddr *) &server, sizeof(server)) == SOCKET_ERROR) { - g_warning("<%s> Please check that adb daemon is running.", strerror(errno)); + ws_warning("<%s> Please check that adb daemon is running.", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } slen = (socklen_t)sizeof(client); if (getsockname(sock, (struct sockaddr *) &client, &slen)) { - g_warning("getsockname: %s", strerror(errno)); + ws_warning("getsockname: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (slen != sizeof(client)) { - g_warning("incorrect length"); + ws_warning("incorrect length"); closesocket(sock); return EXIT_CODE_GENERIC; } - g_debug("Client port %u", GUINT16_FROM_BE(client.sin_port)); + ws_debug("Client port %u", GUINT16_FROM_BE(client.sin_port)); } else { int result; @@ -1745,14 +1745,14 @@ static int capture_android_bluetooth_external_parser(char *interface, result = g_snprintf((char *) buffer, PACKET_LENGTH, adb_tcp_bluedroid_external_parser_template, *bt_server_tcp_port); if (result <= 0 || result > PACKET_LENGTH) { - g_warning("Error while completing adb packet"); + ws_warning("Error while completing adb packet"); closesocket(sock); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_14; } result = adb_send(sock, buffer); if (result) { - g_warning("Error while forwarding adb port"); + ws_warning("Error while forwarding adb port"); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1769,7 +1769,7 @@ static int capture_android_bluetooth_external_parser(char *interface, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1777,11 +1777,11 @@ static int capture_android_bluetooth_external_parser(char *interface, if (length <= 0) { if (bt_forward_socket) { /* NOTE: Workaround... It seems that Bluedroid is slower and we can connect to socket that are not really ready... */ - g_warning("Broken socket connection. Try reconnect."); + ws_warning("Broken socket connection. Try reconnect."); closesocket(sock); if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { - g_warning("%s", strerror(errno)); + ws_warning("%s", strerror(errno)); return EXIT_CODE_GENERIC; } @@ -1792,12 +1792,12 @@ static int capture_android_bluetooth_external_parser(char *interface, useSndTimeout(sock); if (connect(sock, (struct sockaddr *) &server, sizeof(server)) == SOCKET_ERROR) { - g_warning("ERROR reconnect: <%s> Please check that adb daemon is running.", strerror(errno)); + ws_warning("ERROR reconnect: <%s> Please check that adb daemon is running.", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } } else { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1807,7 +1807,7 @@ static int capture_android_bluetooth_external_parser(char *interface, used_buffer_length += length; - g_debug("Received: length=%"G_GSSIZE_FORMAT"", length); + ws_debug("Received: length=%"G_GSSIZE_FORMAT"", length); while (((payload[BLUEDROID_H4_PACKET_TYPE] == BLUEDROID_H4_PACKET_TYPE_HCI_CMD || payload[BLUEDROID_H4_PACKET_TYPE] == BLUEDROID_H4_PACKET_TYPE_SCO) && used_buffer_length >= BLUEDROID_TIMESTAMP_SIZE + BLUEDROID_H4_SIZE + 2 + 1 && @@ -1858,14 +1858,14 @@ static int capture_android_bluetooth_external_parser(char *interface, break; default: - g_warning("Invalid stream"); + ws_warning("Invalid stream"); closesocket(sock); return EXIT_CODE_GENERIC; } - g_debug("\t Packet %u: used_buffer_length=%"G_GSSIZE_FORMAT" length=%"G_GSSIZE_FORMAT" captured_length=%i type=0x%02x", id, used_buffer_length, length, captured_length, payload[BLUEDROID_H4_PACKET_TYPE]); + ws_debug("\t Packet %u: used_buffer_length=%"G_GSSIZE_FORMAT" length=%"G_GSSIZE_FORMAT" captured_length=%i type=0x%02x", id, used_buffer_length, length, captured_length, payload[BLUEDROID_H4_PACKET_TYPE]); if (payload[BLUEDROID_H4_PACKET_TYPE] == BLUEDROID_H4_PACKET_TYPE_HCI_EVT) - g_debug("\t Packet: %02x %02x %02x", (unsigned int) payload[0], (unsigned int) payload[1], (unsigned int)payload[2]); + ws_debug("\t Packet: %02x %02x %02x", (unsigned int) payload[0], (unsigned int) payload[1], (unsigned int)payload[2]); id +=1; ts -= BLUEDROID_TIMESTAMP_BASE; @@ -1878,7 +1878,7 @@ static int capture_android_bluetooth_external_parser(char *interface, used_buffer_length -= length - sizeof(own_pcap_bluetooth_h4_header) + BLUEDROID_TIMESTAMP_SIZE; if (used_buffer_length < 0) { - g_warning("Internal Negative used buffer length."); + ws_warning("Internal Negative used buffer length."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1929,7 +1929,7 @@ static int capture_android_bluetooth_btsnoop_net(char *interface, char *fifo, result = adb_send(sock, adb_tcp_btsnoop_net); if (result) { - g_warning("Error while sending command <%s>", adb_tcp_btsnoop_net); + ws_warning("Error while sending command <%s>", adb_tcp_btsnoop_net); closesocket(sock); return EXIT_CODE_ERROR_WHILE_SENDING_ADB_PACKET_2; } @@ -1938,7 +1938,7 @@ static int capture_android_bluetooth_btsnoop_net(char *interface, char *fifo, while (used_buffer_length < BTSNOOP_HDR_LEN) { length = recv(sock, packet + used_buffer_length, (int)(BTSNOOP_HDR_LEN - used_buffer_length), 0); if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1958,13 +1958,13 @@ static int capture_android_bluetooth_btsnoop_net(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -1990,7 +1990,7 @@ static int capture_android_bluetooth_btsnoop_net(char *interface, char *fifo, used_buffer_length -= 24 + GINT32_FROM_BE(*captured_length); if (used_buffer_length < 0) { - g_warning("Internal Negative used buffer length."); + ws_warning("Internal Negative used buffer length."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2051,7 +2051,7 @@ static int capture_android_logcat_text(char *interface, char *fifo, else if (is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_TEXT_CRASH)) logcat_buffer = " -b crash"; else { - g_warning("Unknown interface: <%s>", interface); + ws_warning("Unknown interface: <%s>", interface); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2066,14 +2066,14 @@ static int capture_android_logcat_text(char *interface, char *fifo, result = g_snprintf((char *) packet, PACKET_LENGTH, adb_logcat_template, logcat_buffer, logcat_log_buffer, logcat_custom_parameter); if (result <= 0 || result > PACKET_LENGTH) { - g_warning("Error while completing adb packet"); + ws_warning("Error while completing adb packet"); closesocket(sock); return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_17; } result = adb_send(sock, packet); if (result) { - g_warning("Error while sending command <%s>", packet); + ws_warning("Error while sending command <%s>", packet); closesocket(sock); return EXIT_CODE_ERROR_WHILE_SENDING_ADB_PACKET_3; } @@ -2105,13 +2105,13 @@ static int capture_android_logcat_text(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection. Try reconnect."); + ws_warning("Broken socket connection. Try reconnect."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2198,14 +2198,14 @@ static int capture_android_logcat(char *interface, char *fifo, adb_command = interface_to_logbuf(interface); if (!adb_command) { - g_warning("Unknown interface: <%s>", interface); + ws_warning("Unknown interface: <%s>", interface); closesocket(sock); return EXIT_CODE_GENERIC; } result = adb_send(sock, adb_command); if (result) { - g_warning("Error while sending command <%s>", adb_command); + ws_warning("Error while sending command <%s>", adb_command); closesocket(sock); return EXIT_CODE_ERROR_WHILE_SENDING_ADB_PACKET_4; } @@ -2247,14 +2247,14 @@ static int capture_android_logcat(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { while (endless_loop) { - g_warning("Broken socket connection. Try reconnect."); + ws_warning("Broken socket connection. Try reconnect."); used_buffer_length = 0; closesocket(sock); @@ -2264,7 +2264,7 @@ static int capture_android_logcat(char *interface, char *fifo, result = adb_send(sock, adb_command); if (result) { - g_warning("WARNING: Error while sending command <%s>", adb_command); + ws_warning("WARNING: Error while sending command <%s>", adb_command); continue; } @@ -2337,13 +2337,13 @@ static int capture_android_tcpdump(char *interface, char *fifo, regex = g_regex_new(regex_interface, G_REGEX_RAW, (GRegexMatchFlags)0, &err); if (!regex) { - g_warning("Failed to compile regex for tcpdump interface"); + ws_warning("Failed to compile regex for tcpdump interface"); return EXIT_CODE_GENERIC; } g_regex_match(regex, interface, (GRegexMatchFlags)0, &match); if (!g_match_info_matches(match)) { - g_warning("Failed to determine iface name and serial number"); + ws_warning("Failed to determine iface name and serial number"); g_regex_unref(regex); return EXIT_CODE_GENERIC; } @@ -2365,7 +2365,7 @@ static int capture_android_tcpdump(char *interface, char *fifo, g_free(iface); result = adb_send(sock, tcpdump_cmd); if (result) { - g_warning("Error while setting adb transport"); + ws_warning("Error while setting adb transport"); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2381,13 +2381,13 @@ static int capture_android_tcpdump(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2414,7 +2414,7 @@ static int capture_android_tcpdump(char *interface, char *fifo, nanosecond_timestamps = TRUE; break; default: - g_warning("Received incorrect magic"); + ws_warning("Received incorrect magic"); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2438,13 +2438,13 @@ static int capture_android_tcpdump(char *interface, char *fifo, continue; } else if (errno != 0) { - g_warning("ERROR capture: %s", strerror(errno)); + ws_warning("ERROR capture: %s", strerror(errno)); closesocket(sock); return EXIT_CODE_GENERIC; } if (length <= 0) { - g_warning("Broken socket connection."); + ws_warning("Broken socket connection."); closesocket(sock); return EXIT_CODE_GENERIC; } @@ -2551,7 +2551,7 @@ int main(int argc, char *argv[]) { */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -2632,11 +2632,11 @@ int main(int argc, char *argv[]) { case OPT_CONFIG_ADB_SERVER_TCP_PORT: adb_server_tcp_port = &local_adb_server_tcp_port; if (!optarg){ - g_warning("Impossible exception. Parameter required argument, but there is no it right now."); + ws_warning("Impossible exception. Parameter required argument, but there is no it right now."); goto end; } if (!ws_strtou16(optarg, NULL, adb_server_tcp_port)) { - g_warning("Invalid adb server TCP port: %s", optarg); + ws_warning("Invalid adb server TCP port: %s", optarg); goto end; } break; @@ -2659,7 +2659,7 @@ int main(int argc, char *argv[]) { } if (g_regex_match_simple("(^|\\s)-[bBcDfgLnpPrv]", optarg, G_REGEX_RAW, (GRegexMatchFlags)0)) { - g_error("Found prohibited option in logcat-custom-options"); + ws_error("Found prohibited option in logcat-custom-options"); return EXIT_CODE_GENERIC; } @@ -2669,11 +2669,11 @@ int main(int argc, char *argv[]) { case OPT_CONFIG_BT_SERVER_TCP_PORT: bt_server_tcp_port = &local_bt_server_tcp_port; if (!optarg){ - g_warning("Impossible exception. Parameter required argument, but there is no it right now."); + ws_warning("Impossible exception. Parameter required argument, but there is no it right now."); goto end; } if (!ws_strtou16(optarg, NULL, bt_server_tcp_port)) { - g_warning("Invalid bluetooth server TCP port: %s", optarg); + ws_warning("Invalid bluetooth server TCP port: %s", optarg); goto end; } break; @@ -2686,18 +2686,18 @@ int main(int argc, char *argv[]) { case OPT_CONFIG_BT_LOCAL_TCP_PORT: bt_local_tcp_port = &local_bt_local_tcp_port; if (!optarg){ - g_warning("Impossible exception. Parameter required argument, but there is no it right now."); + ws_warning("Impossible exception. Parameter required argument, but there is no it right now."); goto end; } if (!ws_strtou16(optarg, NULL, bt_local_tcp_port)) { - g_warning("Invalid bluetooth local tcp port: %s", optarg); + ws_warning("Invalid bluetooth local tcp port: %s", optarg); goto end; } break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid argument <%s>. Try --help.\n", argv[optind - 1]); + ws_warning("Invalid argument <%s>. Try --help.\n", argv[optind - 1]); goto end; } } @@ -2720,9 +2720,9 @@ int main(int argc, char *argv[]) { err_msg = ws_init_sockets(); if (err_msg != NULL) { - g_warning("ERROR: %s", err_msg); + ws_warning("ERROR: %s", err_msg); g_free(err_msg); - g_warning("%s", please_report_bug()); + ws_warning("%s", please_report_bug()); goto end; } diff --git a/extcap/ciscodump.c b/extcap/ciscodump.c index 9b845fd8d7..80f8cc5418 100644 --- a/extcap/ciscodump.c +++ b/extcap/ciscodump.c @@ -11,6 +11,7 @@ */ #include "config.h" +#define WS_LOG_DOMAIN "ciscodump" #include <extcap/extcap-base.h> #include <wsutil/interface.h> @@ -18,6 +19,7 @@ #include <wsutil/filesystem.h> #include <wsutil/privileges.h> #include <wsutil/please_report_bug.h> +#include <wsutil/wslog.h> #include <extcap/ssh-base.h> #include <writecap/pcapio.h> @@ -121,7 +123,7 @@ static int read_output_bytes(ssh_channel channel, int bytes, char* outbuf) bytes_read = 0; while(ssh_channel_read_timeout(channel, &chr, 1, 0, 2000) > 0 && bytes_read < total) { - g_debug("%c", chr); + ws_debug("%c", chr); if (chr == '^') return EXIT_FAILURE; if (outbuf) @@ -157,7 +159,7 @@ static int wait_until_data(ssh_channel channel, const guint32 count) while (got < count && rounds--) { if (ssh_channel_printf(channel, "show monitor capture buffer %s parameters\n", WIRESHARK_CAPTURE_BUFFER) == EXIT_FAILURE) { - g_warning("Can't write to channel"); + ws_warning("Can't write to channel"); return EXIT_FAILURE; } if (read_output_bytes(channel, SSH_READ_BLOCK_SIZE, output) == EXIT_FAILURE) @@ -165,14 +167,14 @@ static int wait_until_data(ssh_channel channel, const guint32 count) output_ptr = g_strstr_len(output, strlen(output), "Packets"); if (!output_ptr) { - g_warning("Error in sscanf()"); + ws_warning("Error in sscanf()"); return EXIT_FAILURE; } else { if (sscanf(output_ptr, "Packets : %lu", &got) != 1) return EXIT_FAILURE; } } - g_debug("All packets got: dumping"); + ws_debug("All packets got: dumping"); return EXIT_SUCCESS; } @@ -239,7 +241,7 @@ static void ssh_loop_read(ssh_channel channel, FILE* fp, const guint32 count) do { if (ssh_channel_read_timeout(channel, &chr, 1, FALSE, SSH_READ_TIMEOUT) == SSH_ERROR) { - g_warning("Error reading from channel"); + ws_warning("Error reading from channel"); g_free(packet); return; } @@ -257,10 +259,10 @@ static void ssh_loop_read(ssh_channel channel, FILE* fp, const guint32 count) if (!libpcap_write_packet(fp, (guint32)(curtime / G_USEC_PER_SEC), (guint32)(curtime % G_USEC_PER_SEC), packet_size, packet_size, packet, &bytes_written, &err)) { - g_debug("Error in libpcap_write_packet(): %s", g_strerror(err)); + ws_debug("Error in libpcap_write_packet(): %s", g_strerror(err)); break; } - g_debug("Dumped packet %lu size: %u", packets, packet_size); + ws_debug("Dumped packet %lu size: %u", packets, packet_size); packet_size = 0; status = CISCODUMP_PARSER_STARTING; packets++; @@ -297,14 +299,14 @@ static int check_ios_version(ssh_channel channel) return FALSE; if ((major > MINIMUM_IOS_MAJOR) || (major == MINIMUM_IOS_MAJOR && minor >= MINIMUM_IOS_MINOR)) { - g_debug("Current IOS Version: %u.%u", major, minor); + ws_debug("Current IOS Version: %u.%u", major, minor); if (read_output_bytes(channel, -1, NULL) == EXIT_FAILURE) return FALSE; return TRUE; } } - g_warning("Invalid IOS version. Minimum version: 12.4, current: %u.%u", major, minor); + ws_warning("Invalid IOS version. Minimum version: 12.4, current: %u.%u", major, minor); return FALSE; } @@ -356,7 +358,7 @@ static ssh_channel run_capture(ssh_session sshs, const char* iface, const char* chr = multiline_filter; while((chr = g_strstr_len(chr, strlen(chr), ",")) != NULL) { chr[0] = '\n'; - g_debug("Splitting filter into multiline"); + ws_debug("Splitting filter into multiline"); } ret = ssh_channel_write(channel, multiline_filter, (uint32_t)strlen(multiline_filter)); g_free(multiline_filter); @@ -402,7 +404,7 @@ static ssh_channel run_capture(ssh_session sshs, const char* iface, const char* return channel; error: g_free(cmdline); - g_warning("Error running ssh remote command"); + ws_warning("Error running ssh remote command"); read_output_bytes(channel, -1, NULL); ssh_channel_close(channel); @@ -425,19 +427,19 @@ static int ssh_open_remote_connection(const ssh_params_t* ssh_params, const char /* Open or create the output file */ fp = fopen(fifo, "wb"); if (!fp) { - g_warning("Error creating output file: %s", g_strerror(errno)); + ws_warning("Error creating output file: %s", g_strerror(errno)); return EXIT_FAILURE; } } sshs = create_ssh_connection(ssh_params, &err_info); if (!sshs) { - g_warning("Error creating connection: %s", err_info); + ws_warning("Error creating connection: %s", err_info); goto cleanup; } if (!libpcap_write_file_header(fp, 1, PCAP_SNAPLEN, FALSE, &bytes_written, &err)) { - g_warning("Can't write pcap file header"); + ws_warning("Can't write pcap file header"); goto cleanup; } @@ -467,12 +469,12 @@ static int list_config(char *interface, unsigned int remote_port) char* ipfilter; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, CISCODUMP_EXTCAP_INTERFACE)) { - g_warning("interface must be %s", CISCODUMP_EXTCAP_INTERFACE); + ws_warning("interface must be %s", CISCODUMP_EXTCAP_INTERFACE); return EXIT_FAILURE; } @@ -543,7 +545,7 @@ int main(int argc, char *argv[]) */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -608,7 +610,7 @@ int main(int argc, char *argv[]) case OPT_REMOTE_PORT: if (!ws_strtou16(optarg, NULL, &ssh_params->port) || ssh_params->port == 0) { - g_warning("Invalid port: %s", optarg); + ws_warning("Invalid port: %s", optarg); goto end; } break; @@ -652,19 +654,19 @@ int main(int argc, char *argv[]) case OPT_REMOTE_COUNT: if (!ws_strtou32(optarg, NULL, &count)) { - g_warning("Invalid packet count: %s", optarg); + ws_warning("Invalid packet count: %s", optarg); goto end; } break; case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -673,7 +675,7 @@ int main(int argc, char *argv[]) extcap_cmdline_debug(argv, argc); if (optind != argc) { - g_warning("Unexpected extra option: %s", argv[optind]); + ws_warning("Unexpected extra option: %s", argv[optind]); goto end; } @@ -689,31 +691,31 @@ int main(int argc, char *argv[]) err_msg = ws_init_sockets(); if (err_msg != NULL) { - g_warning("ERROR: %s", err_msg); + ws_warning("ERROR: %s", err_msg); g_free(err_msg); - g_warning("%s", please_report_bug()); + ws_warning("%s", please_report_bug()); goto end; } if (extcap_conf->capture) { if (!ssh_params->host) { - g_warning("Missing parameter: --remote-host"); + ws_warning("Missing parameter: --remote-host"); goto end; } if (!remote_interface) { - g_warning("ERROR: No interface specified (--remote-interface)"); + ws_warning("ERROR: No interface specified (--remote-interface)"); goto end; } if (count == 0) { - g_warning("ERROR: count of packets must be specified (--remote-count)"); + ws_warning("ERROR: count of packets must be specified (--remote-count)"); goto end; } ssh_params->debug = extcap_conf->debug; ret = ssh_open_remote_connection(ssh_params, remote_interface, remote_filter, count, extcap_conf->fifo); } else { - g_debug("You should not come here... maybe some parameter missing?"); + ws_debug("You should not come here... maybe some parameter missing?"); ret = EXIT_FAILURE; } diff --git a/extcap/dpauxmon.c b/extcap/dpauxmon.c index 0ab4f576cc..f3bed612d9 100644 --- a/extcap/dpauxmon.c +++ b/extcap/dpauxmon.c @@ -11,6 +11,7 @@ */ #include "config.h" +#define WS_LOG_DOMAIN "dpauxmon" #include "extcap-base.h" @@ -18,6 +19,7 @@ #include <wsutil/filesystem.h> #include <wsutil/netlink.h> #include <wsutil/privileges.h> +#include <wsutil/wslog.h> #include <writecap/pcapio.h> #include <netlink/netlink.h> @@ -75,12 +77,12 @@ static int list_config(char *interface) unsigned inc = 0; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, DPAUXMON_EXTCAP_INTERFACE)) { - g_warning("interface must be %s", DPAUXMON_EXTCAP_INTERFACE); + ws_warning("interface must be %s", DPAUXMON_EXTCAP_INTERFACE); return EXIT_FAILURE; } @@ -110,12 +112,12 @@ static int setup_dumpfile(const char* fifo, FILE** fp) *fp = fopen(fifo, "wb"); if (!(*fp)) { - g_warning("Error creating output file: %s", g_strerror(errno)); + ws_warning("Error creating output file: %s", g_strerror(errno)); return EXIT_FAILURE; } if (!libpcap_write_file_header(*fp, 275, PCAP_SNAPLEN, FALSE, &bytes_written, &err)) { - g_warning("Can't write pcap file header"); + ws_warning("Can't write pcap file header"); return EXIT_FAILURE; } @@ -129,7 +131,7 @@ static int dump_packet(FILE* fp, const char* buf, const guint32 buflen, guint64 int ret = EXIT_SUCCESS; if (!libpcap_write_packet(fp, ts_usecs / 1000000, ts_usecs % 1000000, buflen, buflen, buf, &bytes_written, &err)) { - g_warning("Can't write packet"); + ws_warning("Can't write packet"); ret = EXIT_FAILURE; } @@ -250,7 +252,7 @@ static int nl_receive_timeout(struct nl_sock* sk, struct sockaddr_nl* nla, unsig int poll_res = poll(&fds, 1, 500); if (poll_res < 0) { - g_debug("poll() failed in nl_receive_timeout"); + ws_debug("poll() failed in nl_receive_timeout"); g_usleep(500000); return -nl_syserr2nlerr(errno); } @@ -267,26 +269,26 @@ static int send_start(struct nl_sock *sock, int family, unsigned int interface_i msg = nlmsg_alloc(); if (msg == NULL) { - g_critical("Unable to allocate netlink message"); + ws_critical("Unable to allocate netlink message"); return -ENOMEM; } hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, 0, DPAUXMON_CMD_START, 1); if (hdr == NULL) { - g_critical("Unable to write genl header"); + ws_critical("Unable to write genl header"); res = -ENOMEM; goto out_free; } if ((err = nla_put_u32(msg, DPAUXMON_ATTR_IFINDEX, interface_id)) < 0) { - g_critical("Unable to add attribute: %s", nl_geterror(err)); + ws_critical("Unable to add attribute: %s", nl_geterror(err)); res = -EIO; goto out_free; } if ((err = nl_send_auto_complete(sock, msg)) < 0) - g_debug("Starting monitor failed, already running?"); + ws_debug("Starting monitor failed, already running?"); out_free: nlmsg_free(msg); @@ -301,24 +303,24 @@ static void send_stop(struct nl_sock *sock, int family, unsigned int interface_i msg = nlmsg_alloc(); if (msg == NULL) { - g_critical("Unable to allocate netlink message"); + ws_critical("Unable to allocate netlink message"); return; } hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, 0, DPAUXMON_CMD_STOP, 1); if (hdr == NULL) { - g_critical("Unable to write genl header"); + ws_critical("Unable to write genl header"); goto out_free; } if ((err = nla_put_u32(msg, DPAUXMON_ATTR_IFINDEX, interface_id)) < 0) { - g_critical("Unable to add attribute: %s", nl_geterror(err)); + ws_critical("Unable to add attribute: %s", nl_geterror(err)); goto out_free; } if ((err = nl_send_auto_complete(sock, msg)) < 0) { - g_critical("Unable to send message: %s", nl_geterror(err)); + ws_critical("Unable to send message: %s", nl_geterror(err)); goto out_free; } @@ -341,7 +343,7 @@ static int handle_data(struct nl_cache_ops *unused _U_, struct genl_cmd *cmd _U_ data_size = nla_len(info->attrs[DPAUXMON_ATTR_DATA]); if (data_size > 19) { - g_debug("Invalid packet size %u", data_size); + ws_debug("Invalid packet size %u", data_size); return NL_SKIP; } @@ -407,7 +409,7 @@ static void run_listener(const char* fifo, unsigned int interface_id) struct nl_cb *socket_cb; if (sigaction(SIGINT, &int_handler, 0)) { - g_warning("Can't set signal handler"); + ws_warning("Can't set signal handler"); return; } @@ -417,30 +419,30 @@ static void run_listener(const char* fifo, unsigned int interface_id) } if (!(sock = nl_socket_alloc())) { - g_critical("Unable to allocate netlink socket"); + ws_critical("Unable to allocate netlink socket"); goto close_out; } if ((err = nl_connect(sock, NETLINK_GENERIC)) < 0) { - g_critical("Unable to connect netlink socket: %s", + ws_critical("Unable to connect netlink socket: %s", nl_geterror(err)); goto free_out; } if ((err = genl_register_family(&ops)) < 0) { - g_critical("Unable to register Generic Netlink family"); + ws_critical("Unable to register Generic Netlink family"); goto err_out; } if ((err = genl_ops_resolve(sock, &ops)) < 0) { - g_critical("Unable to resolve family name"); + ws_critical("Unable to resolve family name"); goto err_out; } /* register notification handler callback */ if ((err = nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL)) < 0) { - g_critical("Unable to modify valid message callback"); + ws_critical("Unable to modify valid message callback"); goto err_out; } @@ -448,7 +450,7 @@ static void run_listener(const char* fifo, unsigned int interface_id) nl_socket_add_membership(sock, grp); if (!(socket_cb = nl_socket_get_cb(sock))) { - g_warning("Can't overwrite recv callback"); + ws_warning("Can't overwrite recv callback"); } else { nl_cb_overwrite_recv(socket_cb, nl_receive_timeout); nl_cb_put(socket_cb); @@ -460,11 +462,11 @@ static void run_listener(const char* fifo, unsigned int interface_id) nl_socket_disable_seq_check(sock); - g_debug("DisplayPort AUX monitor running on interface %u", interface_id); + ws_debug("DisplayPort AUX monitor running on interface %u", interface_id); while(run_loop == TRUE) { if ((err = nl_recvmsgs_default(sock)) < 0) - g_warning("Unable to receive message: %s", nl_geterror(err)); + ws_warning("Unable to receive message: %s", nl_geterror(err)); } send_stop(sock, ops.o_id, interface_id); @@ -498,7 +500,7 @@ int main(int argc, char *argv[]) */ init_progfile_dir_error = init_progfile_dir(argv[0]); if (init_progfile_dir_error != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", init_progfile_dir_error); g_free(init_progfile_dir_error); } @@ -541,19 +543,19 @@ int main(int argc, char *argv[]) case OPT_INTERFACE_ID: if (!ws_strtou32(optarg, NULL, &interface_id)) { - g_warning("Invalid interface id: %s", optarg); + ws_warning("Invalid interface id: %s", optarg); goto end; } break; case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -562,7 +564,7 @@ int main(int argc, char *argv[]) extcap_cmdline_debug(argv, argc); if (optind != argc) { - g_warning("Unexpected extra option: %s", argv[optind]); + ws_warning("Unexpected extra option: %s", argv[optind]); goto end; } diff --git a/extcap/etw_message.c b/extcap/etw_message.c index fa74d8b637..b78e7bc3ff 100644 --- a/extcap/etw_message.c +++ b/extcap/etw_message.c @@ -131,7 +131,7 @@ DWORD GetPropertyLength(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO pInfo, USHORT i, } else { - g_debug("Event %d Unexpected length of 0 for intype %d and outtype %d", g_num_events, + ws_debug("Event %d Unexpected length of 0 for intype %d and outtype %d", g_num_events, pInfo->EventPropertyInfoArray[i].nonStructType.InType, pInfo->EventPropertyInfoArray[i].nonStructType.OutType); @@ -385,7 +385,7 @@ BOOL get_event_information(PEVENT_RECORD pEvent, PTRACE_EVENT_INFO* pInfo) *pInfo = (TRACE_EVENT_INFO*)g_malloc(BufferSize); if (*pInfo == NULL) { - g_debug("Event %d GetEventInformation Failed to allocate memory for event info (size=%lu).", g_num_events, BufferSize); + ws_debug("Event %d GetEventInformation Failed to allocate memory for event info (size=%lu).", g_num_events, BufferSize); goto Exit; } /* Retrieve the event metadata. */ diff --git a/extcap/etwdump.c b/extcap/etwdump.c index 82a0d3a64b..e2ccaeb95f 100644 --- a/extcap/etwdump.c +++ b/extcap/etwdump.c @@ -74,12 +74,12 @@ static int list_config(char* interface) unsigned inc = 0; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, ETW_EXTCAP_INTERFACE)) { - g_warning("Interface must be %s", ETW_EXTCAP_INTERFACE); + ws_warning("Interface must be %s", ETW_EXTCAP_INTERFACE); return EXIT_FAILURE; } /* @@ -132,7 +132,7 @@ int main(int argc, char* argv[]) */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -190,14 +190,14 @@ int main(int argc, char* argv[]) case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: /* Handle extcap specific options */ if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -218,13 +218,13 @@ int main(int argc, char* argv[]) if (extcap_conf->capture) { if (g_strcmp0(extcap_conf->interface, ETW_EXTCAP_INTERFACE)) { - g_warning("ERROR: invalid interface"); + ws_warning("ERROR: invalid interface"); goto end; } if (etlfile == NULL && params == NULL) { - g_warning("ERROR: Both --etlfile and --params arguments are empty"); + ws_warning("ERROR: Both --etlfile and --params arguments are empty"); goto end; } @@ -236,38 +236,38 @@ int main(int argc, char* argv[]) { case WTAP_OPEN_ERROR: if (err_msg != NULL) { - g_warning("etw_dump failed: %s.", + ws_warning("etw_dump failed: %s.", err_msg); g_free(err_msg); } else { - g_warning("etw_dump failed"); + ws_warning("etw_dump failed"); } break; case WTAP_OPEN_NOT_MINE: if (etlfile == NULL) { if (err_msg != NULL) { - g_warning("The live session didn't caputre any event. Error message: %s.", + ws_warning("The live session didn't caputre any event. Error message: %s.", err_msg); g_free(err_msg); } else { - g_warning("The live session didn't caputre any event"); + ws_warning("The live session didn't caputre any event"); } } else { if (err_msg != NULL) { - g_warning("The file %s is not etl format. Error message: %s.", + ws_warning("The file %s is not etl format. Error message: %s.", etlfile, err_msg); g_free(err_msg); } else { - g_warning("The file %s is not etl format", etlfile); + ws_warning("The file %s is not etl format", etlfile); } } break; diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index 0f8a5e6a51..a8e1795104 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -215,7 +215,7 @@ uint8_t extcap_base_handle_interface(extcap_parameters * extcap) /* A fifo must be provided for capture */ if (extcap->capture && (extcap->fifo == NULL || strlen(extcap->fifo) <= 0)) { extcap->capture = 0; - g_error("Extcap Error: No FIFO pipe provided"); + ws_error("Extcap Error: No FIFO pipe provided"); return 0; } @@ -320,7 +320,7 @@ void extcap_init_custom_log(const char* filename) return; custom_log = fopen(filename, "w"); if (!custom_log) - g_error("Can't open custom log file: %s (%s)", filename, strerror(errno)); + ws_error("Can't open custom log file: %s (%s)", filename, strerror(errno)); ws_log_add_custom_file(custom_log); } @@ -340,7 +340,7 @@ void extcap_cmdline_debug(char** ar, const unsigned n) unsigned i; for (i = 0; i < n; i++) g_string_append_printf(cmdline, "%s ", ar[i]); - g_debug("%s", cmdline->str); + ws_debug("%s", cmdline->str); g_string_free(cmdline, TRUE); } diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c index 5014c6641f..1b7e3dec1b 100644 --- a/extcap/randpktdump.c +++ b/extcap/randpktdump.c @@ -83,12 +83,12 @@ static int list_config(char *interface) char** longname_list; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, RANDPKT_EXTCAP_INTERFACE)) { - g_warning("Interface must be %s", RANDPKT_EXTCAP_INTERFACE); + ws_warning("Interface must be %s", RANDPKT_EXTCAP_INTERFACE); return EXIT_FAILURE; } @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -223,7 +223,7 @@ int main(int argc, char *argv[]) case OPT_MAXBYTES: if (!ws_strtou16(optarg, NULL, &maxbytes)) { - g_warning("Invalid parameter maxbytes: %s (max value is %u)", + ws_warning("Invalid parameter maxbytes: %s (max value is %u)", optarg, G_MAXUINT16); goto end; } @@ -231,14 +231,14 @@ int main(int argc, char *argv[]) case OPT_COUNT: if (!ws_strtou64(optarg, NULL, &count)) { - g_warning("Invalid packet count: %s", optarg); + ws_warning("Invalid packet count: %s", optarg); goto end; } break; case OPT_DELAY: if (!ws_strtou64(optarg, NULL, &packet_delay_ms)) { - g_warning("Invalid packet delay: %s", optarg); + ws_warning("Invalid packet delay: %s", optarg); goto end; } break; @@ -258,14 +258,14 @@ int main(int argc, char *argv[]) case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: /* Handle extcap specific options */ if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -285,7 +285,7 @@ int main(int argc, char *argv[]) /* Some sanity checks */ if ((random_type) && (all_random)) { - g_warning("You can specify only one between: --random-type, --all-random"); + ws_warning("You can specify only one between: --random-type, --all-random"); goto end; } @@ -297,16 +297,16 @@ int main(int argc, char *argv[]) err_msg = ws_init_sockets(); if (err_msg != NULL) { - g_warning("ERROR: %s", err_msg); + ws_warning("ERROR: %s", err_msg); g_free(err_msg); - g_warning("%s", please_report_bug()); + ws_warning("%s", please_report_bug()); goto end; } if (extcap_conf->capture) { if (g_strcmp0(extcap_conf->interface, RANDPKT_EXTCAP_INTERFACE)) { - g_warning("ERROR: invalid interface"); + ws_warning("ERROR: invalid interface"); goto end; } @@ -319,7 +319,7 @@ int main(int argc, char *argv[]) if (!example) goto end; - g_debug("Generating packets: %s", example->abbrev); + ws_debug("Generating packets: %s", example->abbrev); randpkt_example_init(example, extcap_conf->fifo, maxbytes); randpkt_loop(example, count, packet_delay_ms); diff --git a/extcap/sdjournal.c b/extcap/sdjournal.c index fd1b9a8f74..0ffdc5b71e 100644 --- a/extcap/sdjournal.c +++ b/extcap/sdjournal.c @@ -18,12 +18,14 @@ */ #include "config.h" +#define WS_LOG_DOMAIN "sdjournal" #include <extcap/extcap-base.h> #include <wsutil/interface.h> #include <wsutil/file_util.h> #include <wsutil/filesystem.h> #include <wsutil/privileges.h> +#include <wsutil/wslog.h> #include <writecap/pcapio.h> #include <wiretap/wtap.h> @@ -89,9 +91,9 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) memcpy(entry_buff, &block_type, 4); jr = sd_journal_next(jnl); - g_debug("sd_journal_next: %d", jr); + ws_debug("sd_journal_next: %d", jr); if (jr < 0) { - g_warning("Error fetching journal entry: %s", g_strerror(jr)); + ws_warning("Error fetching journal entry: %s", g_strerror(jr)); goto end; } else if (jr == 0) { sd_journal_wait(jnl, (uint64_t) -1); @@ -100,7 +102,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) jr = sd_journal_get_cursor(jnl, &cursor); if (jr < 0) { - g_warning("Error fetching cursor: %s", g_strerror(jr)); + ws_warning("Error fetching cursor: %s", g_strerror(jr)); goto end; } data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__CURSOR=%s\n", cursor); @@ -108,31 +110,31 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) jr = sd_journal_get_realtime_usec(jnl, &pkt_rt_ts); if (jr < 0) { - g_warning("Error fetching realtime timestamp: %s", g_strerror(jr)); + ws_warning("Error fetching realtime timestamp: %s", g_strerror(jr)); goto end; } data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__REALTIME_TIMESTAMP=%" G_GUINT64_FORMAT "\n", pkt_rt_ts); jr = sd_journal_get_monotonic_usec(jnl, &mono_ts, &boot_id); if (jr < 0) { - g_warning("Error fetching monotonic timestamp: %s", g_strerror(jr)); + ws_warning("Error fetching monotonic timestamp: %s", g_strerror(jr)); goto end; } sd_id128_to_string(boot_id, boot_id_str + strlen(FLD_BOOT_ID)); data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__MONOTONIC_TIMESTAMP=%" G_GUINT64_FORMAT "\n%s\n", mono_ts, boot_id_str); - g_debug("Entry header is %u bytes", data_end); + ws_debug("Entry header is %u bytes", data_end); SD_JOURNAL_FOREACH_DATA(jnl, fld_data, fld_len) { guint8 *eq_ptr = (guint8 *) memchr(fld_data, '=', fld_len); if (!eq_ptr) { - g_warning("Invalid field."); + ws_warning("Invalid field."); goto end; } if (g_utf8_validate((const char *) fld_data, (gssize) fld_len, NULL)) { // Allow for two trailing newlines, one here and one // at the end of the buffer. if (fld_len > MAX_EXPORT_ENTRY_LENGTH-data_end-2) { - g_debug("Breaking on UTF-8 field: %u + %zd", data_end, fld_len); + ws_debug("Breaking on UTF-8 field: %u + %zd", data_end, fld_len); break; } memcpy(entry_buff+data_end, fld_data, fld_len); @@ -142,7 +144,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) } else { // \n + 64-bit size + \n + trailing \n = 11 if (fld_len > MAX_EXPORT_ENTRY_LENGTH-data_end-11) { - g_debug("Breaking on binary field: %u + %zd", data_end, fld_len); + ws_debug("Breaking on binary field: %u + %zd", data_end, fld_len); break; } ptrdiff_t name_len = eq_ptr - (const guint8 *) fld_data; @@ -169,9 +171,9 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp) memcpy (entry_buff+4, &total_len, 4); memcpy (entry_buff+data_end, &total_len, 4); - g_debug("Attempting to write %u bytes", total_len); + ws_debug("Attempting to write %u bytes", total_len); if (!pcapng_write_block(fp, entry_buff, total_len, &bytes_written, &err)) { - g_warning("Can't write event: %s", strerror(err)); + ws_warning("Can't write event: %s", strerror(err)); ret = EXIT_FAILURE; break; } @@ -202,7 +204,7 @@ static int sdj_start_export(const int start_from_entries, const gboolean start_f /* Open or create the output file */ fp = fopen(fifo, "wb"); if (fp == NULL) { - g_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno)); + ws_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno)); return EXIT_FAILURE; } } @@ -221,26 +223,26 @@ static int sdj_start_export(const int start_from_entries, const gboolean start_f g_free(appname); if (!success) { - g_warning("Can't write pcapng file header"); + ws_warning("Can't write pcapng file header"); goto cleanup; } jr = sd_journal_open(&jnl, 0); if (jr < 0) { - g_warning("Error opening journal: %s", g_strerror(jr)); + ws_warning("Error opening journal: %s", g_strerror(jr)); goto cleanup; } jr = sd_id128_get_boot(&boot_id); if (jr < 0) { - g_warning("Error fetching system boot ID: %s", g_strerror(jr)); + ws_warning("Error fetching system boot ID: %s", g_strerror(jr)); goto cleanup; } sd_id128_to_string(boot_id, boot_id_str + strlen(FLD_BOOT_ID)); jr = sd_journal_add_match(jnl, boot_id_str, strlen(boot_id_str)); if (jr < 0) { - g_warning("Error adding match: %s", g_strerror(jr)); + ws_warning("Error adding match: %s", g_strerror(jr)); goto cleanup; } @@ -250,28 +252,28 @@ static int sdj_start_export(const int start_from_entries, const gboolean start_f sd_journal_set_data_threshold(jnl, 2048); if (start_from_end) { - g_debug("Attempting to seek %d entries from the end", start_from_entries); + ws_debug("Attempting to seek %d entries from the end", start_from_entries); jr = sd_journal_seek_tail(jnl); if (jr < 0) { - g_warning("Error starting at end: %s", g_strerror(jr)); + ws_warning("Error starting at end: %s", g_strerror(jr)); goto cleanup; } jr = sd_journal_previous_skip(jnl, (uint64_t) start_from_entries + 1); if (jr < 0) { - g_warning("Error skipping backward: %s", g_strerror(jr)); + ws_warning("Error skipping backward: %s", g_strerror(jr)); goto cleanup; } } else { - g_debug("Attempting to seek %d entries from the beginning", start_from_entries); + ws_debug("Attempting to seek %d entries from the beginning", start_from_entries); jr = sd_journal_seek_head(jnl); if (jr < 0) { - g_warning("Error starting at beginning: %s", g_strerror(jr)); + ws_warning("Error starting at beginning: %s", g_strerror(jr)); goto cleanup; } if (start_from_entries > 0) { jr = sd_journal_next_skip(jnl, (uint64_t) start_from_entries); if (jr < 0) { - g_warning("Error skipping forward: %s", g_strerror(jr)); + ws_warning("Error skipping forward: %s", g_strerror(jr)); goto cleanup; } } @@ -279,7 +281,7 @@ static int sdj_start_export(const int start_from_entries, const gboolean start_f /* read from channel and write into fp */ if (sdj_dump_entries(jnl, fp) != 0) { - g_warning("Error dumping entries"); + ws_warning("Error dumping entries"); goto cleanup; } @@ -291,7 +293,7 @@ cleanup: } if (err_info) { - g_warning("%s", err_info); + ws_warning("%s", err_info); } g_free(err_info); @@ -308,12 +310,12 @@ static int list_config(char *interface) unsigned inc = 0; if (!interface) { - g_warning("ERROR: No interface specified."); + ws_warning("ERROR: No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, SDJOURNAL_EXTCAP_INTERFACE)) { - g_warning("ERROR: interface must be %s", SDJOURNAL_EXTCAP_INTERFACE); + ws_warning("ERROR: interface must be %s", SDJOURNAL_EXTCAP_INTERFACE); return EXIT_FAILURE; } @@ -350,7 +352,7 @@ int main(int argc, char **argv) */ init_progfile_dir_error = init_progfile_dir(argv[0]); if (init_progfile_dir_error != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", init_progfile_dir_error); g_free(init_progfile_dir_error); } @@ -402,7 +404,7 @@ int main(int argc, char **argv) case OPT_START_FROM: start_from_entries = (int) strtol(optarg, NULL, 10); if (errno == EINVAL) { - g_warning("Invalid entry count: %s", optarg); + ws_warning("Invalid entry count: %s", optarg); goto end; } if (strlen(optarg) > 0 && optarg[0] == '+') { @@ -412,17 +414,17 @@ int main(int argc, char **argv) start_from_end = TRUE; start_from_entries *= -1; } - g_debug("start %d from %s", start_from_entries, start_from_end ? "end" : "beginning"); + ws_debug("start %d from %s", start_from_entries, start_from_end ? "end" : "beginning"); break; case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -443,7 +445,7 @@ int main(int argc, char **argv) if (extcap_conf->capture) { ret = sdj_start_export(start_from_entries, start_from_end, extcap_conf->fifo); } else { - g_debug("You should not come here... maybe some parameter missing?"); + ws_debug("You should not come here... maybe some parameter missing?"); ret = EXIT_FAILURE; } diff --git a/extcap/ssh-base.c b/extcap/ssh-base.c index 98f968f657..37e152a89c 100644 --- a/extcap/ssh-base.c +++ b/extcap/ssh-base.c @@ -22,7 +22,7 @@ static void extcap_log(int priority _U_, const char *function, const char *buffer, void *userdata _U_) { - g_debug("[%s] %s", function, buffer); + ws_debug("[%s] %s", function, buffer); } void add_libssh_info(extcap_parameters * extcap_conf) diff --git a/extcap/sshdump.c b/extcap/sshdump.c index 94bf6d28e5..ae202fb22f 100644 --- a/extcap/sshdump.c +++ b/extcap/sshdump.c @@ -11,6 +11,7 @@ */ #include "config.h" +#define WS_LOG_DOMAIN "sshdump" #include <extcap/extcap-base.h> #include <extcap/ssh-base.h> @@ -20,6 +21,7 @@ #include <wsutil/filesystem.h> #include <wsutil/privileges.h> #include <wsutil/please_report_bug.h> +#include <wsutil/wslog.h> #include <errno.h> #include <string.h> @@ -82,14 +84,14 @@ static int ssh_loop_read(ssh_channel channel, FILE* fp) while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) { nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE, 0); if (nbytes < 0) { - g_warning("Error reading from channel"); + ws_warning("Error reading from channel"); goto end; } if (nbytes == 0) { break; } if (fwrite(buffer, 1, nbytes, fp) != (guint)nbytes) { - g_warning("Error writing to fifo"); + ws_warning("Error writing to fifo"); ret = EXIT_FAILURE; goto end; } @@ -100,18 +102,18 @@ static int ssh_loop_read(ssh_channel channel, FILE* fp) while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) { nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE, 1); if (nbytes < 0) { - g_warning("Error reading from channel"); + ws_warning("Error reading from channel"); goto end; } if (fwrite(buffer, 1, nbytes, stderr) != (guint)nbytes) { - g_warning("Error writing to stderr"); + ws_warning("Error writing to stderr"); break; } } end: if (ssh_channel_send_eof(channel) != SSH_OK) { - g_warning("Error sending EOF in ssh channel"); + ws_warning("Error sending EOF in ssh channel"); ret = EXIT_FAILURE; } return ret; @@ -137,12 +139,12 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_command channel = ssh_channel_new(sshs); if (!channel) { - g_warning("Can't create channel"); + ws_warning("Can't create channel"); return NULL; } if (ssh_channel_open_session(channel) != SSH_OK) { - g_warning("Can't open session"); + ws_warning("Can't open session"); ssh_channel_free(channel); return NULL; } @@ -152,7 +154,7 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_command /* escape parameters to go save with the shell */ if (capture_command && *capture_command) { cmdline = g_strdup(capture_command); - g_debug("Remote capture command has disabled other options"); + ws_debug("Remote capture command has disabled other options"); } else { quoted_iface = iface ? g_shell_quote(iface) : NULL; quoted_filter = g_shell_quote(cfilter ? cfilter : ""); @@ -168,9 +170,9 @@ static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_command quoted_filter); } - g_debug("Running: %s", cmdline); + ws_debug("Running: %s", cmdline); if (ssh_channel_request_exec(channel, cmdline) != SSH_OK) { - g_warning("Can't request exec"); + ws_warning("Can't request exec"); ssh_channel_close(channel); ssh_channel_free(channel); channel = NULL; @@ -197,7 +199,7 @@ static int ssh_open_remote_connection(const ssh_params_t* params, const char* if /* Open or create the output file */ fp = fopen(fifo, "wb"); if (fp == NULL) { - g_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno)); + ws_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno)); return EXIT_FAILURE; } } @@ -205,20 +207,20 @@ static int ssh_open_remote_connection(const ssh_params_t* params, const char* if sshs = create_ssh_connection(params, &err_info); if (!sshs) { - g_warning("Error creating connection."); + ws_warning("Error creating connection."); goto cleanup; } channel = run_ssh_command(sshs, capture_command, use_sudo, noprom, iface, cfilter, count); if (!channel) { - g_warning("Can't run ssh command."); + ws_warning("Can't run ssh command."); goto cleanup; } /* read from channel and write into fp */ if (ssh_loop_read(channel, fp) != EXIT_SUCCESS) { - g_warning("Error in read loop."); + ws_warning("Error in read loop."); ret = EXIT_FAILURE; goto cleanup; } @@ -226,7 +228,7 @@ static int ssh_open_remote_connection(const ssh_params_t* params, const char* if ret = EXIT_SUCCESS; cleanup: if (err_info) - g_warning("%s", err_info); + ws_warning("%s", err_info); g_free(err_info); /* clean up and exit */ @@ -269,12 +271,12 @@ static int list_config(char *interface, unsigned int remote_port) char* ipfilter; if (!interface) { - g_warning("ERROR: No interface specified."); + ws_warning("ERROR: No interface specified."); return EXIT_FAILURE; } if (g_strcmp0(interface, sshdump_extcap_interface)) { - g_warning("ERROR: interface must be %s", sshdump_extcap_interface); + ws_warning("ERROR: interface must be %s", sshdump_extcap_interface); return EXIT_FAILURE; } @@ -373,7 +375,7 @@ int main(int argc, char *argv[]) */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -447,7 +449,7 @@ int main(int argc, char *argv[]) case OPT_REMOTE_PORT: if (!ws_strtou16(optarg, NULL, &ssh_params->port) || ssh_params->port == 0) { - g_warning("Invalid port: %s", optarg); + ws_warning("Invalid port: %s", optarg); goto end; } break; @@ -500,7 +502,7 @@ int main(int argc, char *argv[]) case OPT_REMOTE_COUNT: if (!ws_strtou32(optarg, NULL, &count)) { - g_warning("Invalid value for count: %s", optarg); + ws_warning("Invalid value for count: %s", optarg); goto end; } break; @@ -511,12 +513,12 @@ int main(int argc, char *argv[]) case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -536,9 +538,9 @@ int main(int argc, char *argv[]) err_msg = ws_init_sockets(); if (err_msg != NULL) { - g_warning("ERROR: %s", err_msg); + ws_warning("ERROR: %s", err_msg); g_free(err_msg); - g_warning("%s", please_report_bug()); + ws_warning("%s", please_report_bug()); goto end; } @@ -546,7 +548,7 @@ int main(int argc, char *argv[]) char* filter; if (!ssh_params->host) { - g_warning("Missing parameter: --remote-host"); + ws_warning("Missing parameter: --remote-host"); goto end; } filter = concat_filters(extcap_conf->capture_filter, remote_filter); @@ -555,7 +557,7 @@ int main(int argc, char *argv[]) filter, remote_capture_command, use_sudo, noprom, count, extcap_conf->fifo); g_free(filter); } else { - g_debug("You should not come here... maybe some parameter missing?"); + ws_debug("You should not come here... maybe some parameter missing?"); ret = EXIT_FAILURE; } diff --git a/extcap/udpdump.c b/extcap/udpdump.c index 18b68739c2..ba606dda5c 100644 --- a/extcap/udpdump.c +++ b/extcap/udpdump.c @@ -12,6 +12,7 @@ */ #include "config.h" +#define WS_LOG_DOMAIN "udpdump" #include <extcap/extcap-base.h> @@ -42,6 +43,7 @@ #include <wsutil/privileges.h> #include <wsutil/socket.h> #include <wsutil/please_report_bug.h> +#include <wsutil/wslog.h> #include <cli_main.h> @@ -91,7 +93,7 @@ static int list_config(char *interface) unsigned inc = 0; if (!interface) { - g_warning("No interface specified."); + ws_warning("No interface specified."); return EXIT_FAILURE; } @@ -118,19 +120,19 @@ static int setup_listener(const guint16 port, socket_handle_t* sock) *sock = socket(AF_INET, SOCK_DGRAM, 0); if (*sock == INVALID_SOCKET) { - g_warning("Error opening socket: %s", strerror(errno)); + ws_warning("Error opening socket: %s", strerror(errno)); return EXIT_FAILURE; } optval = 1; if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, (char*)&optval, (socklen_t)sizeof(int)) < 0) { - g_warning("Can't set socket option SO_REUSEADDR: %s", strerror(errno)); + ws_warning("Can't set socket option SO_REUSEADDR: %s", strerror(errno)); goto cleanup_setup_listener; } #ifndef _WIN32 if (setsockopt (*sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, (socklen_t)sizeof(timeout)) < 0) { - g_warning("Can't set socket option SO_RCVTIMEO: %s", strerror(errno)); + ws_warning("Can't set socket option SO_RCVTIMEO: %s", strerror(errno)); goto cleanup_setup_listener; } #endif @@ -141,7 +143,7 @@ static int setup_listener(const guint16 port, socket_handle_t* sock) serveraddr.sin_port = htons(port); if (bind(*sock, (struct sockaddr *)&serveraddr, (socklen_t)sizeof(serveraddr)) < 0) { - g_warning("Error on binding: %s", strerror(errno)); + ws_warning("Error on binding: %s", strerror(errno)); goto cleanup_setup_listener; } @@ -155,7 +157,7 @@ cleanup_setup_listener: static void exit_from_loop(int signo _U_) { - g_warning("Exiting from main loop"); + ws_warning("Exiting from main loop"); run_loop = FALSE; } @@ -171,12 +173,12 @@ static int setup_dumpfile(const char* fifo, FILE** fp) *fp = fopen(fifo, "wb"); if (!(*fp)) { - g_warning("Error creating output file: %s", g_strerror(errno)); + ws_warning("Error creating output file: %s", g_strerror(errno)); return EXIT_FAILURE; } if (!libpcap_write_file_header(*fp, 252, PCAP_SNAPLEN, FALSE, &bytes_written, &err)) { - g_warning("Can't write pcap file header: %s", g_strerror(err)); + ws_warning("Can't write pcap file header: %s", g_strerror(err)); return EXIT_FAILURE; } @@ -279,7 +281,7 @@ static int dump_packet(const char* proto_name, const guint16 listenport, const c if (!libpcap_write_packet(fp, (guint32)(curtime / G_USEC_PER_SEC), (guint32)(curtime % G_USEC_PER_SEC), offset, offset, mbuf, &bytes_written, &err)) { - g_warning("Can't write packet: %s", g_strerror(err)); + ws_warning("Can't write packet: %s", g_strerror(err)); ret = EXIT_FAILURE; } @@ -299,7 +301,7 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto FILE* fp = NULL; if (signal(SIGINT, exit_from_loop) == SIG_ERR) { - g_warning("Can't set signal handler"); + ws_warning("Can't set signal handler"); return; } @@ -312,7 +314,7 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto if (setup_listener(port, &sock) == EXIT_FAILURE) return; - g_debug("Listener running on port %u", port); + ws_debug("Listener running on port %u", port); buf = (char*)g_malloc(PKT_BUF_SIZE); while(run_loop == TRUE) { @@ -333,11 +335,11 @@ static void run_listener(const char* fifo, const guint16 port, const char* proto NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&errmsg, 0, NULL); - g_warning("Error in recvfrom: %S (err=%d)", errmsg, err); + ws_warning("Error in recvfrom: %S (err=%d)", errmsg, err); LocalFree(errmsg); } #else - g_warning("Error in recvfrom: %s (errno=%d)", strerror(errno), errno); + ws_warning("Error in recvfrom: %s (errno=%d)", strerror(errno), errno); #endif run_loop = FALSE; break; @@ -377,7 +379,7 @@ int main(int argc, char *argv[]) */ err_msg = init_progfile_dir(argv[0]); if (err_msg != NULL) { - g_warning("Can't get pathname of directory containing the captype program: %s.", + ws_warning("Can't get pathname of directory containing the captype program: %s.", err_msg); g_free(err_msg); } @@ -424,7 +426,7 @@ int main(int argc, char *argv[]) case OPT_PORT: if (!ws_strtou16(optarg, NULL, &port)) { - g_warning("Invalid port: %s", optarg); + ws_warning("Invalid port: %s", optarg); goto end; } break; @@ -436,12 +438,12 @@ int main(int argc, char *argv[]) case ':': /* missing option argument */ - g_warning("Option '%s' requires an argument", argv[optind - 1]); + ws_warning("Option '%s' requires an argument", argv[optind - 1]); break; default: if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, optarg)) { - g_warning("Invalid option: %s", argv[optind - 1]); + ws_warning("Invalid option: %s", argv[optind - 1]); goto end; } } @@ -450,7 +452,7 @@ int main(int argc, char *argv[]) extcap_cmdline_debug(argv, argc); if (optind != argc) { - g_warning("Unexpected extra option: %s", argv[optind]); + ws_warning("Unexpected extra option: %s", argv[optind]); goto end; } @@ -469,9 +471,9 @@ int main(int argc, char *argv[]) err_msg = ws_init_sockets(); if (err_msg != NULL) { - g_warning("Error: %s", err_msg); + ws_warning("Error: %s", err_msg); g_free(err_msg); - g_warning("%s", please_report_bug()); + ws_warning("%s", please_report_bug()); goto end; } |