X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/8ece0a663f1d163d8468697d6525ef7f6d4f9597..296d466cd6bbf2f7e75e15bb6a01268e88c76ed0:/print-someip.c diff --git a/print-someip.c b/print-someip.c index 5da3851b..d21219ae 100644 --- a/print-someip.c +++ b/print-someip.c @@ -13,14 +13,13 @@ * Original code by Francesco Fondelli (francesco dot fondelli, gmail dot com) */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +/* \summary: Autosar SOME/IP Protocol printer */ + +#include #include "netdissect-stdinc.h" #include "netdissect.h" #include "extract.h" -#include "udp.h" /* * SOMEIP Header (R19-11) @@ -31,16 +30,16 @@ * | Message ID (Service ID/Method ID) | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Length | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Request ID (Client ID/Session ID) | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Protocol Ver | Interface Ver | Message Type | Return Code | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | Payload | - * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ -struct tok message_type_values[] = { +static const struct tok message_type_values[] = { { 0x00, "REQUEST" }, { 0x01, "REQUEST_NO_RETURN" }, { 0x02, "NOTIFICATION" }, @@ -54,7 +53,7 @@ struct tok message_type_values[] = { { 0, NULL } }; -struct tok return_code_values[] = { +static const struct tok return_code_values[] = { { 0x00, "E_OK" }, { 0x01, "E_NOT_OK" }, { 0x02, "E_UNKNOWN_SERVICE" }, @@ -71,10 +70,11 @@ struct tok return_code_values[] = { { 0x0d, "E_E2E" }, { 0x0e, "E_E2E_NOT_AVAILABLE" }, { 0x0f, "E_E2E_NO_NEW_DATA" }, + { 0, NULL } }; void -someip_print(netdissect_options *ndo, const u_char *bp, u_int len) +someip_print(netdissect_options *ndo, const u_char *bp, const u_int len) { uint32_t message_id; uint16_t service_id; @@ -90,10 +90,10 @@ someip_print(netdissect_options *ndo, const u_char *bp, u_int len) uint8_t return_code; ndo->ndo_protocol = "someip"; + nd_print_protocol_caps(ndo); if (len < 16) { - nd_print_trunc(ndo); - return; + goto invalid; } message_id = GET_BE_U_4(bp); @@ -101,33 +101,39 @@ someip_print(netdissect_options *ndo, const u_char *bp, u_int len) event_flag = (message_id & 0x00008000) >> 15; method_or_event_id = message_id & 0x00007FFF; bp += 4; + ND_PRINT(", service %u, %s %u", + service_id, event_flag ? "event" : "method", method_or_event_id); message_len = GET_BE_U_4(bp); bp += 4; + ND_PRINT(", len %u", message_len); request_id = GET_BE_U_4(bp); client_id = request_id >> 16; session_id = request_id & 0x0000FFFF; bp += 4; + ND_PRINT(", client %u, session %u", client_id, session_id); protocol_version = GET_U_1(bp); bp += 1; + ND_PRINT(", pver %u", protocol_version); interface_version = GET_U_1(bp); bp += 1; + ND_PRINT(", iver %u", interface_version); message_type = GET_U_1(bp); bp += 1; + ND_PRINT(", msgtype %s", + tok2str(message_type_values, "Unknown", message_type)); return_code = GET_U_1(bp); bp += 1; - - ND_PRINT("SOMEIP, service %u, %s %u, len %u, client %u, session %u, " - "pver %u, iver %u, msgtype %s, retcode %s\n", - service_id, event_flag ? "event" : "method", method_or_event_id, - message_len, client_id, session_id, protocol_version, - interface_version, - tok2str(message_type_values, "Unknown", message_type), + ND_PRINT(", retcode %s\n", tok2str(return_code_values, "Unknown", return_code)); + return; + +invalid: + nd_print_invalid(ndo); }