diff --git a/app/src/main/jni/common/memtrack.h b/app/src/main/jni/common/memtrack.h index 525e273e..11c348dc 100644 --- a/app/src/main/jni/common/memtrack.h +++ b/app/src/main/jni/common/memtrack.h @@ -93,6 +93,14 @@ static inline void* pd_ndpi_malloc(size_t size) { return _pcapdroid_malloc(size, MEMTRACK_NDPI); } +static inline void* pd_ndpi_calloc(size_t nmemb, size_t size) { + return _pcapdroid_calloc(nmemb, size, MEMTRACK_NDPI); +} + +static inline void* pd_ndpi_realloc(void *ptr, size_t size) { + return _pcapdroid_realloc(ptr, size, MEMTRACK_NDPI); +} + static inline void pd_ndpi_free(void *ptr) { return _pcapdroid_free(ptr, MEMTRACK_NDPI); } diff --git a/app/src/main/jni/core/jni_impl.c b/app/src/main/jni/core/jni_impl.c index d42dd9dd..36b22e07 100644 --- a/app/src/main/jni/core/jni_impl.c +++ b/app/src/main/jni/core/jni_impl.c @@ -591,8 +591,9 @@ Java_com_emanuelef_remote_1capture_CaptureService_runPacketLoop(JNIEnv *env, jcl jobject vpn, jint sdk) { #ifdef PCAPDROID_TRACK_ALLOCS - set_ndpi_malloc(pd_ndpi_malloc); - set_ndpi_free(pd_ndpi_free); + ndpi_set_memory_alloction_functions(pd_ndpi_malloc, pd_ndpi_free, + pd_ndpi_calloc, pd_ndpi_realloc, NULL, NULL, + pd_ndpi_malloc, pd_ndpi_free); #endif init_jni(env); @@ -1079,20 +1080,20 @@ Java_com_emanuelef_remote_1capture_CaptureService_getL7Protocols(JNIEnv *env, jc if(!ndpi) return(NULL); - NDPI_PROTOCOL_BITMASK protocols; - NDPI_BITMASK_SET_ALL(protocols); - ndpi_set_protocol_detection_bitmask2(ndpi, &protocols); + ndpi_finalize_initialization(ndpi); jobject plist = (*env)->NewObject(env, arrayListClass, arrayListNew); - if((plist == NULL) || jniCheckException(env)) + if((plist == NULL) || jniCheckException(env)) { + ndpi_exit_detection_module(ndpi); return NULL; + } bool success = true; - int num_protos = (int) ndpi_get_ndpi_num_supported_protocols(ndpi); + int num_protos = (int) ndpi_get_num_protocols(ndpi); ndpi_proto_defaults_t* proto_defaults = ndpi_get_proto_defaults(ndpi); - ndpi_protocol_bitmask_struct_t unique_protos; - NDPI_BITMASK_RESET(unique_protos); + struct ndpi_bitmask unique_protos; + ndpi_bitmask_alloc(&unique_protos, num_protos); // NOTE: this does not currently exist as a protocol (see pd_get_proto_name) if(!arraylist_add_string(env, arrayListAdd, plist, "HTTPS")) { @@ -1101,12 +1102,15 @@ Java_com_emanuelef_remote_1capture_CaptureService_getL7Protocols(JNIEnv *env, jc } for(int i=0; i %d -> %d", i, proto_defaults[i].protoId, proto); - if(!NDPI_ISSET(&unique_protos, proto)) { - NDPI_SET(&unique_protos, proto); + if(!ndpi_bitmask_is_set(&unique_protos, proto)) { + ndpi_bitmask_set(&unique_protos, proto); const char *name = ndpi_get_proto_name(ndpi, proto); //log_d("proto: %d %s", proto, name); @@ -1118,6 +1122,7 @@ Java_com_emanuelef_remote_1capture_CaptureService_getL7Protocols(JNIEnv *env, jc } out: + ndpi_bitmask_free(&unique_protos); if(!success) { (*env)->DeleteLocalRef(env, plist); plist = NULL; diff --git a/app/src/main/jni/core/ndpi_config.c b/app/src/main/jni/core/ndpi_config.c index 71afbafd..adfe4c37 100644 --- a/app/src/main/jni/core/ndpi_config.c +++ b/app/src/main/jni/core/ndpi_config.c @@ -20,93 +20,94 @@ #include "ndpi_api.h" #include "ndpi_protocol_ids.h" +#define MASTER_PROTOS_MAX_BITS 1024 + /* ******************************************************* */ // protocols which are not application protocols -void init_ndpi_protocols_bitmask(ndpi_protocol_bitmask_struct_t *b) { - NDPI_ZERO(b); +void init_ndpi_protocols_bitmask(struct ndpi_bitmask *b) { + ndpi_bitmask_alloc(b, MASTER_PROTOS_MAX_BITS); // https://github.com/ntop/nDPI/blob/dev/src/include/ndpi_protocol_ids.h - NDPI_SET(b, NDPI_PROTOCOL_FTP_CONTROL); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_POP); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_SMTP); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_IMAP); - NDPI_SET(b, NDPI_PROTOCOL_DNS); - NDPI_SET(b, NDPI_PROTOCOL_IPP); - NDPI_SET(b, NDPI_PROTOCOL_HTTP); - NDPI_SET(b, NDPI_PROTOCOL_MDNS); - NDPI_SET(b, NDPI_PROTOCOL_NTP); - NDPI_SET(b, NDPI_PROTOCOL_NETBIOS); - NDPI_SET(b, NDPI_PROTOCOL_NFS); - NDPI_SET(b, NDPI_PROTOCOL_SSDP); - NDPI_SET(b, NDPI_PROTOCOL_SNMP); - NDPI_SET(b, NDPI_PROTOCOL_XDMCP); - NDPI_SET(b, NDPI_PROTOCOL_SMBV1); - NDPI_SET(b, NDPI_PROTOCOL_SYSLOG); - NDPI_SET(b, NDPI_PROTOCOL_DHCP); - NDPI_SET(b, NDPI_PROTOCOL_POSTGRES); - NDPI_SET(b, NDPI_PROTOCOL_MYSQL); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_POPS); - NDPI_SET(b, NDPI_PROTOCOL_TAILSCALE); - NDPI_SET(b, NDPI_PROTOCOL_COAP); - NDPI_SET(b, NDPI_PROTOCOL_VMWARE); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_SMTPS); - NDPI_SET(b, NDPI_PROTOCOL_DTLS); - NDPI_SET(b, NDPI_PROTOCOL_UBNTAC2); - NDPI_SET(b, NDPI_PROTOCOL_BITTORRENT); - NDPI_SET(b, NDPI_PROTOCOL_SMBV23); - NDPI_SET(b, NDPI_PROTOCOL_RTSP); - NDPI_SET(b, NDPI_PROTOCOL_MAIL_IMAPS); - NDPI_SET(b, NDPI_PROTOCOL_ICECAST); - NDPI_SET(b, NDPI_PROTOCOL_IRC); - NDPI_SET(b, NDPI_PROTOCOL_NATS); - NDPI_SET(b, NDPI_PROTOCOL_TELNET); - NDPI_SET(b, NDPI_PROTOCOL_STUN); - NDPI_SET(b, NDPI_PROTOCOL_IPSEC); - NDPI_SET(b, NDPI_PROTOCOL_IP_GRE); - NDPI_SET(b, NDPI_PROTOCOL_RTP); - NDPI_SET(b, NDPI_PROTOCOL_RDP); - NDPI_SET(b, NDPI_PROTOCOL_VNC); - NDPI_SET(b, NDPI_PROTOCOL_TLS); - NDPI_SET(b, NDPI_PROTOCOL_SSH); - NDPI_SET(b, NDPI_PROTOCOL_TFTP); - NDPI_SET(b, NDPI_PROTOCOL_SIP); - NDPI_SET(b, NDPI_PROTOCOL_DHCPV6); - NDPI_SET(b, NDPI_PROTOCOL_KERBEROS); - NDPI_SET(b, NDPI_PROTOCOL_PPTP); - NDPI_SET(b, NDPI_PROTOCOL_NETFLOW); - NDPI_SET(b, NDPI_PROTOCOL_SFLOW); - NDPI_SET(b, NDPI_PROTOCOL_HTTP_CONNECT); - NDPI_SET(b, NDPI_PROTOCOL_HTTP_PROXY); - NDPI_SET(b, NDPI_PROTOCOL_RADIUS); - NDPI_SET(b, NDPI_PROTOCOL_TEAMVIEWER); - NDPI_SET(b, NDPI_PROTOCOL_OPENVPN); - NDPI_SET(b, NDPI_PROTOCOL_CISCOVPN); - NDPI_SET(b, NDPI_PROTOCOL_TOR); - NDPI_SET(b, NDPI_PROTOCOL_RTCP); - NDPI_SET(b, NDPI_PROTOCOL_SOCKS); - NDPI_SET(b, NDPI_PROTOCOL_RTMP); - NDPI_SET(b, NDPI_PROTOCOL_FTP_DATA); - NDPI_SET(b, NDPI_PROTOCOL_ZMQ); - NDPI_SET(b, NDPI_PROTOCOL_RESP); - NDPI_SET(b, NDPI_PROTOCOL_QUIC); - NDPI_SET(b, NDPI_PROTOCOL_WIREGUARD); - NDPI_SET(b, NDPI_PROTOCOL_DNSCRYPT); - NDPI_SET(b, NDPI_PROTOCOL_TINC); - NDPI_SET(b, NDPI_PROTOCOL_DNSCRYPT); - NDPI_SET(b, NDPI_PROTOCOL_MQTT); - NDPI_SET(b, NDPI_PROTOCOL_RX); - NDPI_SET(b, NDPI_PROTOCOL_GIT); - NDPI_SET(b, NDPI_PROTOCOL_DRDA); - NDPI_SET(b, NDPI_PROTOCOL_VALVE_SDR); - NDPI_SET(b, NDPI_PROTOCOL_WEBSOCKET); - NDPI_SET(b, NDPI_PROTOCOL_Z3950); - NDPI_SET(b, NDPI_PROTOCOL_MPEGDASH); - NDPI_SET(b, NDPI_PROTOCOL_FTPS); - NDPI_SET(b, NDPI_PROTOCOL_NATPMP); - NDPI_SET(b, NDPI_PROTOCOL_SRTP); - NDPI_SET(b, NDPI_PROTOCOL_HTTP2); - NDPI_SET(b, NDPI_PROTOCOL_PROTOBUF); - NDPI_SET(b, NDPI_PROTOCOL_RTPS); - NDPI_SET(b, NDPI_PROTOCOL_TRDP); -} \ No newline at end of file + ndpi_bitmask_set(b, NDPI_PROTOCOL_FTP_CONTROL); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_POP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_SMTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_IMAP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DNS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_IPP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_HTTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MDNS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NETBIOS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NFS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SSDP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SNMP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_XDMCP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SMBV1); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SYSLOG); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DHCP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_POSTGRES); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MYSQL); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_POPS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TAILSCALE); + ndpi_bitmask_set(b, NDPI_PROTOCOL_COAP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_VMWARE); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_SMTPS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DTLS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_UBNTAC2); + ndpi_bitmask_set(b, NDPI_PROTOCOL_BITTORRENT); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SMBV23); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RTSP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MAIL_IMAPS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_ICECAST); + ndpi_bitmask_set(b, NDPI_PROTOCOL_IRC); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NATS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TELNET); + ndpi_bitmask_set(b, NDPI_PROTOCOL_STUN); + ndpi_bitmask_set(b, NDPI_PROTOCOL_IPSEC); + ndpi_bitmask_set(b, NDPI_PROTOCOL_IP_GRE); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RDP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_VNC); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TLS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SSH); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TFTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SIP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DHCPV6); + ndpi_bitmask_set(b, NDPI_PROTOCOL_KERBEROS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_PPTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NETFLOW); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SFLOW); + ndpi_bitmask_set(b, NDPI_PROTOCOL_HTTP_CONNECT); + ndpi_bitmask_set(b, NDPI_PROTOCOL_HTTP_PROXY); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RADIUS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TEAMVIEWER); + ndpi_bitmask_set(b, NDPI_PROTOCOL_OPENVPN); + ndpi_bitmask_set(b, NDPI_PROTOCOL_CISCOVPN); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TOR); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RTCP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SOCKS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RTMP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_FTP_DATA); + ndpi_bitmask_set(b, NDPI_PROTOCOL_ZMQ); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RESP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_QUIC); + ndpi_bitmask_set(b, NDPI_PROTOCOL_WIREGUARD); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DNSCRYPT); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TINC); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MQTT); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RX); + ndpi_bitmask_set(b, NDPI_PROTOCOL_GIT); + ndpi_bitmask_set(b, NDPI_PROTOCOL_DRDA); + ndpi_bitmask_set(b, NDPI_PROTOCOL_VALVE_SDR); + ndpi_bitmask_set(b, NDPI_PROTOCOL_WEBSOCKET); + ndpi_bitmask_set(b, NDPI_PROTOCOL_Z3950); + ndpi_bitmask_set(b, NDPI_PROTOCOL_MPEGDASH); + ndpi_bitmask_set(b, NDPI_PROTOCOL_FTPS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_NATPMP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_SRTP); + ndpi_bitmask_set(b, NDPI_PROTOCOL_HTTP2); + ndpi_bitmask_set(b, NDPI_PROTOCOL_PROTOBUF); + ndpi_bitmask_set(b, NDPI_PROTOCOL_RTPS); + ndpi_bitmask_set(b, NDPI_PROTOCOL_TRDP); +} diff --git a/app/src/main/jni/core/pcapdroid.c b/app/src/main/jni/core/pcapdroid.c index 0b4898c4..24758c3e 100644 --- a/app/src/main/jni/core/pcapdroid.c +++ b/app/src/main/jni/core/pcapdroid.c @@ -47,7 +47,7 @@ char *pd_appver = (char*) ""; char *pd_device = (char*) ""; char *pd_os = (char*) ""; -static ndpi_protocol_bitmask_struct_t masterProtos; +static struct ndpi_bitmask masterProtos; static bool masterProtosInit = false; /* ******************************************************* */ @@ -85,7 +85,7 @@ uint16_t pd_ndpi2proto(ndpi_protocol nproto) { // nDPI will still return a disabled protocol (via the bitmask) if it matches some // metadata for it (e.g. the SNI) - if(!NDPI_ISSET(&masterProtos, l7proto)) + if(!ndpi_bitmask_is_set(&masterProtos, l7proto)) l7proto = NDPI_PROTOCOL_UNKNOWN; //log_d("PROTO: %d/%d -> %d", proto.master_protocol, proto.app_protocol, l7proto); @@ -97,7 +97,7 @@ uint16_t pd_ndpi2proto(ndpi_protocol nproto) { static bool is_encrypted_l7(struct ndpi_detection_module_struct *ndpi_str, uint16_t l7proto) { // The ndpi_is_encrypted_proto API does not work reliably as it mixes master protocols with apps - if(l7proto >= (NDPI_MAX_SUPPORTED_PROTOCOLS + NDPI_MAX_NUM_CUSTOM_PROTOCOLS)) + if(l7proto >= ndpi_get_num_protocols(ndpi_str)) return false; ndpi_proto_defaults_t *proto_defaults = ndpi_get_proto_defaults(ndpi_str); @@ -226,34 +226,37 @@ struct ndpi_detection_module_struct* init_ndpi() { #endif struct ndpi_detection_module_struct *ndpi = ndpi_init_detection_module(NULL); - NDPI_PROTOCOL_BITMASK protocols; - if(!ndpi) + if(!ndpi) { + log_e("ndpi_init_detection_module returned NULL"); return(NULL); + } - // needed by pd_get_proto_name + // nDPI 5.0: all protocols are enabled by default, no need to set a bitmask + +#ifdef FUZZING + // nDPI has a big performance impact on fuzzing. + // Only enable some protocols to extract the metadata for use in + // PCAPdroid, we are not fuzzing nDPI! + ndpi_set_config(ndpi, "all", "enable", "0"); + ndpi_set_config(ndpi, "DNS", "enable", "1"); + ndpi_set_config(ndpi, "HTTP", "enable", "1"); + //ndpi_set_config(ndpi, "TLS", "enable", "1"); +#endif + + int rc = ndpi_finalize_initialization(ndpi); + if(rc != 0) { + log_e("ndpi_finalize_initialization failed: %d", rc); + ndpi_exit_detection_module(ndpi); + return(NULL); + } + + // needed by pd_get_proto_name (must be after finalize) if(!masterProtosInit) { init_ndpi_protocols_bitmask(&masterProtos); masterProtosInit = true; } -#ifndef FUZZING - // enable all the protocols - NDPI_BITMASK_SET_ALL(protocols); -#else - // nDPI has a big performance impact on fuzzing. - // Only enable some protocols to extract the metadata for use in - // PCAPdroid, we are not fuzzing nDPI! - NDPI_BITMASK_RESET(protocols); - NDPI_BITMASK_ADD(protocols, NDPI_PROTOCOL_DNS); - NDPI_BITMASK_ADD(protocols, NDPI_PROTOCOL_HTTP); - //NDPI_BITMASK_ADD(protocols, NDPI_PROTOCOL_TLS); -#endif - - ndpi_set_protocol_detection_bitmask2(ndpi, &protocols); - - ndpi_finalize_initialization(ndpi); - #ifdef FUZZING ndpi_cache = ndpi; #endif @@ -570,9 +573,7 @@ void pd_giveup_dpi(pcapdroid_t *pd, pd_conn_t *data, const zdtun_5tuple_t *tuple return; if(data->l7proto == NDPI_PROTOCOL_UNKNOWN) { - uint8_t proto_guessed; - struct ndpi_proto n_proto = ndpi_detection_giveup(pd->ndpi, data->ndpi_flow, - &proto_guessed); + struct ndpi_proto n_proto = ndpi_detection_giveup(pd->ndpi, data->ndpi_flow); data->l7proto = pd_ndpi2proto(n_proto); data->encrypted_l7 = is_encrypted_l7(pd->ndpi, data->l7proto); } @@ -754,7 +755,7 @@ static void perform_dpi(pcapdroid_t *pd, pkt_context_t *pctx) { process_dns_reply(data, pd, pkt); if(giveup || ((data->l7proto != NDPI_PROTOCOL_UNKNOWN) && - !ndpi_extra_dissection_possible(pd->ndpi, data->ndpi_flow))) + (n_proto.state >= NDPI_STATE_MONITORING))) pd_giveup_dpi(pd, data, &pkt->tuple); // calls process_ndpi_data else process_ndpi_data(pd, &pkt->tuple, data); diff --git a/app/src/main/jni/core/pcapdroid.h b/app/src/main/jni/core/pcapdroid.h index ba829f88..71e6469b 100644 --- a/app/src/main/jni/core/pcapdroid.h +++ b/app/src/main/jni/core/pcapdroid.h @@ -452,7 +452,7 @@ bool getCountryCode(pcapdroid_t *pd, const char *host, char out[3]); #endif // ANDROID // Internals -void init_ndpi_protocols_bitmask(ndpi_protocol_bitmask_struct_t *b); +void init_ndpi_protocols_bitmask(struct ndpi_bitmask *b); void load_ndpi_hosts(struct ndpi_detection_module_struct *ndpi); uint32_t crc32(u_char *buf, size_t len, uint32_t crc); char* get_allocs_summary(); diff --git a/generated/libpcap/config.h b/generated/libpcap/config.h index 1d7609c3..9a5306f4 100644 --- a/generated/libpcap/config.h +++ b/generated/libpcap/config.h @@ -103,9 +103,6 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_LINUX_USBDEVICE_FS_H */ -/* Define to 1 if you have the header file. */ -#define HAVE_LINUX_WIRELESS_H 1 - /* Define to 1 if you have the header file. */ #define HAVE_NETPACKET_PACKET_H 1 @@ -139,7 +136,7 @@ /* Use OpenSSL */ /* #undef HAVE_OPENSSL */ -/* if there's an os_proto.h for this platform, to use additional prototypes */ +/* if there's an os-proto.h for this platform, to use additional prototypes */ /* #undef HAVE_OS_PROTO_H */ /* Define to 1 if you have a POSIX-style `strerror_r' function. */ @@ -257,6 +254,9 @@ /* Define to 1 if you have the 'vsyslog' function. */ #define HAVE_VSYSLOG 1 +/* Define to 1 if you have the header file. */ +/* #undef HAVE_ZONE_H */ + /* Define to 1 if you have the '_wcserror_s' function. */ /* #undef HAVE__WCSERROR_S */ @@ -288,7 +288,7 @@ #define PACKAGE_NAME "pcap" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "pcap 1.10.5" +#define PACKAGE_STRING "pcap 1.10.6" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "pcap" @@ -297,7 +297,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.10.5" +#define PACKAGE_VERSION "1.10.6" /* target host supports Bluetooth sniffing */ /* #undef PCAP_SUPPORT_BT */ diff --git a/generated/libpcap/grammar.c b/generated/libpcap/grammar.c index d91f8d7d..83d08158 100644 --- a/generated/libpcap/grammar.c +++ b/generated/libpcap/grammar.c @@ -107,19 +107,6 @@ #include -#ifndef _WIN32 -#include -#include - -#if __STDC__ -struct mbuf; -struct rtentry; -#endif - -#include -#include -#endif /* _WIN32 */ - #include #include "diag-control.h" @@ -382,7 +369,7 @@ pfaction_to_num(compiler_state_t *cstate, const char *action) DIAG_OFF_BISON_BYACC -#line 386 "grammar.c" +#line 373 "grammar.c" # ifndef YY_CAST # ifdef __cplusplus @@ -995,29 +982,29 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 431, 431, 443, 445, 447, 448, 449, 450, 451, - 453, 455, 457, 458, 460, 462, 463, 482, 501, 520, - 545, 570, 571, 572, 574, 576, 578, 579, 580, 582, - 584, 586, 587, 589, 590, 591, 592, 593, 601, 603, - 604, 605, 606, 608, 610, 611, 612, 613, 614, 615, - 618, 619, 622, 623, 624, 625, 626, 627, 628, 629, - 630, 631, 632, 633, 636, 637, 638, 639, 642, 644, - 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, - 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, - 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, - 675, 676, 677, 678, 679, 680, 681, 682, 684, 685, - 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, - 696, 697, 698, 699, 700, 701, 702, 703, 706, 707, - 708, 709, 710, 711, 714, 719, 722, 726, 729, 735, - 744, 750, 773, 790, 791, 815, 818, 819, 835, 836, - 839, 842, 843, 844, 846, 847, 848, 850, 851, 853, - 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, - 864, 865, 866, 867, 869, 870, 871, 872, 873, 875, - 876, 878, 879, 880, 881, 882, 883, 884, 886, 887, - 888, 889, 892, 893, 895, 896, 897, 898, 900, 907, - 908, 911, 912, 913, 914, 915, 916, 919, 920, 921, - 922, 923, 924, 925, 926, 928, 929, 930, 931, 933, - 946, 947 + 0, 418, 418, 430, 432, 434, 435, 436, 437, 438, + 440, 442, 444, 445, 447, 449, 450, 469, 488, 507, + 532, 557, 558, 559, 561, 563, 565, 566, 567, 569, + 571, 573, 574, 576, 577, 578, 579, 580, 588, 590, + 591, 592, 593, 595, 597, 598, 599, 600, 601, 602, + 605, 606, 609, 610, 611, 612, 613, 614, 615, 616, + 617, 618, 619, 620, 623, 624, 625, 626, 629, 631, + 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, + 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, + 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, + 662, 663, 664, 665, 666, 667, 668, 669, 671, 672, + 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, + 683, 684, 685, 686, 687, 688, 689, 690, 693, 694, + 695, 696, 697, 698, 701, 706, 709, 713, 716, 722, + 731, 737, 760, 777, 778, 802, 805, 806, 822, 823, + 826, 829, 830, 831, 833, 834, 835, 837, 838, 840, + 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, + 851, 852, 853, 854, 856, 857, 858, 859, 860, 862, + 863, 865, 866, 867, 868, 869, 870, 871, 873, 874, + 875, 876, 879, 880, 882, 883, 884, 885, 887, 894, + 895, 898, 899, 900, 901, 902, 903, 906, 907, 908, + 909, 910, 911, 912, 913, 915, 916, 917, 918, 920, + 933, 934 }; #endif @@ -1906,7 +1893,7 @@ yyreduce: switch (yyn) { case 2: /* prog: null expr */ -#line 432 "grammar.y" +#line 419 "grammar.y" { /* * I'm not sure we have a reason to use yynerrs, but it's @@ -1918,72 +1905,72 @@ yyreduce: (void) yynerrs; CHECK_INT_VAL(finish_parse(cstate, (yyvsp[0].blk).b)); } -#line 1922 "grammar.c" +#line 1909 "grammar.c" break; case 4: /* null: %empty */ -#line 445 "grammar.y" +#line 432 "grammar.y" { (yyval.blk).q = qerr; } -#line 1928 "grammar.c" +#line 1915 "grammar.c" break; case 6: /* expr: expr and term */ -#line 448 "grammar.y" +#line 435 "grammar.y" { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 1934 "grammar.c" +#line 1921 "grammar.c" break; case 7: /* expr: expr and id */ -#line 449 "grammar.y" +#line 436 "grammar.y" { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 1940 "grammar.c" +#line 1927 "grammar.c" break; case 8: /* expr: expr or term */ -#line 450 "grammar.y" +#line 437 "grammar.y" { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 1946 "grammar.c" +#line 1933 "grammar.c" break; case 9: /* expr: expr or id */ -#line 451 "grammar.y" +#line 438 "grammar.y" { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 1952 "grammar.c" +#line 1939 "grammar.c" break; case 10: /* and: AND */ -#line 453 "grammar.y" +#line 440 "grammar.y" { (yyval.blk) = (yyvsp[-1].blk); } -#line 1958 "grammar.c" +#line 1945 "grammar.c" break; case 11: /* or: OR */ -#line 455 "grammar.y" +#line 442 "grammar.y" + { (yyval.blk) = (yyvsp[-1].blk); } +#line 1951 "grammar.c" + break; + + case 13: /* id: pnum */ +#line 445 "grammar.y" + { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (yyvsp[0].h), + (yyval.blk).q = (yyvsp[-1].blk).q))); } +#line 1958 "grammar.c" + break; + + case 14: /* id: paren pid ')' */ +#line 447 "grammar.y" { (yyval.blk) = (yyvsp[-1].blk); } #line 1964 "grammar.c" break; - case 13: /* id: pnum */ -#line 458 "grammar.y" - { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (yyvsp[0].h), - (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 1971 "grammar.c" - break; - - case 14: /* id: paren pid ')' */ -#line 460 "grammar.y" - { (yyval.blk) = (yyvsp[-1].blk); } -#line 1977 "grammar.c" - break; - case 15: /* nid: ID */ -#line 462 "grammar.y" +#line 449 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_scode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 1983 "grammar.c" +#line 1970 "grammar.c" break; case 16: /* nid: HID '/' NUM */ -#line 463 "grammar.y" +#line 450 "grammar.y" { CHECK_PTR_VAL((yyvsp[-2].s)); /* Check whether HID/NUM is being used when appropriate */ @@ -2003,11 +1990,11 @@ yyreduce: } CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), NULL, (yyvsp[0].h), (yyval.blk).q))); } -#line 2007 "grammar.c" +#line 1994 "grammar.c" break; case 17: /* nid: HID NETMASK HID */ -#line 482 "grammar.y" +#line 469 "grammar.y" { CHECK_PTR_VAL((yyvsp[-2].s)); /* Check whether HID mask HID is being used when appropriate */ @@ -2027,11 +2014,11 @@ yyreduce: } CHECK_PTR_VAL(((yyval.blk).b = gen_mcode(cstate, (yyvsp[-2].s), (yyvsp[0].s), 0, (yyval.blk).q))); } -#line 2031 "grammar.c" +#line 2018 "grammar.c" break; case 18: /* nid: HID */ -#line 501 "grammar.y" +#line 488 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); /* Check whether HID is being used when appropriate */ @@ -2051,11 +2038,11 @@ yyreduce: } CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, (yyvsp[0].s), 0, (yyval.blk).q))); } -#line 2055 "grammar.c" +#line 2042 "grammar.c" break; case 19: /* nid: HID6 '/' NUM */ -#line 520 "grammar.y" +#line 507 "grammar.y" { CHECK_PTR_VAL((yyvsp[-2].s)); #ifdef INET6 @@ -2081,11 +2068,11 @@ yyreduce: YYABORT; #endif /*INET6*/ } -#line 2085 "grammar.c" +#line 2072 "grammar.c" break; case 20: /* nid: HID6 */ -#line 545 "grammar.y" +#line 532 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); #ifdef INET6 @@ -2111,90 +2098,90 @@ yyreduce: YYABORT; #endif /*INET6*/ } -#line 2115 "grammar.c" +#line 2102 "grammar.c" break; case 21: /* nid: EID */ -#line 570 "grammar.y" +#line 557 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_ecode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2121 "grammar.c" +#line 2108 "grammar.c" break; case 22: /* nid: AID */ -#line 571 "grammar.y" +#line 558 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.blk).b = gen_acode(cstate, (yyvsp[0].s), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2127 "grammar.c" +#line 2114 "grammar.c" break; case 23: /* nid: not id */ -#line 572 "grammar.y" +#line 559 "grammar.y" { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2133 "grammar.c" +#line 2120 "grammar.c" break; case 24: /* not: '!' */ -#line 574 "grammar.y" +#line 561 "grammar.y" { (yyval.blk) = (yyvsp[-1].blk); } -#line 2139 "grammar.c" +#line 2126 "grammar.c" break; case 25: /* paren: '(' */ -#line 576 "grammar.y" +#line 563 "grammar.y" { (yyval.blk) = (yyvsp[-1].blk); } -#line 2145 "grammar.c" +#line 2132 "grammar.c" break; case 27: /* pid: qid and id */ -#line 579 "grammar.y" +#line 566 "grammar.y" { gen_and((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2151 "grammar.c" +#line 2138 "grammar.c" break; case 28: /* pid: qid or id */ -#line 580 "grammar.y" +#line 567 "grammar.y" { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2157 "grammar.c" +#line 2144 "grammar.c" break; case 29: /* qid: pnum */ -#line 582 "grammar.y" +#line 569 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_ncode(cstate, NULL, (yyvsp[0].h), (yyval.blk).q = (yyvsp[-1].blk).q))); } -#line 2164 "grammar.c" +#line 2151 "grammar.c" break; case 32: /* term: not term */ -#line 587 "grammar.y" +#line 574 "grammar.y" { gen_not((yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 2170 "grammar.c" +#line 2157 "grammar.c" break; case 33: /* head: pqual dqual aqual */ -#line 589 "grammar.y" +#line 576 "grammar.y" { QSET((yyval.blk).q, (yyvsp[-2].i), (yyvsp[-1].i), (yyvsp[0].i)); } -#line 2176 "grammar.c" +#line 2163 "grammar.c" break; case 34: /* head: pqual dqual */ -#line 590 "grammar.y" +#line 577 "grammar.y" { QSET((yyval.blk).q, (yyvsp[-1].i), (yyvsp[0].i), Q_DEFAULT); } -#line 2182 "grammar.c" +#line 2169 "grammar.c" break; case 35: /* head: pqual aqual */ -#line 591 "grammar.y" +#line 578 "grammar.y" { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); } -#line 2188 "grammar.c" +#line 2175 "grammar.c" break; case 36: /* head: pqual PROTO */ -#line 592 "grammar.y" +#line 579 "grammar.y" { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTO); } -#line 2194 "grammar.c" +#line 2181 "grammar.c" break; case 37: /* head: pqual PROTOCHAIN */ -#line 593 "grammar.y" +#line 580 "grammar.y" { #ifdef NO_PROTOCHAIN bpf_set_error(cstate, "protochain not supported"); @@ -2203,626 +2190,626 @@ yyreduce: QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, Q_PROTOCHAIN); #endif } -#line 2207 "grammar.c" +#line 2194 "grammar.c" break; case 38: /* head: pqual ndaqual */ -#line 601 "grammar.y" +#line 588 "grammar.y" { QSET((yyval.blk).q, (yyvsp[-1].i), Q_DEFAULT, (yyvsp[0].i)); } -#line 2213 "grammar.c" +#line 2200 "grammar.c" break; case 39: /* rterm: head id */ -#line 603 "grammar.y" +#line 590 "grammar.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 2219 "grammar.c" +#line 2206 "grammar.c" break; case 40: /* rterm: paren expr ')' */ -#line 604 "grammar.y" +#line 591 "grammar.y" { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = (yyvsp[-2].blk).q; } -#line 2225 "grammar.c" +#line 2212 "grammar.c" break; case 41: /* rterm: pname */ -#line 605 "grammar.y" +#line 592 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_proto_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2231 "grammar.c" +#line 2218 "grammar.c" break; case 42: /* rterm: arth relop arth */ -#line 606 "grammar.y" +#line 593 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 0))); (yyval.blk).q = qerr; } -#line 2238 "grammar.c" +#line 2225 "grammar.c" break; case 43: /* rterm: arth irelop arth */ -#line 608 "grammar.y" +#line 595 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_relation(cstate, (yyvsp[-1].i), (yyvsp[-2].a), (yyvsp[0].a), 1))); (yyval.blk).q = qerr; } -#line 2245 "grammar.c" +#line 2232 "grammar.c" break; case 44: /* rterm: other */ -#line 610 "grammar.y" +#line 597 "grammar.y" { (yyval.blk).b = (yyvsp[0].rblk); (yyval.blk).q = qerr; } -#line 2251 "grammar.c" +#line 2238 "grammar.c" break; case 45: /* rterm: atmtype */ -#line 611 "grammar.y" +#line 598 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_atmtype_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2257 "grammar.c" +#line 2244 "grammar.c" break; case 46: /* rterm: atmmultitype */ -#line 612 "grammar.y" +#line 599 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_atmmulti_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2263 "grammar.c" +#line 2250 "grammar.c" break; case 47: /* rterm: atmfield atmvalue */ -#line 613 "grammar.y" +#line 600 "grammar.y" { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; } -#line 2269 "grammar.c" +#line 2256 "grammar.c" break; case 48: /* rterm: mtp2type */ -#line 614 "grammar.y" +#line 601 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp2type_abbrev(cstate, (yyvsp[0].i)))); (yyval.blk).q = qerr; } -#line 2275 "grammar.c" +#line 2262 "grammar.c" break; case 49: /* rterm: mtp3field mtp3value */ -#line 615 "grammar.y" +#line 602 "grammar.y" { (yyval.blk).b = (yyvsp[0].blk).b; (yyval.blk).q = qerr; } -#line 2281 "grammar.c" +#line 2268 "grammar.c" break; case 51: /* pqual: %empty */ -#line 619 "grammar.y" +#line 606 "grammar.y" { (yyval.i) = Q_DEFAULT; } -#line 2287 "grammar.c" +#line 2274 "grammar.c" break; case 52: /* dqual: SRC */ -#line 622 "grammar.y" +#line 609 "grammar.y" { (yyval.i) = Q_SRC; } -#line 2293 "grammar.c" +#line 2280 "grammar.c" break; case 53: /* dqual: DST */ -#line 623 "grammar.y" +#line 610 "grammar.y" { (yyval.i) = Q_DST; } -#line 2299 "grammar.c" +#line 2286 "grammar.c" break; case 54: /* dqual: SRC OR DST */ -#line 624 "grammar.y" +#line 611 "grammar.y" { (yyval.i) = Q_OR; } -#line 2305 "grammar.c" +#line 2292 "grammar.c" break; case 55: /* dqual: DST OR SRC */ -#line 625 "grammar.y" +#line 612 "grammar.y" { (yyval.i) = Q_OR; } -#line 2311 "grammar.c" +#line 2298 "grammar.c" break; case 56: /* dqual: SRC AND DST */ -#line 626 "grammar.y" +#line 613 "grammar.y" { (yyval.i) = Q_AND; } -#line 2317 "grammar.c" +#line 2304 "grammar.c" break; case 57: /* dqual: DST AND SRC */ -#line 627 "grammar.y" +#line 614 "grammar.y" { (yyval.i) = Q_AND; } -#line 2323 "grammar.c" +#line 2310 "grammar.c" break; case 58: /* dqual: ADDR1 */ -#line 628 "grammar.y" +#line 615 "grammar.y" { (yyval.i) = Q_ADDR1; } -#line 2329 "grammar.c" +#line 2316 "grammar.c" break; case 59: /* dqual: ADDR2 */ -#line 629 "grammar.y" +#line 616 "grammar.y" { (yyval.i) = Q_ADDR2; } -#line 2335 "grammar.c" +#line 2322 "grammar.c" break; case 60: /* dqual: ADDR3 */ -#line 630 "grammar.y" +#line 617 "grammar.y" { (yyval.i) = Q_ADDR3; } -#line 2341 "grammar.c" +#line 2328 "grammar.c" break; case 61: /* dqual: ADDR4 */ -#line 631 "grammar.y" +#line 618 "grammar.y" { (yyval.i) = Q_ADDR4; } -#line 2347 "grammar.c" +#line 2334 "grammar.c" break; case 62: /* dqual: RA */ -#line 632 "grammar.y" +#line 619 "grammar.y" { (yyval.i) = Q_RA; } -#line 2353 "grammar.c" +#line 2340 "grammar.c" break; case 63: /* dqual: TA */ -#line 633 "grammar.y" +#line 620 "grammar.y" { (yyval.i) = Q_TA; } -#line 2359 "grammar.c" +#line 2346 "grammar.c" break; case 64: /* aqual: HOST */ -#line 636 "grammar.y" +#line 623 "grammar.y" { (yyval.i) = Q_HOST; } -#line 2365 "grammar.c" +#line 2352 "grammar.c" break; case 65: /* aqual: NET */ -#line 637 "grammar.y" +#line 624 "grammar.y" { (yyval.i) = Q_NET; } -#line 2371 "grammar.c" +#line 2358 "grammar.c" break; case 66: /* aqual: PORT */ -#line 638 "grammar.y" +#line 625 "grammar.y" { (yyval.i) = Q_PORT; } -#line 2377 "grammar.c" +#line 2364 "grammar.c" break; case 67: /* aqual: PORTRANGE */ -#line 639 "grammar.y" +#line 626 "grammar.y" { (yyval.i) = Q_PORTRANGE; } -#line 2383 "grammar.c" +#line 2370 "grammar.c" break; case 68: /* ndaqual: GATEWAY */ -#line 642 "grammar.y" +#line 629 "grammar.y" { (yyval.i) = Q_GATEWAY; } -#line 2389 "grammar.c" +#line 2376 "grammar.c" break; case 69: /* pname: LINK */ -#line 644 "grammar.y" +#line 631 "grammar.y" { (yyval.i) = Q_LINK; } -#line 2395 "grammar.c" +#line 2382 "grammar.c" break; case 70: /* pname: IP */ -#line 645 "grammar.y" +#line 632 "grammar.y" { (yyval.i) = Q_IP; } -#line 2401 "grammar.c" +#line 2388 "grammar.c" break; case 71: /* pname: ARP */ -#line 646 "grammar.y" +#line 633 "grammar.y" { (yyval.i) = Q_ARP; } -#line 2407 "grammar.c" +#line 2394 "grammar.c" break; case 72: /* pname: RARP */ -#line 647 "grammar.y" +#line 634 "grammar.y" { (yyval.i) = Q_RARP; } -#line 2413 "grammar.c" +#line 2400 "grammar.c" break; case 73: /* pname: SCTP */ -#line 648 "grammar.y" +#line 635 "grammar.y" { (yyval.i) = Q_SCTP; } -#line 2419 "grammar.c" +#line 2406 "grammar.c" break; case 74: /* pname: TCP */ -#line 649 "grammar.y" +#line 636 "grammar.y" { (yyval.i) = Q_TCP; } -#line 2425 "grammar.c" +#line 2412 "grammar.c" break; case 75: /* pname: UDP */ -#line 650 "grammar.y" +#line 637 "grammar.y" { (yyval.i) = Q_UDP; } -#line 2431 "grammar.c" +#line 2418 "grammar.c" break; case 76: /* pname: ICMP */ -#line 651 "grammar.y" +#line 638 "grammar.y" { (yyval.i) = Q_ICMP; } -#line 2437 "grammar.c" +#line 2424 "grammar.c" break; case 77: /* pname: IGMP */ -#line 652 "grammar.y" +#line 639 "grammar.y" { (yyval.i) = Q_IGMP; } -#line 2443 "grammar.c" +#line 2430 "grammar.c" break; case 78: /* pname: IGRP */ -#line 653 "grammar.y" +#line 640 "grammar.y" { (yyval.i) = Q_IGRP; } -#line 2449 "grammar.c" +#line 2436 "grammar.c" break; case 79: /* pname: PIM */ -#line 654 "grammar.y" +#line 641 "grammar.y" { (yyval.i) = Q_PIM; } -#line 2455 "grammar.c" +#line 2442 "grammar.c" break; case 80: /* pname: VRRP */ -#line 655 "grammar.y" +#line 642 "grammar.y" { (yyval.i) = Q_VRRP; } -#line 2461 "grammar.c" +#line 2448 "grammar.c" break; case 81: /* pname: CARP */ -#line 656 "grammar.y" +#line 643 "grammar.y" { (yyval.i) = Q_CARP; } -#line 2467 "grammar.c" +#line 2454 "grammar.c" break; case 82: /* pname: ATALK */ -#line 657 "grammar.y" +#line 644 "grammar.y" { (yyval.i) = Q_ATALK; } -#line 2473 "grammar.c" +#line 2460 "grammar.c" break; case 83: /* pname: AARP */ -#line 658 "grammar.y" +#line 645 "grammar.y" { (yyval.i) = Q_AARP; } -#line 2479 "grammar.c" +#line 2466 "grammar.c" break; case 84: /* pname: DECNET */ -#line 659 "grammar.y" +#line 646 "grammar.y" { (yyval.i) = Q_DECNET; } -#line 2485 "grammar.c" +#line 2472 "grammar.c" break; case 85: /* pname: LAT */ -#line 660 "grammar.y" +#line 647 "grammar.y" { (yyval.i) = Q_LAT; } -#line 2491 "grammar.c" +#line 2478 "grammar.c" break; case 86: /* pname: SCA */ -#line 661 "grammar.y" +#line 648 "grammar.y" { (yyval.i) = Q_SCA; } -#line 2497 "grammar.c" +#line 2484 "grammar.c" break; case 87: /* pname: MOPDL */ -#line 662 "grammar.y" +#line 649 "grammar.y" { (yyval.i) = Q_MOPDL; } -#line 2503 "grammar.c" +#line 2490 "grammar.c" break; case 88: /* pname: MOPRC */ -#line 663 "grammar.y" +#line 650 "grammar.y" { (yyval.i) = Q_MOPRC; } -#line 2509 "grammar.c" +#line 2496 "grammar.c" break; case 89: /* pname: IPV6 */ -#line 664 "grammar.y" +#line 651 "grammar.y" { (yyval.i) = Q_IPV6; } -#line 2515 "grammar.c" +#line 2502 "grammar.c" break; case 90: /* pname: ICMPV6 */ -#line 665 "grammar.y" +#line 652 "grammar.y" { (yyval.i) = Q_ICMPV6; } -#line 2521 "grammar.c" +#line 2508 "grammar.c" break; case 91: /* pname: AH */ -#line 666 "grammar.y" +#line 653 "grammar.y" { (yyval.i) = Q_AH; } -#line 2527 "grammar.c" +#line 2514 "grammar.c" break; case 92: /* pname: ESP */ -#line 667 "grammar.y" +#line 654 "grammar.y" { (yyval.i) = Q_ESP; } -#line 2533 "grammar.c" +#line 2520 "grammar.c" break; case 93: /* pname: ISO */ -#line 668 "grammar.y" +#line 655 "grammar.y" { (yyval.i) = Q_ISO; } -#line 2539 "grammar.c" +#line 2526 "grammar.c" break; case 94: /* pname: ESIS */ -#line 669 "grammar.y" +#line 656 "grammar.y" { (yyval.i) = Q_ESIS; } -#line 2545 "grammar.c" +#line 2532 "grammar.c" break; case 95: /* pname: ISIS */ -#line 670 "grammar.y" +#line 657 "grammar.y" { (yyval.i) = Q_ISIS; } -#line 2551 "grammar.c" +#line 2538 "grammar.c" break; case 96: /* pname: L1 */ -#line 671 "grammar.y" +#line 658 "grammar.y" { (yyval.i) = Q_ISIS_L1; } -#line 2557 "grammar.c" +#line 2544 "grammar.c" break; case 97: /* pname: L2 */ -#line 672 "grammar.y" +#line 659 "grammar.y" { (yyval.i) = Q_ISIS_L2; } -#line 2563 "grammar.c" +#line 2550 "grammar.c" break; case 98: /* pname: IIH */ -#line 673 "grammar.y" +#line 660 "grammar.y" { (yyval.i) = Q_ISIS_IIH; } -#line 2569 "grammar.c" +#line 2556 "grammar.c" break; case 99: /* pname: LSP */ -#line 674 "grammar.y" +#line 661 "grammar.y" { (yyval.i) = Q_ISIS_LSP; } -#line 2575 "grammar.c" +#line 2562 "grammar.c" break; case 100: /* pname: SNP */ -#line 675 "grammar.y" +#line 662 "grammar.y" { (yyval.i) = Q_ISIS_SNP; } -#line 2581 "grammar.c" +#line 2568 "grammar.c" break; case 101: /* pname: PSNP */ -#line 676 "grammar.y" +#line 663 "grammar.y" { (yyval.i) = Q_ISIS_PSNP; } -#line 2587 "grammar.c" +#line 2574 "grammar.c" break; case 102: /* pname: CSNP */ -#line 677 "grammar.y" +#line 664 "grammar.y" { (yyval.i) = Q_ISIS_CSNP; } -#line 2593 "grammar.c" +#line 2580 "grammar.c" break; case 103: /* pname: CLNP */ -#line 678 "grammar.y" +#line 665 "grammar.y" { (yyval.i) = Q_CLNP; } -#line 2599 "grammar.c" +#line 2586 "grammar.c" break; case 104: /* pname: STP */ -#line 679 "grammar.y" +#line 666 "grammar.y" { (yyval.i) = Q_STP; } -#line 2605 "grammar.c" +#line 2592 "grammar.c" break; case 105: /* pname: IPX */ -#line 680 "grammar.y" +#line 667 "grammar.y" { (yyval.i) = Q_IPX; } -#line 2611 "grammar.c" +#line 2598 "grammar.c" break; case 106: /* pname: NETBEUI */ -#line 681 "grammar.y" +#line 668 "grammar.y" { (yyval.i) = Q_NETBEUI; } -#line 2617 "grammar.c" +#line 2604 "grammar.c" break; case 107: /* pname: RADIO */ -#line 682 "grammar.y" +#line 669 "grammar.y" { (yyval.i) = Q_RADIO; } -#line 2623 "grammar.c" +#line 2610 "grammar.c" break; case 108: /* other: pqual TK_BROADCAST */ -#line 684 "grammar.y" +#line 671 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_broadcast(cstate, (yyvsp[-1].i)))); } -#line 2629 "grammar.c" +#line 2616 "grammar.c" break; case 109: /* other: pqual TK_MULTICAST */ -#line 685 "grammar.y" +#line 672 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_multicast(cstate, (yyvsp[-1].i)))); } -#line 2635 "grammar.c" +#line 2622 "grammar.c" break; case 110: /* other: LESS NUM */ -#line 686 "grammar.y" +#line 673 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_less(cstate, (yyvsp[0].h)))); } -#line 2641 "grammar.c" +#line 2628 "grammar.c" break; case 111: /* other: GREATER NUM */ -#line 687 "grammar.y" +#line 674 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_greater(cstate, (yyvsp[0].h)))); } -#line 2647 "grammar.c" +#line 2634 "grammar.c" break; case 112: /* other: CBYTE NUM byteop NUM */ -#line 688 "grammar.y" +#line 675 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_byteop(cstate, (yyvsp[-1].i), (yyvsp[-2].h), (yyvsp[0].h)))); } -#line 2653 "grammar.c" +#line 2640 "grammar.c" break; case 113: /* other: INBOUND */ -#line 689 "grammar.y" +#line 676 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 0))); } -#line 2659 "grammar.c" +#line 2646 "grammar.c" break; case 114: /* other: OUTBOUND */ -#line 690 "grammar.y" +#line 677 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_inbound(cstate, 1))); } -#line 2665 "grammar.c" +#line 2652 "grammar.c" break; case 115: /* other: IFINDEX NUM */ -#line 691 "grammar.y" +#line 678 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_ifindex(cstate, (yyvsp[0].h)))); } -#line 2671 "grammar.c" +#line 2658 "grammar.c" break; case 116: /* other: VLAN pnum */ -#line 692 "grammar.y" +#line 679 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, (yyvsp[0].h), 1))); } -#line 2677 "grammar.c" +#line 2664 "grammar.c" break; case 117: /* other: VLAN */ -#line 693 "grammar.y" +#line 680 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_vlan(cstate, 0, 0))); } -#line 2683 "grammar.c" +#line 2670 "grammar.c" break; case 118: /* other: MPLS pnum */ -#line 694 "grammar.y" +#line 681 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, (yyvsp[0].h), 1))); } -#line 2689 "grammar.c" +#line 2676 "grammar.c" break; case 119: /* other: MPLS */ -#line 695 "grammar.y" +#line 682 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_mpls(cstate, 0, 0))); } -#line 2695 "grammar.c" +#line 2682 "grammar.c" break; case 120: /* other: PPPOED */ -#line 696 "grammar.y" +#line 683 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoed(cstate))); } -#line 2701 "grammar.c" +#line 2688 "grammar.c" break; case 121: /* other: PPPOES pnum */ -#line 697 "grammar.y" +#line 684 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, (yyvsp[0].h), 1))); } -#line 2707 "grammar.c" +#line 2694 "grammar.c" break; case 122: /* other: PPPOES */ -#line 698 "grammar.y" +#line 685 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pppoes(cstate, 0, 0))); } -#line 2713 "grammar.c" +#line 2700 "grammar.c" break; case 123: /* other: GENEVE pnum */ -#line 699 "grammar.y" +#line 686 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, (yyvsp[0].h), 1))); } -#line 2719 "grammar.c" +#line 2706 "grammar.c" break; case 124: /* other: GENEVE */ -#line 700 "grammar.y" +#line 687 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_geneve(cstate, 0, 0))); } -#line 2725 "grammar.c" +#line 2712 "grammar.c" break; case 125: /* other: pfvar */ -#line 701 "grammar.y" +#line 688 "grammar.y" { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2731 "grammar.c" +#line 2718 "grammar.c" break; case 126: /* other: pqual p80211 */ -#line 702 "grammar.y" +#line 689 "grammar.y" { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2737 "grammar.c" +#line 2724 "grammar.c" break; case 127: /* other: pllc */ -#line 703 "grammar.y" +#line 690 "grammar.y" { (yyval.rblk) = (yyvsp[0].rblk); } -#line 2743 "grammar.c" +#line 2730 "grammar.c" break; case 128: /* pfvar: PF_IFNAME ID */ -#line 706 "grammar.y" +#line 693 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ifname(cstate, (yyvsp[0].s)))); } -#line 2749 "grammar.c" +#line 2736 "grammar.c" break; case 129: /* pfvar: PF_RSET ID */ -#line 707 "grammar.y" +#line 694 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_PTR_VAL(((yyval.rblk) = gen_pf_ruleset(cstate, (yyvsp[0].s)))); } -#line 2755 "grammar.c" +#line 2742 "grammar.c" break; case 130: /* pfvar: PF_RNR NUM */ -#line 708 "grammar.y" +#line 695 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_rnr(cstate, (yyvsp[0].h)))); } -#line 2761 "grammar.c" +#line 2748 "grammar.c" break; case 131: /* pfvar: PF_SRNR NUM */ -#line 709 "grammar.y" +#line 696 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_srnr(cstate, (yyvsp[0].h)))); } -#line 2767 "grammar.c" +#line 2754 "grammar.c" break; case 132: /* pfvar: PF_REASON reason */ -#line 710 "grammar.y" +#line 697 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_reason(cstate, (yyvsp[0].i)))); } -#line 2773 "grammar.c" +#line 2760 "grammar.c" break; case 133: /* pfvar: PF_ACTION action */ -#line 711 "grammar.y" +#line 698 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_pf_action(cstate, (yyvsp[0].i)))); } -#line 2779 "grammar.c" +#line 2766 "grammar.c" break; case 134: /* p80211: TYPE type SUBTYPE subtype */ -#line 715 "grammar.y" +#line 702 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[-2].i) | (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK))); } -#line 2788 "grammar.c" +#line 2775 "grammar.c" break; case 135: /* p80211: TYPE type */ -#line 719 "grammar.y" +#line 706 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK))); } -#line 2796 "grammar.c" +#line 2783 "grammar.c" break; case 136: /* p80211: SUBTYPE type_subtype */ -#line 722 "grammar.y" +#line 709 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_type(cstate, (yyvsp[0].i), IEEE80211_FC0_TYPE_MASK | IEEE80211_FC0_SUBTYPE_MASK))); } -#line 2805 "grammar.c" +#line 2792 "grammar.c" break; case 137: /* p80211: DIR dir */ -#line 726 "grammar.y" +#line 713 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_p80211_fcdir(cstate, (yyvsp[0].i)))); } -#line 2811 "grammar.c" +#line 2798 "grammar.c" break; case 138: /* type: NUM */ -#line 729 "grammar.y" +#line 716 "grammar.y" { if (((yyvsp[0].h) & (~IEEE80211_FC0_TYPE_MASK)) != 0) { bpf_set_error(cstate, "invalid 802.11 type value 0x%02x", (yyvsp[0].h)); YYABORT; } (yyval.i) = (int)(yyvsp[0].h); } -#line 2822 "grammar.c" +#line 2809 "grammar.c" break; case 139: /* type: ID */ -#line 735 "grammar.y" +#line 722 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); (yyval.i) = str2tok((yyvsp[0].s), ieee80211_types); if ((yyval.i) == -1) { @@ -2830,22 +2817,22 @@ yyreduce: YYABORT; } } -#line 2834 "grammar.c" +#line 2821 "grammar.c" break; case 140: /* subtype: NUM */ -#line 744 "grammar.y" +#line 731 "grammar.y" { if (((yyvsp[0].h) & (~IEEE80211_FC0_SUBTYPE_MASK)) != 0) { bpf_set_error(cstate, "invalid 802.11 subtype value 0x%02x", (yyvsp[0].h)); YYABORT; } (yyval.i) = (int)(yyvsp[0].h); } -#line 2845 "grammar.c" +#line 2832 "grammar.c" break; case 141: /* subtype: ID */ -#line 750 "grammar.y" +#line 737 "grammar.y" { const struct tok *types = NULL; int i; CHECK_PTR_VAL((yyvsp[0].s)); @@ -2867,11 +2854,11 @@ yyreduce: YYABORT; } } -#line 2871 "grammar.c" +#line 2858 "grammar.c" break; case 142: /* type_subtype: ID */ -#line 773 "grammar.y" +#line 760 "grammar.y" { int i; CHECK_PTR_VAL((yyvsp[0].s)); for (i = 0;; i++) { @@ -2887,17 +2874,17 @@ yyreduce: } } } -#line 2891 "grammar.c" +#line 2878 "grammar.c" break; case 143: /* pllc: LLC */ -#line 790 "grammar.y" +#line 777 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_llc(cstate))); } -#line 2897 "grammar.c" +#line 2884 "grammar.c" break; case 144: /* pllc: LLC ID */ -#line 791 "grammar.y" +#line 778 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); if (pcapint_strcasecmp((yyvsp[0].s), "i") == 0) { CHECK_PTR_VAL(((yyval.rblk) = gen_llc_i(cstate))); @@ -2921,23 +2908,23 @@ yyreduce: } } } -#line 2925 "grammar.c" +#line 2912 "grammar.c" break; case 145: /* pllc: LLC PF_RNR */ -#line 815 "grammar.y" +#line 802 "grammar.y" { CHECK_PTR_VAL(((yyval.rblk) = gen_llc_s_subtype(cstate, LLC_RNR))); } -#line 2931 "grammar.c" +#line 2918 "grammar.c" break; case 146: /* dir: NUM */ -#line 818 "grammar.y" +#line 805 "grammar.y" { (yyval.i) = (int)(yyvsp[0].h); } -#line 2937 "grammar.c" +#line 2924 "grammar.c" break; case 147: /* dir: ID */ -#line 819 "grammar.y" +#line 806 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); if (pcapint_strcasecmp((yyvsp[0].s), "nods") == 0) (yyval.i) = IEEE80211_FC1_DIR_NODS; @@ -2952,412 +2939,412 @@ yyreduce: YYABORT; } } -#line 2956 "grammar.c" +#line 2943 "grammar.c" break; case 148: /* reason: NUM */ -#line 835 "grammar.y" +#line 822 "grammar.y" { (yyval.i) = (yyvsp[0].h); } -#line 2962 "grammar.c" +#line 2949 "grammar.c" break; case 149: /* reason: ID */ -#line 836 "grammar.y" +#line 823 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfreason_to_num(cstate, (yyvsp[0].s)))); } -#line 2968 "grammar.c" +#line 2955 "grammar.c" break; case 150: /* action: ID */ -#line 839 "grammar.y" +#line 826 "grammar.y" { CHECK_PTR_VAL((yyvsp[0].s)); CHECK_INT_VAL(((yyval.i) = pfaction_to_num(cstate, (yyvsp[0].s)))); } -#line 2974 "grammar.c" +#line 2961 "grammar.c" break; case 151: /* relop: '>' */ -#line 842 "grammar.y" +#line 829 "grammar.y" { (yyval.i) = BPF_JGT; } -#line 2980 "grammar.c" +#line 2967 "grammar.c" break; case 152: /* relop: GEQ */ -#line 843 "grammar.y" +#line 830 "grammar.y" { (yyval.i) = BPF_JGE; } -#line 2986 "grammar.c" +#line 2973 "grammar.c" break; case 153: /* relop: '=' */ -#line 844 "grammar.y" +#line 831 "grammar.y" { (yyval.i) = BPF_JEQ; } -#line 2992 "grammar.c" +#line 2979 "grammar.c" break; case 154: /* irelop: LEQ */ -#line 846 "grammar.y" +#line 833 "grammar.y" { (yyval.i) = BPF_JGT; } -#line 2998 "grammar.c" +#line 2985 "grammar.c" break; case 155: /* irelop: '<' */ -#line 847 "grammar.y" +#line 834 "grammar.y" { (yyval.i) = BPF_JGE; } -#line 3004 "grammar.c" +#line 2991 "grammar.c" break; case 156: /* irelop: NEQ */ -#line 848 "grammar.y" +#line 835 "grammar.y" { (yyval.i) = BPF_JEQ; } -#line 3010 "grammar.c" +#line 2997 "grammar.c" break; case 157: /* arth: pnum */ -#line 850 "grammar.y" +#line 837 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_loadi(cstate, (yyvsp[0].h)))); } -#line 3016 "grammar.c" +#line 3003 "grammar.c" break; case 159: /* narth: pname '[' arth ']' */ -#line 853 "grammar.y" +#line 840 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-3].i), (yyvsp[-1].a), 1))); } -#line 3022 "grammar.c" +#line 3009 "grammar.c" break; case 160: /* narth: pname '[' arth ':' NUM ']' */ -#line 854 "grammar.y" +#line 841 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_load(cstate, (yyvsp[-5].i), (yyvsp[-3].a), (yyvsp[-1].h)))); } -#line 3028 "grammar.c" +#line 3015 "grammar.c" break; case 161: /* narth: arth '+' arth */ -#line 855 "grammar.y" +#line 842 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_ADD, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3034 "grammar.c" +#line 3021 "grammar.c" break; case 162: /* narth: arth '-' arth */ -#line 856 "grammar.y" +#line 843 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_SUB, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3040 "grammar.c" +#line 3027 "grammar.c" break; case 163: /* narth: arth '*' arth */ -#line 857 "grammar.y" +#line 844 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MUL, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3046 "grammar.c" +#line 3033 "grammar.c" break; case 164: /* narth: arth '/' arth */ -#line 858 "grammar.y" +#line 845 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_DIV, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3052 "grammar.c" +#line 3039 "grammar.c" break; case 165: /* narth: arth '%' arth */ -#line 859 "grammar.y" +#line 846 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_MOD, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3058 "grammar.c" +#line 3045 "grammar.c" break; case 166: /* narth: arth '&' arth */ -#line 860 "grammar.y" +#line 847 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_AND, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3064 "grammar.c" +#line 3051 "grammar.c" break; case 167: /* narth: arth '|' arth */ -#line 861 "grammar.y" +#line 848 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_OR, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3070 "grammar.c" +#line 3057 "grammar.c" break; case 168: /* narth: arth '^' arth */ -#line 862 "grammar.y" +#line 849 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_XOR, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3076 "grammar.c" +#line 3063 "grammar.c" break; case 169: /* narth: arth LSH arth */ -#line 863 "grammar.y" +#line 850 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_LSH, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3082 "grammar.c" +#line 3069 "grammar.c" break; case 170: /* narth: arth RSH arth */ -#line 864 "grammar.y" +#line 851 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_arth(cstate, BPF_RSH, (yyvsp[-2].a), (yyvsp[0].a)))); } -#line 3088 "grammar.c" +#line 3075 "grammar.c" break; case 171: /* narth: '-' arth */ -#line 865 "grammar.y" +#line 852 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_neg(cstate, (yyvsp[0].a)))); } -#line 3094 "grammar.c" +#line 3081 "grammar.c" break; case 172: /* narth: paren narth ')' */ -#line 866 "grammar.y" +#line 853 "grammar.y" { (yyval.a) = (yyvsp[-1].a); } -#line 3100 "grammar.c" +#line 3087 "grammar.c" break; case 173: /* narth: LEN */ -#line 867 "grammar.y" +#line 854 "grammar.y" { CHECK_PTR_VAL(((yyval.a) = gen_loadlen(cstate))); } -#line 3106 "grammar.c" +#line 3093 "grammar.c" break; case 174: /* byteop: '&' */ -#line 869 "grammar.y" +#line 856 "grammar.y" { (yyval.i) = '&'; } -#line 3112 "grammar.c" +#line 3099 "grammar.c" break; case 175: /* byteop: '|' */ -#line 870 "grammar.y" +#line 857 "grammar.y" { (yyval.i) = '|'; } -#line 3118 "grammar.c" +#line 3105 "grammar.c" break; case 176: /* byteop: '<' */ -#line 871 "grammar.y" +#line 858 "grammar.y" { (yyval.i) = '<'; } -#line 3124 "grammar.c" +#line 3111 "grammar.c" break; case 177: /* byteop: '>' */ -#line 872 "grammar.y" +#line 859 "grammar.y" { (yyval.i) = '>'; } -#line 3130 "grammar.c" +#line 3117 "grammar.c" break; case 178: /* byteop: '=' */ -#line 873 "grammar.y" +#line 860 "grammar.y" { (yyval.i) = '='; } -#line 3136 "grammar.c" +#line 3123 "grammar.c" break; case 180: /* pnum: paren pnum ')' */ -#line 876 "grammar.y" +#line 863 "grammar.y" { (yyval.h) = (yyvsp[-1].h); } -#line 3142 "grammar.c" +#line 3129 "grammar.c" break; case 181: /* atmtype: LANE */ -#line 878 "grammar.y" +#line 865 "grammar.y" { (yyval.i) = A_LANE; } -#line 3148 "grammar.c" +#line 3135 "grammar.c" break; case 182: /* atmtype: METAC */ -#line 879 "grammar.y" +#line 866 "grammar.y" { (yyval.i) = A_METAC; } -#line 3154 "grammar.c" +#line 3141 "grammar.c" break; case 183: /* atmtype: BCC */ -#line 880 "grammar.y" +#line 867 "grammar.y" { (yyval.i) = A_BCC; } -#line 3160 "grammar.c" +#line 3147 "grammar.c" break; case 184: /* atmtype: OAMF4EC */ -#line 881 "grammar.y" +#line 868 "grammar.y" { (yyval.i) = A_OAMF4EC; } -#line 3166 "grammar.c" +#line 3153 "grammar.c" break; case 185: /* atmtype: OAMF4SC */ -#line 882 "grammar.y" +#line 869 "grammar.y" { (yyval.i) = A_OAMF4SC; } -#line 3172 "grammar.c" +#line 3159 "grammar.c" break; case 186: /* atmtype: SC */ -#line 883 "grammar.y" +#line 870 "grammar.y" { (yyval.i) = A_SC; } -#line 3178 "grammar.c" +#line 3165 "grammar.c" break; case 187: /* atmtype: ILMIC */ -#line 884 "grammar.y" +#line 871 "grammar.y" { (yyval.i) = A_ILMIC; } -#line 3184 "grammar.c" +#line 3171 "grammar.c" break; case 188: /* atmmultitype: OAM */ -#line 886 "grammar.y" +#line 873 "grammar.y" { (yyval.i) = A_OAM; } -#line 3190 "grammar.c" +#line 3177 "grammar.c" break; case 189: /* atmmultitype: OAMF4 */ -#line 887 "grammar.y" +#line 874 "grammar.y" { (yyval.i) = A_OAMF4; } -#line 3196 "grammar.c" +#line 3183 "grammar.c" break; case 190: /* atmmultitype: CONNECTMSG */ -#line 888 "grammar.y" +#line 875 "grammar.y" { (yyval.i) = A_CONNECTMSG; } -#line 3202 "grammar.c" +#line 3189 "grammar.c" break; case 191: /* atmmultitype: METACONNECT */ -#line 889 "grammar.y" +#line 876 "grammar.y" { (yyval.i) = A_METACONNECT; } -#line 3208 "grammar.c" +#line 3195 "grammar.c" break; case 192: /* atmfield: VPI */ -#line 892 "grammar.y" +#line 879 "grammar.y" { (yyval.blk).atmfieldtype = A_VPI; } -#line 3214 "grammar.c" +#line 3201 "grammar.c" break; case 193: /* atmfield: VCI */ -#line 893 "grammar.y" +#line 880 "grammar.y" { (yyval.blk).atmfieldtype = A_VCI; } -#line 3220 "grammar.c" +#line 3207 "grammar.c" break; case 195: /* atmvalue: relop NUM */ -#line 896 "grammar.y" +#line 883 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (yyvsp[0].h), (yyvsp[-1].i), 0))); } -#line 3226 "grammar.c" +#line 3213 "grammar.c" break; case 196: /* atmvalue: irelop NUM */ -#line 897 "grammar.y" +#line 884 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyvsp[-2].blk).atmfieldtype, (yyvsp[0].h), (yyvsp[-1].i), 1))); } -#line 3232 "grammar.c" +#line 3219 "grammar.c" break; case 197: /* atmvalue: paren atmlistvalue ')' */ -#line 898 "grammar.y" +#line 885 "grammar.y" { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; } -#line 3238 "grammar.c" +#line 3225 "grammar.c" break; case 198: /* atmfieldvalue: NUM */ -#line 900 "grammar.y" +#line 887 "grammar.y" { (yyval.blk).atmfieldtype = (yyvsp[-1].blk).atmfieldtype; if ((yyval.blk).atmfieldtype == A_VPI || (yyval.blk).atmfieldtype == A_VCI) CHECK_PTR_VAL(((yyval.blk).b = gen_atmfield_code(cstate, (yyval.blk).atmfieldtype, (yyvsp[0].h), BPF_JEQ, 0))); } -#line 3249 "grammar.c" +#line 3236 "grammar.c" break; case 200: /* atmlistvalue: atmlistvalue or atmfieldvalue */ -#line 908 "grammar.y" +#line 895 "grammar.y" { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 3255 "grammar.c" +#line 3242 "grammar.c" break; case 201: /* mtp2type: FISU */ -#line 911 "grammar.y" +#line 898 "grammar.y" { (yyval.i) = M_FISU; } -#line 3261 "grammar.c" +#line 3248 "grammar.c" break; case 202: /* mtp2type: LSSU */ -#line 912 "grammar.y" +#line 899 "grammar.y" { (yyval.i) = M_LSSU; } -#line 3267 "grammar.c" +#line 3254 "grammar.c" break; case 203: /* mtp2type: MSU */ -#line 913 "grammar.y" +#line 900 "grammar.y" { (yyval.i) = M_MSU; } -#line 3273 "grammar.c" +#line 3260 "grammar.c" break; case 204: /* mtp2type: HFISU */ -#line 914 "grammar.y" +#line 901 "grammar.y" { (yyval.i) = MH_FISU; } -#line 3279 "grammar.c" +#line 3266 "grammar.c" break; case 205: /* mtp2type: HLSSU */ -#line 915 "grammar.y" +#line 902 "grammar.y" { (yyval.i) = MH_LSSU; } -#line 3285 "grammar.c" +#line 3272 "grammar.c" break; case 206: /* mtp2type: HMSU */ -#line 916 "grammar.y" +#line 903 "grammar.y" { (yyval.i) = MH_MSU; } -#line 3291 "grammar.c" +#line 3278 "grammar.c" break; case 207: /* mtp3field: SIO */ -#line 919 "grammar.y" +#line 906 "grammar.y" { (yyval.blk).mtp3fieldtype = M_SIO; } -#line 3297 "grammar.c" +#line 3284 "grammar.c" break; case 208: /* mtp3field: OPC */ -#line 920 "grammar.y" +#line 907 "grammar.y" { (yyval.blk).mtp3fieldtype = M_OPC; } -#line 3303 "grammar.c" +#line 3290 "grammar.c" break; case 209: /* mtp3field: DPC */ -#line 921 "grammar.y" +#line 908 "grammar.y" { (yyval.blk).mtp3fieldtype = M_DPC; } -#line 3309 "grammar.c" +#line 3296 "grammar.c" break; case 210: /* mtp3field: SLS */ -#line 922 "grammar.y" +#line 909 "grammar.y" { (yyval.blk).mtp3fieldtype = M_SLS; } -#line 3315 "grammar.c" +#line 3302 "grammar.c" break; case 211: /* mtp3field: HSIO */ -#line 923 "grammar.y" +#line 910 "grammar.y" { (yyval.blk).mtp3fieldtype = MH_SIO; } -#line 3321 "grammar.c" +#line 3308 "grammar.c" break; case 212: /* mtp3field: HOPC */ -#line 924 "grammar.y" +#line 911 "grammar.y" { (yyval.blk).mtp3fieldtype = MH_OPC; } -#line 3327 "grammar.c" +#line 3314 "grammar.c" break; case 213: /* mtp3field: HDPC */ -#line 925 "grammar.y" +#line 912 "grammar.y" { (yyval.blk).mtp3fieldtype = MH_DPC; } -#line 3333 "grammar.c" +#line 3320 "grammar.c" break; case 214: /* mtp3field: HSLS */ -#line 926 "grammar.y" +#line 913 "grammar.y" { (yyval.blk).mtp3fieldtype = MH_SLS; } -#line 3339 "grammar.c" +#line 3326 "grammar.c" break; case 216: /* mtp3value: relop NUM */ -#line 929 "grammar.y" +#line 916 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (yyvsp[0].h), (yyvsp[-1].i), 0))); } -#line 3345 "grammar.c" +#line 3332 "grammar.c" break; case 217: /* mtp3value: irelop NUM */ -#line 930 "grammar.y" +#line 917 "grammar.y" { CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyvsp[-2].blk).mtp3fieldtype, (yyvsp[0].h), (yyvsp[-1].i), 1))); } -#line 3351 "grammar.c" +#line 3338 "grammar.c" break; case 218: /* mtp3value: paren mtp3listvalue ')' */ -#line 931 "grammar.y" +#line 918 "grammar.y" { (yyval.blk).b = (yyvsp[-1].blk).b; (yyval.blk).q = qerr; } -#line 3357 "grammar.c" +#line 3344 "grammar.c" break; case 219: /* mtp3fieldvalue: NUM */ -#line 933 "grammar.y" +#line 920 "grammar.y" { (yyval.blk).mtp3fieldtype = (yyvsp[-1].blk).mtp3fieldtype; if ((yyval.blk).mtp3fieldtype == M_SIO || @@ -3370,17 +3357,17 @@ yyreduce: (yyval.blk).mtp3fieldtype == MH_SLS) CHECK_PTR_VAL(((yyval.blk).b = gen_mtp3field_code(cstate, (yyval.blk).mtp3fieldtype, (yyvsp[0].h), BPF_JEQ, 0))); } -#line 3374 "grammar.c" +#line 3361 "grammar.c" break; case 221: /* mtp3listvalue: mtp3listvalue or mtp3fieldvalue */ -#line 947 "grammar.y" +#line 934 "grammar.y" { gen_or((yyvsp[-2].blk).b, (yyvsp[0].blk).b); (yyval.blk) = (yyvsp[0].blk); } -#line 3380 "grammar.c" +#line 3367 "grammar.c" break; -#line 3384 "grammar.c" +#line 3371 "grammar.c" default: break; } @@ -3573,5 +3560,5 @@ yyreturnlab: return yyresult; } -#line 949 "grammar.y" +#line 936 "grammar.y" diff --git a/generated/libpcap/grammar.h b/generated/libpcap/grammar.h index df67a931..f80f49ea 100644 --- a/generated/libpcap/grammar.h +++ b/generated/libpcap/grammar.h @@ -183,7 +183,7 @@ extern int pcap_debug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 357 "grammar.y" +#line 344 "grammar.y" int i; bpf_u_int32 h; diff --git a/generated/libpcap/scanner.c b/generated/libpcap/scanner.c index 0d38690b..1efa2445 100644 --- a/generated/libpcap/scanner.c +++ b/generated/libpcap/scanner.c @@ -3155,28 +3155,6 @@ void pcap_set_column(int, yyscan_t); #ifdef _WIN32 #include #include -/* - * To quote the MSDN page for getaddrinfo() at - * - * https://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx - * - * "Support for getaddrinfo on Windows 2000 and older versions - * The getaddrinfo function was added to the Ws2_32.dll on Windows XP and - * later. To execute an application that uses this function on earlier - * versions of Windows, then you need to include the Ws2tcpip.h and - * Wspiapi.h files. When the Wspiapi.h include file is added, the - * getaddrinfo function is defined to the WspiapiGetAddrInfo inline - * function in the Wspiapi.h file. At runtime, the WspiapiGetAddrInfo - * function is implemented in such a way that if the Ws2_32.dll or the - * Wship6.dll (the file containing getaddrinfo in the IPv6 Technology - * Preview for Windows 2000) does not include getaddrinfo, then a - * version of getaddrinfo is implemented inline based on code in the - * Wspiapi.h header file. This inline code will be used on older Windows - * platforms that do not natively support the getaddrinfo function." - * - * We use getaddrinfo(), so we include Wspiapi.h here. - */ -#include #else /* _WIN32 */ #include /* for "struct sockaddr" in "struct addrinfo" */ #include /* for "struct addrinfo" */ @@ -3203,8 +3181,8 @@ static int stou(const char *, YYSTYPE *, compiler_state_t *); */ DIAG_OFF_FLEX -#line 3206 "scanner.c" -#line 3207 "scanner.c" +#line 3184 "scanner.c" +#line 3185 "scanner.c" #define INITIAL 0 @@ -3474,9 +3452,9 @@ YY_DECL } { -#line 273 "scanner.l" +#line 251 "scanner.l" -#line 3479 "scanner.c" +#line 3457 "scanner.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -3531,634 +3509,634 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 274 "scanner.l" +#line 252 "scanner.l" return DST; YY_BREAK case 2: YY_RULE_SETUP -#line 275 "scanner.l" +#line 253 "scanner.l" return SRC; YY_BREAK case 3: YY_RULE_SETUP -#line 277 "scanner.l" +#line 255 "scanner.l" return LINK; YY_BREAK case 4: YY_RULE_SETUP -#line 278 "scanner.l" +#line 256 "scanner.l" return LINK; YY_BREAK case 5: YY_RULE_SETUP -#line 279 "scanner.l" +#line 257 "scanner.l" return ARP; YY_BREAK case 6: YY_RULE_SETUP -#line 280 "scanner.l" +#line 258 "scanner.l" return RARP; YY_BREAK case 7: YY_RULE_SETUP -#line 281 "scanner.l" +#line 259 "scanner.l" return IP; YY_BREAK case 8: YY_RULE_SETUP -#line 282 "scanner.l" +#line 260 "scanner.l" return SCTP; YY_BREAK case 9: YY_RULE_SETUP -#line 283 "scanner.l" +#line 261 "scanner.l" return TCP; YY_BREAK case 10: YY_RULE_SETUP -#line 284 "scanner.l" +#line 262 "scanner.l" return UDP; YY_BREAK case 11: YY_RULE_SETUP -#line 285 "scanner.l" +#line 263 "scanner.l" return ICMP; YY_BREAK case 12: YY_RULE_SETUP -#line 286 "scanner.l" +#line 264 "scanner.l" return IGMP; YY_BREAK case 13: YY_RULE_SETUP -#line 287 "scanner.l" +#line 265 "scanner.l" return IGRP; YY_BREAK case 14: YY_RULE_SETUP -#line 288 "scanner.l" +#line 266 "scanner.l" return PIM; YY_BREAK case 15: YY_RULE_SETUP -#line 289 "scanner.l" +#line 267 "scanner.l" return VRRP; YY_BREAK case 16: YY_RULE_SETUP -#line 290 "scanner.l" +#line 268 "scanner.l" return CARP; YY_BREAK case 17: YY_RULE_SETUP -#line 291 "scanner.l" +#line 269 "scanner.l" return RADIO; YY_BREAK case 18: YY_RULE_SETUP -#line 293 "scanner.l" +#line 271 "scanner.l" return IPV6; YY_BREAK case 19: YY_RULE_SETUP -#line 294 "scanner.l" +#line 272 "scanner.l" return ICMPV6; YY_BREAK case 20: YY_RULE_SETUP -#line 295 "scanner.l" +#line 273 "scanner.l" return AH; YY_BREAK case 21: YY_RULE_SETUP -#line 296 "scanner.l" +#line 274 "scanner.l" return ESP; YY_BREAK case 22: YY_RULE_SETUP -#line 298 "scanner.l" +#line 276 "scanner.l" return ATALK; YY_BREAK case 23: YY_RULE_SETUP -#line 299 "scanner.l" +#line 277 "scanner.l" return AARP; YY_BREAK case 24: YY_RULE_SETUP -#line 300 "scanner.l" +#line 278 "scanner.l" return DECNET; YY_BREAK case 25: YY_RULE_SETUP -#line 301 "scanner.l" +#line 279 "scanner.l" return LAT; YY_BREAK case 26: YY_RULE_SETUP -#line 302 "scanner.l" +#line 280 "scanner.l" return SCA; YY_BREAK case 27: YY_RULE_SETUP -#line 303 "scanner.l" +#line 281 "scanner.l" return MOPRC; YY_BREAK case 28: YY_RULE_SETUP -#line 304 "scanner.l" +#line 282 "scanner.l" return MOPDL; YY_BREAK case 29: YY_RULE_SETUP -#line 306 "scanner.l" +#line 284 "scanner.l" return ISO; YY_BREAK case 30: YY_RULE_SETUP -#line 307 "scanner.l" +#line 285 "scanner.l" return ESIS; YY_BREAK case 31: YY_RULE_SETUP -#line 308 "scanner.l" +#line 286 "scanner.l" return ESIS; YY_BREAK case 32: YY_RULE_SETUP -#line 309 "scanner.l" +#line 287 "scanner.l" return ISIS; YY_BREAK case 33: YY_RULE_SETUP -#line 310 "scanner.l" +#line 288 "scanner.l" return ISIS; YY_BREAK case 34: YY_RULE_SETUP -#line 311 "scanner.l" +#line 289 "scanner.l" return L1; YY_BREAK case 35: YY_RULE_SETUP -#line 312 "scanner.l" +#line 290 "scanner.l" return L2; YY_BREAK case 36: YY_RULE_SETUP -#line 313 "scanner.l" +#line 291 "scanner.l" return IIH; YY_BREAK case 37: YY_RULE_SETUP -#line 314 "scanner.l" +#line 292 "scanner.l" return LSP; YY_BREAK case 38: YY_RULE_SETUP -#line 315 "scanner.l" +#line 293 "scanner.l" return SNP; YY_BREAK case 39: YY_RULE_SETUP -#line 316 "scanner.l" +#line 294 "scanner.l" return CSNP; YY_BREAK case 40: YY_RULE_SETUP -#line 317 "scanner.l" +#line 295 "scanner.l" return PSNP; YY_BREAK case 41: YY_RULE_SETUP -#line 319 "scanner.l" +#line 297 "scanner.l" return CLNP; YY_BREAK case 42: YY_RULE_SETUP -#line 321 "scanner.l" +#line 299 "scanner.l" return STP; YY_BREAK case 43: YY_RULE_SETUP -#line 323 "scanner.l" +#line 301 "scanner.l" return IPX; YY_BREAK case 44: YY_RULE_SETUP -#line 325 "scanner.l" +#line 303 "scanner.l" return NETBEUI; YY_BREAK case 45: YY_RULE_SETUP -#line 327 "scanner.l" +#line 305 "scanner.l" return HOST; YY_BREAK case 46: YY_RULE_SETUP -#line 328 "scanner.l" +#line 306 "scanner.l" return NET; YY_BREAK case 47: YY_RULE_SETUP -#line 329 "scanner.l" +#line 307 "scanner.l" return NETMASK; YY_BREAK case 48: YY_RULE_SETUP -#line 330 "scanner.l" +#line 308 "scanner.l" return PORT; YY_BREAK case 49: YY_RULE_SETUP -#line 331 "scanner.l" +#line 309 "scanner.l" return PORTRANGE; YY_BREAK case 50: YY_RULE_SETUP -#line 332 "scanner.l" +#line 310 "scanner.l" return PROTO; YY_BREAK case 51: YY_RULE_SETUP -#line 333 "scanner.l" +#line 311 "scanner.l" return PROTOCHAIN; YY_BREAK case 52: YY_RULE_SETUP -#line 335 "scanner.l" +#line 313 "scanner.l" return GATEWAY; YY_BREAK case 53: YY_RULE_SETUP -#line 337 "scanner.l" +#line 315 "scanner.l" return TYPE; YY_BREAK case 54: YY_RULE_SETUP -#line 338 "scanner.l" +#line 316 "scanner.l" return SUBTYPE; YY_BREAK case 55: YY_RULE_SETUP -#line 339 "scanner.l" +#line 317 "scanner.l" return DIR; YY_BREAK case 56: YY_RULE_SETUP -#line 340 "scanner.l" +#line 318 "scanner.l" return ADDR1; YY_BREAK case 57: YY_RULE_SETUP -#line 341 "scanner.l" +#line 319 "scanner.l" return ADDR2; YY_BREAK case 58: YY_RULE_SETUP -#line 342 "scanner.l" +#line 320 "scanner.l" return ADDR3; YY_BREAK case 59: YY_RULE_SETUP -#line 343 "scanner.l" +#line 321 "scanner.l" return ADDR4; YY_BREAK case 60: YY_RULE_SETUP -#line 344 "scanner.l" +#line 322 "scanner.l" return RA; YY_BREAK case 61: YY_RULE_SETUP -#line 345 "scanner.l" +#line 323 "scanner.l" return TA; YY_BREAK case 62: YY_RULE_SETUP -#line 347 "scanner.l" +#line 325 "scanner.l" return LESS; YY_BREAK case 63: YY_RULE_SETUP -#line 348 "scanner.l" +#line 326 "scanner.l" return GREATER; YY_BREAK case 64: YY_RULE_SETUP -#line 349 "scanner.l" +#line 327 "scanner.l" return CBYTE; YY_BREAK case 65: YY_RULE_SETUP -#line 350 "scanner.l" +#line 328 "scanner.l" return TK_BROADCAST; YY_BREAK case 66: YY_RULE_SETUP -#line 351 "scanner.l" +#line 329 "scanner.l" return TK_MULTICAST; YY_BREAK case 67: YY_RULE_SETUP -#line 353 "scanner.l" +#line 331 "scanner.l" return AND; YY_BREAK case 68: YY_RULE_SETUP -#line 354 "scanner.l" +#line 332 "scanner.l" return OR; YY_BREAK case 69: YY_RULE_SETUP -#line 355 "scanner.l" +#line 333 "scanner.l" return '!'; YY_BREAK case 70: YY_RULE_SETUP -#line 357 "scanner.l" +#line 335 "scanner.l" return LEN; YY_BREAK case 71: YY_RULE_SETUP -#line 358 "scanner.l" +#line 336 "scanner.l" return INBOUND; YY_BREAK case 72: YY_RULE_SETUP -#line 359 "scanner.l" +#line 337 "scanner.l" return OUTBOUND; YY_BREAK case 73: YY_RULE_SETUP -#line 361 "scanner.l" +#line 339 "scanner.l" return IFINDEX; YY_BREAK case 74: YY_RULE_SETUP -#line 363 "scanner.l" +#line 341 "scanner.l" return VLAN; YY_BREAK case 75: YY_RULE_SETUP -#line 364 "scanner.l" +#line 342 "scanner.l" return MPLS; YY_BREAK case 76: YY_RULE_SETUP -#line 365 "scanner.l" +#line 343 "scanner.l" return PPPOED; YY_BREAK case 77: YY_RULE_SETUP -#line 366 "scanner.l" +#line 344 "scanner.l" return PPPOES; YY_BREAK case 78: YY_RULE_SETUP -#line 367 "scanner.l" +#line 345 "scanner.l" return GENEVE; YY_BREAK case 79: YY_RULE_SETUP -#line 369 "scanner.l" +#line 347 "scanner.l" return LANE; YY_BREAK case 80: YY_RULE_SETUP -#line 370 "scanner.l" +#line 348 "scanner.l" return LLC; YY_BREAK case 81: YY_RULE_SETUP -#line 371 "scanner.l" +#line 349 "scanner.l" return METAC; YY_BREAK case 82: YY_RULE_SETUP -#line 372 "scanner.l" +#line 350 "scanner.l" return BCC; YY_BREAK case 83: YY_RULE_SETUP -#line 373 "scanner.l" +#line 351 "scanner.l" return OAM; YY_BREAK case 84: YY_RULE_SETUP -#line 374 "scanner.l" +#line 352 "scanner.l" return OAMF4; YY_BREAK case 85: YY_RULE_SETUP -#line 375 "scanner.l" +#line 353 "scanner.l" return OAMF4EC; YY_BREAK case 86: YY_RULE_SETUP -#line 376 "scanner.l" +#line 354 "scanner.l" return OAMF4SC; YY_BREAK case 87: YY_RULE_SETUP -#line 377 "scanner.l" +#line 355 "scanner.l" return SC; YY_BREAK case 88: YY_RULE_SETUP -#line 378 "scanner.l" +#line 356 "scanner.l" return ILMIC; YY_BREAK case 89: YY_RULE_SETUP -#line 379 "scanner.l" +#line 357 "scanner.l" return VPI; YY_BREAK case 90: YY_RULE_SETUP -#line 380 "scanner.l" +#line 358 "scanner.l" return VCI; YY_BREAK case 91: YY_RULE_SETUP -#line 381 "scanner.l" +#line 359 "scanner.l" return CONNECTMSG; YY_BREAK case 92: YY_RULE_SETUP -#line 382 "scanner.l" +#line 360 "scanner.l" return METACONNECT; YY_BREAK case 93: YY_RULE_SETUP -#line 384 "scanner.l" +#line 362 "scanner.l" return PF_IFNAME; YY_BREAK case 94: YY_RULE_SETUP -#line 385 "scanner.l" +#line 363 "scanner.l" return PF_RSET; YY_BREAK case 95: YY_RULE_SETUP -#line 386 "scanner.l" +#line 364 "scanner.l" return PF_RNR; YY_BREAK case 96: YY_RULE_SETUP -#line 387 "scanner.l" +#line 365 "scanner.l" return PF_SRNR; YY_BREAK case 97: YY_RULE_SETUP -#line 388 "scanner.l" +#line 366 "scanner.l" return PF_REASON; YY_BREAK case 98: YY_RULE_SETUP -#line 389 "scanner.l" +#line 367 "scanner.l" return PF_ACTION; YY_BREAK case 99: YY_RULE_SETUP -#line 391 "scanner.l" +#line 369 "scanner.l" return FISU; YY_BREAK case 100: YY_RULE_SETUP -#line 392 "scanner.l" +#line 370 "scanner.l" return LSSU; YY_BREAK case 101: YY_RULE_SETUP -#line 393 "scanner.l" +#line 371 "scanner.l" return LSSU; YY_BREAK case 102: YY_RULE_SETUP -#line 394 "scanner.l" +#line 372 "scanner.l" return MSU; YY_BREAK case 103: YY_RULE_SETUP -#line 395 "scanner.l" +#line 373 "scanner.l" return HFISU; YY_BREAK case 104: YY_RULE_SETUP -#line 396 "scanner.l" +#line 374 "scanner.l" return HLSSU; YY_BREAK case 105: YY_RULE_SETUP -#line 397 "scanner.l" +#line 375 "scanner.l" return HMSU; YY_BREAK case 106: YY_RULE_SETUP -#line 398 "scanner.l" +#line 376 "scanner.l" return SIO; YY_BREAK case 107: YY_RULE_SETUP -#line 399 "scanner.l" +#line 377 "scanner.l" return OPC; YY_BREAK case 108: YY_RULE_SETUP -#line 400 "scanner.l" +#line 378 "scanner.l" return DPC; YY_BREAK case 109: YY_RULE_SETUP -#line 401 "scanner.l" +#line 379 "scanner.l" return SLS; YY_BREAK case 110: YY_RULE_SETUP -#line 402 "scanner.l" +#line 380 "scanner.l" return HSIO; YY_BREAK case 111: YY_RULE_SETUP -#line 403 "scanner.l" +#line 381 "scanner.l" return HOPC; YY_BREAK case 112: YY_RULE_SETUP -#line 404 "scanner.l" +#line 382 "scanner.l" return HDPC; YY_BREAK case 113: YY_RULE_SETUP -#line 405 "scanner.l" +#line 383 "scanner.l" return HSLS; YY_BREAK case 114: /* rule 114 can match eol */ YY_RULE_SETUP -#line 407 "scanner.l" +#line 385 "scanner.l" ; YY_BREAK case 115: YY_RULE_SETUP -#line 408 "scanner.l" +#line 386 "scanner.l" return yytext[0]; YY_BREAK case 116: YY_RULE_SETUP -#line 409 "scanner.l" +#line 387 "scanner.l" return GEQ; YY_BREAK case 117: YY_RULE_SETUP -#line 410 "scanner.l" +#line 388 "scanner.l" return LEQ; YY_BREAK case 118: YY_RULE_SETUP -#line 411 "scanner.l" +#line 389 "scanner.l" return NEQ; YY_BREAK case 119: YY_RULE_SETUP -#line 412 "scanner.l" +#line 390 "scanner.l" return '='; YY_BREAK case 120: YY_RULE_SETUP -#line 413 "scanner.l" +#line 391 "scanner.l" return LSH; YY_BREAK case 121: YY_RULE_SETUP -#line 414 "scanner.l" +#line 392 "scanner.l" return RSH; YY_BREAK case 122: YY_RULE_SETUP -#line 415 "scanner.l" +#line 393 "scanner.l" { yylval->s = sdup(yyextra, yytext); return AID; } YY_BREAK case 123: YY_RULE_SETUP -#line 416 "scanner.l" +#line 394 "scanner.l" { yylval->s = sdup(yyextra, yytext); return EID; } YY_BREAK case 124: YY_RULE_SETUP -#line 417 "scanner.l" +#line 395 "scanner.l" { return stou(yytext, yylval, yyextra); } YY_BREAK case 125: YY_RULE_SETUP -#line 418 "scanner.l" +#line 396 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return HID; } YY_BREAK case 126: YY_RULE_SETUP -#line 420 "scanner.l" +#line 398 "scanner.l" { #ifdef INET6 struct addrinfo hints, *res; @@ -4181,316 +4159,316 @@ YY_RULE_SETUP YY_BREAK case 127: YY_RULE_SETUP -#line 439 "scanner.l" +#line 417 "scanner.l" { bpf_set_error(yyextra, "bogus ethernet address %s", yytext); yylval->s = NULL; return EID; } YY_BREAK case 128: YY_RULE_SETUP -#line 440 "scanner.l" +#line 418 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 129: YY_RULE_SETUP -#line 441 "scanner.l" +#line 419 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 130: YY_RULE_SETUP -#line 442 "scanner.l" +#line 420 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 131: YY_RULE_SETUP -#line 443 "scanner.l" +#line 421 "scanner.l" { yylval->h = 3; return NUM; } YY_BREAK case 132: YY_RULE_SETUP -#line 444 "scanner.l" +#line 422 "scanner.l" { yylval->h = 4; return NUM; } YY_BREAK case 133: YY_RULE_SETUP -#line 445 "scanner.l" +#line 423 "scanner.l" { yylval->h = 5; return NUM; } YY_BREAK case 134: YY_RULE_SETUP -#line 446 "scanner.l" +#line 424 "scanner.l" { yylval->h = 8; return NUM; } YY_BREAK case 135: YY_RULE_SETUP -#line 447 "scanner.l" +#line 425 "scanner.l" { yylval->h = 9; return NUM; } YY_BREAK case 136: YY_RULE_SETUP -#line 448 "scanner.l" +#line 426 "scanner.l" { yylval->h = 10; return NUM; } YY_BREAK case 137: YY_RULE_SETUP -#line 449 "scanner.l" +#line 427 "scanner.l" { yylval->h = 11; return NUM; } YY_BREAK case 138: YY_RULE_SETUP -#line 450 "scanner.l" +#line 428 "scanner.l" { yylval->h = 12; return NUM; } YY_BREAK case 139: YY_RULE_SETUP -#line 451 "scanner.l" +#line 429 "scanner.l" { yylval->h = 13; return NUM; } YY_BREAK case 140: YY_RULE_SETUP -#line 452 "scanner.l" +#line 430 "scanner.l" { yylval->h = 14; return NUM; } YY_BREAK case 141: YY_RULE_SETUP -#line 453 "scanner.l" +#line 431 "scanner.l" { yylval->h = 15; return NUM; } YY_BREAK case 142: YY_RULE_SETUP -#line 454 "scanner.l" +#line 432 "scanner.l" { yylval->h = 16; return NUM; } YY_BREAK case 143: YY_RULE_SETUP -#line 455 "scanner.l" +#line 433 "scanner.l" { yylval->h = 17; return NUM; } YY_BREAK case 144: YY_RULE_SETUP -#line 456 "scanner.l" +#line 434 "scanner.l" { yylval->h = 18; return NUM; } YY_BREAK case 145: YY_RULE_SETUP -#line 458 "scanner.l" +#line 436 "scanner.l" { yylval->h = 0; return NUM; } YY_BREAK case 146: YY_RULE_SETUP -#line 459 "scanner.l" +#line 437 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 147: YY_RULE_SETUP -#line 461 "scanner.l" +#line 439 "scanner.l" { yylval->h = 1; return NUM; } YY_BREAK case 148: YY_RULE_SETUP -#line 462 "scanner.l" +#line 440 "scanner.l" { yylval->h = 2; return NUM; } YY_BREAK case 149: YY_RULE_SETUP -#line 463 "scanner.l" +#line 441 "scanner.l" { yylval->h = 3; return NUM; } YY_BREAK case 150: YY_RULE_SETUP -#line 464 "scanner.l" +#line 442 "scanner.l" { yylval->h = 4; return NUM; } YY_BREAK case 151: YY_RULE_SETUP -#line 465 "scanner.l" +#line 443 "scanner.l" { yylval->h = 128; return NUM; } YY_BREAK case 152: YY_RULE_SETUP -#line 466 "scanner.l" +#line 444 "scanner.l" { yylval->h = 129; return NUM; } YY_BREAK case 153: YY_RULE_SETUP -#line 467 "scanner.l" +#line 445 "scanner.l" { yylval->h = 130; return NUM; } YY_BREAK case 154: YY_RULE_SETUP -#line 468 "scanner.l" +#line 446 "scanner.l" { yylval->h = 131; return NUM; } YY_BREAK case 155: YY_RULE_SETUP -#line 469 "scanner.l" +#line 447 "scanner.l" { yylval->h = 132; return NUM; } YY_BREAK case 156: YY_RULE_SETUP -#line 470 "scanner.l" +#line 448 "scanner.l" { yylval->h = 133; return NUM; } YY_BREAK case 157: YY_RULE_SETUP -#line 471 "scanner.l" +#line 449 "scanner.l" { yylval->h = 134; return NUM; } YY_BREAK case 158: YY_RULE_SETUP -#line 472 "scanner.l" +#line 450 "scanner.l" { yylval->h = 135; return NUM; } YY_BREAK case 159: YY_RULE_SETUP -#line 473 "scanner.l" +#line 451 "scanner.l" { yylval->h = 136; return NUM; } YY_BREAK case 160: YY_RULE_SETUP -#line 474 "scanner.l" +#line 452 "scanner.l" { yylval->h = 137; return NUM; } YY_BREAK case 161: YY_RULE_SETUP -#line 475 "scanner.l" +#line 453 "scanner.l" { yylval->h = 138; return NUM; } YY_BREAK case 162: YY_RULE_SETUP -#line 476 "scanner.l" +#line 454 "scanner.l" { yylval->h = 139; return NUM; } YY_BREAK case 163: YY_RULE_SETUP -#line 477 "scanner.l" +#line 455 "scanner.l" { yylval->h = 140; return NUM; } YY_BREAK case 164: YY_RULE_SETUP -#line 478 "scanner.l" +#line 456 "scanner.l" { yylval->h = 141; return NUM; } YY_BREAK case 165: YY_RULE_SETUP -#line 479 "scanner.l" +#line 457 "scanner.l" { yylval->h = 142; return NUM; } YY_BREAK case 166: YY_RULE_SETUP -#line 480 "scanner.l" +#line 458 "scanner.l" { yylval->h = 143; return NUM; } YY_BREAK case 167: YY_RULE_SETUP -#line 481 "scanner.l" +#line 459 "scanner.l" { yylval->h = 144; return NUM; } YY_BREAK case 168: YY_RULE_SETUP -#line 482 "scanner.l" +#line 460 "scanner.l" { yylval->h = 145; return NUM; } YY_BREAK case 169: YY_RULE_SETUP -#line 483 "scanner.l" +#line 461 "scanner.l" { yylval->h = 146; return NUM; } YY_BREAK case 170: YY_RULE_SETUP -#line 484 "scanner.l" +#line 462 "scanner.l" { yylval->h = 147; return NUM; } YY_BREAK case 171: YY_RULE_SETUP -#line 485 "scanner.l" +#line 463 "scanner.l" { yylval->h = 148; return NUM; } YY_BREAK case 172: YY_RULE_SETUP -#line 486 "scanner.l" +#line 464 "scanner.l" { yylval->h = 149; return NUM; } YY_BREAK case 173: YY_RULE_SETUP -#line 487 "scanner.l" +#line 465 "scanner.l" { yylval->h = 151; return NUM; } YY_BREAK case 174: YY_RULE_SETUP -#line 488 "scanner.l" +#line 466 "scanner.l" { yylval->h = 152; return NUM; } YY_BREAK case 175: YY_RULE_SETUP -#line 489 "scanner.l" +#line 467 "scanner.l" { yylval->h = 153; return NUM; } YY_BREAK case 176: YY_RULE_SETUP -#line 491 "scanner.l" +#line 469 "scanner.l" { yylval->h = 13; return NUM; } YY_BREAK case 177: YY_RULE_SETUP -#line 492 "scanner.l" +#line 470 "scanner.l" { yylval->h = 0x01; return NUM; } YY_BREAK case 178: YY_RULE_SETUP -#line 493 "scanner.l" +#line 471 "scanner.l" { yylval->h = 0x02; return NUM; } YY_BREAK case 179: YY_RULE_SETUP -#line 494 "scanner.l" +#line 472 "scanner.l" { yylval->h = 0x04; return NUM; } YY_BREAK case 180: YY_RULE_SETUP -#line 495 "scanner.l" +#line 473 "scanner.l" { yylval->h = 0x08; return NUM; } YY_BREAK case 181: YY_RULE_SETUP -#line 496 "scanner.l" +#line 474 "scanner.l" { yylval->h = 0x10; return NUM; } YY_BREAK case 182: YY_RULE_SETUP -#line 497 "scanner.l" +#line 475 "scanner.l" { yylval->h = 0x20; return NUM; } YY_BREAK case 183: YY_RULE_SETUP -#line 498 "scanner.l" +#line 476 "scanner.l" { yylval->h = 0x40; return NUM; } YY_BREAK case 184: YY_RULE_SETUP -#line 499 "scanner.l" +#line 477 "scanner.l" { yylval->h = 0x80; return NUM; } YY_BREAK case 185: YY_RULE_SETUP -#line 500 "scanner.l" +#line 478 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext); return ID; } YY_BREAK case 186: YY_RULE_SETUP -#line 502 "scanner.l" +#line 480 "scanner.l" { yylval->s = sdup(yyextra, (char *)yytext + 1); return ID; } YY_BREAK case 187: YY_RULE_SETUP -#line 503 "scanner.l" +#line 481 "scanner.l" { return LEX_ERROR; } YY_BREAK case 188: YY_RULE_SETUP -#line 504 "scanner.l" +#line 482 "scanner.l" ECHO; YY_BREAK -#line 4493 "scanner.c" +#line 4471 "scanner.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -5634,7 +5612,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 504 "scanner.l" +#line 482 "scanner.l" /* diff --git a/generated/libpcap/scanner.h b/generated/libpcap/scanner.h index 3080ed61..478c502f 100644 --- a/generated/libpcap/scanner.h +++ b/generated/libpcap/scanner.h @@ -761,7 +761,7 @@ extern int yylex \ #undef yyTABLES_NAME #endif -#line 504 "scanner.l" +#line 482 "scanner.l" #line 767 "scanner.h" diff --git a/generated/nDPI/ndpi_api.h b/generated/nDPI/ndpi_api.h index b80841f8..61a656bd 100644 --- a/generated/nDPI/ndpi_api.h +++ b/generated/nDPI/ndpi_api.h @@ -1,7 +1,7 @@ /* * ndpi_api.h * - * Copyright (C) 2011-24 - ntop.org + * Copyright (C) 2011-25 - ntop.org * * This file is part of nDPI, an open source deep packet inspection * library based on the OpenDPI and PACE technology by ipoque GmbH @@ -21,6 +21,7 @@ * */ + #ifndef __NDPI_API_H__ #define __NDPI_API_H__ @@ -35,13 +36,8 @@ extern "C" { #define NDPI_DETECTION_ONLY_IPV4 ( 1 << 0 ) #define NDPI_DETECTION_ONLY_IPV6 ( 1 << 1 ) -#define ADD_TO_DETECTION_BITMASK 1 -#define NO_ADD_TO_DETECTION_BITMASK 0 -#define SAVE_DETECTION_BITMASK_AS_UNKNOWN 1 -#define NO_SAVE_DETECTION_BITMASK_AS_UNKNOWN 0 - /* - In case a custom DGA function is used, the fucntion + In case a custom DGA function is used, the function below must be overwritten, */ extern ndpi_custom_dga_predict_fctn ndpi_dga_function; @@ -50,7 +46,7 @@ extern "C" { * Check if a string is encoded with punycode * ( https://tools.ietf.org/html/rfc3492 ) * - * @par buff = pointer to the string to ckeck + * @par buff = pointer to the string to check * @par len = len of the string * @return 1 if the string is punycoded; * else 0 @@ -67,28 +63,17 @@ extern "C" { */ u_int32_t ndpi_detection_get_sizeof_ndpi_flow_struct(void); - /** - * Get the size of the flow tcp struct - * - * @return the size of the flow tcp struct + * Match a string against an automaton and retrieve its associated numeric value. + * This function is similar to ndpi_match_string_subprotocol() but is used for + * matching raw IDs that were added via ndpi_add_string_value_to_automa(). * + * @param _automa Automaton created with ndpi_init_automa() + * @param string_to_match String to search for + * @param match_len Length of the string to match + * @param num Pointer to store the associated numeric value (output parameter) + * @return 1 if a match was found, 0 otherwise */ - u_int32_t ndpi_detection_get_sizeof_ndpi_flow_tcp_struct(void); - - - /** - * Get the size of the flow udp struct - * - * @return the size of the flow udp struct - * - */ - u_int32_t ndpi_detection_get_sizeof_ndpi_flow_udp_struct(void); - - /* - Same as the API call above but used for matching raw id's added - via ndpi_add_string_value_to_automa() - */ int ndpi_match_string_value(void *_automa, char *string_to_match, u_int match_len, u_int32_t *num); @@ -102,18 +87,115 @@ extern "C" { u_int32_t ndpi_get_flow_error_code(struct ndpi_flow_struct *flow); /** - * nDPI personal allocation and free functions - **/ + * Allocate memory using nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom allocator. + * + * @param size Number of bytes to allocate + * @return Pointer to allocated memory, or NULL on failure + */ void * ndpi_malloc(size_t size); - void * ndpi_calloc(unsigned long count, size_t size); - void * ndpi_realloc(void *ptr, size_t old_size, size_t new_size); + + /** + * Allocate and zero-initialize memory using nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom allocator. + * + * @param count Number of elements to allocate + * @param size Size of each element in bytes + * @return Pointer to zero-initialized memory, or NULL on failure + */ + void * ndpi_calloc(size_t nmemb, size_t size); + + /** + * Reallocate memory using nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom allocator. + * + * @param ptr Pointer to previously allocated memory (or NULL for new allocation) + * @param old_size Current size of the allocated block in bytes + * @param new_size Desired new size in bytes + * @return Pointer to reallocated memory, or NULL on failure + */ + void * ndpi_realloc(void *ptr, size_t size); + + /** + * Allocate aligned memory using nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom allocator. + * + * @param the address of the allocated memory will be a multiple of `alignment` + * @param size Number of bytes to allocate + * @return Pointer to allocated memory, or NULL on failure + */ + void * ndpi_aligned_malloc(size_t alignment, size_t size); + + /** + * Duplicate a string using nDPI's memory allocator. + * The returned string must be freed with ndpi_free(). + * + * @param s String to duplicate (null-terminated) + * @return Pointer to newly allocated string copy, or NULL on failure + */ char * ndpi_strdup(const char *s); + + /** + * Duplicate a string with length limit using nDPI's memory allocator. + * The returned string must be freed with ndpi_free(). + * + * @param s String to duplicate + * @param size Maximum number of characters to copy (excluding null terminator) + * @return Pointer to newly allocated string copy, or NULL on failure + */ char * ndpi_strndup(const char *s, size_t size); + + /** + * Free memory allocated by nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom deallocator. + * + * @param ptr Pointer to memory to free (NULL is safe to pass) + */ void ndpi_free(void *ptr); + + /** + * Free aligned memory allocated by nDPI's memory allocator. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom deallocator. + * + * @param ptr Pointer to memory to free (NULL is safe to pass) + */ + void ndpi_aligned_free(void *ptr); + + /** + * Allocate memory for flow-specific data using nDPI's flow allocator. + * Flow memory can use a separate allocator from general memory for better + * memory management in high-throughput scenarios. + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom allocator. + * + * @param size Number of bytes to allocate + * @return Pointer to allocated memory, or NULL on failure + */ void * ndpi_flow_malloc(size_t size); + + /** + * Free memory allocated by ndpi_flow_malloc(). + * This function can be customized via ndpi_set_memory_alloction_functions() to use a custom deallocator. + * + * @param ptr Pointer to flow memory to free (NULL is safe to pass) + */ void ndpi_flow_free(void *ptr); + + /** + * Get the total amount of memory allocated by nDPI. + * This tracks memory allocated via ndpi_malloc(), ndpi_calloc(), ndpi_realloc(), + * ndpi_strdup(), and ndpi_strndup() (but not flow allocations). + * + * @return Total number of bytes currently allocated + */ u_int32_t ndpi_get_tot_allocated_memory(void); + /** + * Remove leading and trailing whitespace from a string in-place. + * + * @param ptr Pointer to the string to process (modified in-place) + * @param ptr_len Pointer to the string length (updated to new length after stripping) + * @return Pointer to the start of the trimmed string (within the original buffer) + */ char *ndpi_strip_leading_trailing_spaces(char *ptr, int *ptr_len) ; /** @@ -152,6 +234,8 @@ extern "C" { */ u_int16_t ndpi_network_ptree_match(struct ndpi_detection_module_struct *ndpi_struct, struct in_addr *pin); + u_int16_t ndpi_network_ptree6_match(struct ndpi_detection_module_struct *ndpi_str, + struct in6_addr *pin); /** * Returns the nDPI protocol id for IP+port-based protocol detection @@ -171,38 +255,6 @@ extern "C" { struct in6_addr *pin, u_int16_t port /* network byte order */); - /** - * Creates a protocol match that does not contain any hostnames. - * - * @par hostname_list = the desired hostname list form which the first entry is used to create the match - * @par empty_app_protocol = the resulting protocol match that does contain all information except the hostname - * - * @return 0 on success, 1 otherwise - */ - int ndpi_init_empty_app_protocol(ndpi_protocol_match const * const hostname_list, - ndpi_protocol_match * const empty_app_protocol); - - /** - * Init single protocol match. - * - * @par ndpi_mod = the struct created for the protocol detection - * @par match = the struct passed to match the protocol - * - * @return 0 on success, 1 otherwise - */ - int ndpi_init_app_protocol(struct ndpi_detection_module_struct *ndpi_str, - ndpi_protocol_match const * const match); - - /** - * Init single protocol match and adds it to the Aho-Corasick automata. - * - * @par ndpi_mod = the struct created for the protocol detection - * @par match = the struct passed to match the protocol - * - */ - void ndpi_init_protocol_match(struct ndpi_detection_module_struct *ndpi_mod, - ndpi_protocol_match const * const match); - /** * Returns a new initialized global context. * @@ -226,10 +278,10 @@ extern "C" { * it do not forget to call first ndpi_finalize_initialization() * * You can call this function multiple times, (i.e. to create multiple - * indipendent detection contexts) but all these calls MUST NOT run + * independent detection contexts) but all these calls MUST NOT run * in parallel * - * @g_ctx = global context associated to the new detection module; NULL if no global context is needed + * @par g_ctx = global context associated to the new detection module; NULL if no global context is needed * @return the initialized detection module * */ @@ -269,74 +321,17 @@ extern "C" { */ void ndpi_exit_detection_module(struct ndpi_detection_module_struct *ndpi_struct); - /** - * Sets a single protocol bitmask - * This function does not increment the index of the callback_buffer - * - * @par label = string for the protocol name - * @par ndpi_struct = the detection module - * @par idx = the index of the callback_buffer - * @par func = function pointer of the protocol search - * @par ndpi_selection_bitmask = the protocol selected bitmask - * @par b_save_bitmask_unknow = if set as "true" save the detection bitmask as unknow - * @par b_add_detection_bitmask = if set as "true" add the protocol bitmask to the detection bitmask - * - */ - void ndpi_set_bitmask_protocol_detection(char *label, - struct ndpi_detection_module_struct *ndpi_struct, - const u_int32_t idx, - u_int16_t ndpi_protocol_id, - void (*func) (struct ndpi_detection_module_struct *, - struct ndpi_flow_struct *flow), - const NDPI_SELECTION_BITMASK_PROTOCOL_SIZE ndpi_selection_bitmask, - u_int8_t b_save_bitmask_unknow, - u_int8_t b_add_detection_bitmask); - - /** - * Sets the protocol bitmask2 - * - * @par ndpi_struct = the detection module - * @par detection_bitmask = the protocol bitmask to set - * @return 0 if ok, -1 if error - * - */ - int ndpi_set_protocol_detection_bitmask2(struct ndpi_detection_module_struct *ndpi_struct, - const NDPI_PROTOCOL_BITMASK * detection_bitmask); - /** * Function to be called before we give up with detection for a given flow. * This function reduces the NDPI_UNKNOWN_PROTOCOL detection * * @par ndpi_struct = the detection module * @par flow = the flow given for the detection module - * @par protocol_was_guessed = 1 if the protocol was guesses (requires enable_guess = 1), 0 otherwise * @return the detected protocol even if the flow is not completed; * */ ndpi_protocol ndpi_detection_giveup(struct ndpi_detection_module_struct *ndpi_struct, - struct ndpi_flow_struct *flow, - u_int8_t *protocol_was_guessed); - - /** - * Processes an extra packet in order to get more information for a given protocol - * (like SSL getting both client and server certificate even if we already know after - * seeing the client certificate what the protocol is) - * - * @par ndpi_struct = the detection module - * @par flow = pointer to the connection state machine - * @par packet = unsigned char pointer to the Layer 3 (IP header) - * @par packetlen = the length of the packet - * @par packet_time_ms = the current timestamp for the packet (expressed in msec) - * @par input_info = (optional) flow information provided by the (external) flow manager - * @return void - * - */ - void ndpi_process_extra_packet(struct ndpi_detection_module_struct *ndpi_struct, - struct ndpi_flow_struct *flow, - const unsigned char *packet, - const unsigned short packetlen, - const u_int64_t packet_time_ms, - struct ndpi_flow_input_info *input_info); + struct ndpi_flow_struct *flow); /** * Processes one packet and returns the ID of the detected protocol. @@ -485,6 +480,7 @@ extern "C" { * @par string_to_match_len = the length of the string * @par ret_match = completed returned match information * @par master_protocol_id = value of the ID associated to the master protocol detected + * @par update_flow_classification = update or not protocol (sub)classification * @return the ID of the matched subprotocol * */ @@ -493,7 +489,8 @@ extern "C" { char *string_to_match, u_int string_to_match_len, ndpi_protocol_match_result *ret_match, - u_int16_t master_protocol_id); + u_int16_t master_protocol_id, + int update_flow_classification); /** * Check if the string content passed match with a protocol @@ -505,18 +502,6 @@ extern "C" { void ndpi_check_subprotocol_risk(struct ndpi_detection_module_struct *ndpi_str, struct ndpi_flow_struct *flow, u_int16_t subprotocol_id); - /** - * Exclude protocol from search - * - * @par ndpi_struct = the detection module - * @par flow = the flow where match the host - * @par master_protocol_id = value of the ID associated to the master protocol detected - * - */ - void ndpi_exclude_protocol(struct ndpi_detection_module_struct *ndpi_struct, - struct ndpi_flow_struct *flow, - u_int16_t master_protocol_id, - const char *_file, const char *_func,int _line); /** * Check if the string -bigram_to_match- match with a bigram of -automa- * @@ -532,35 +517,45 @@ extern "C" { * Write the protocol name in the buffer -buf- as master_protocol.protocol * * @par ndpi_mod = the detection module - * @par proto = the struct ndpi_protocol contain the protocols name + * @par proto = the struct ndpi_master_app_protocol contain the protocols name * @par buf = the buffer to write the name of the protocols * @par buf_len = the length of the buffer * @return the buffer contains the master_protocol and protocol name * */ char* ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_mod, - ndpi_protocol proto, char *buf, u_int buf_len); + ndpi_master_app_protocol proto, char *buf, u_int buf_len); /** * Same as ndpi_protocol2name() with the difference that the numeric protocol * name is returned * - * @par proto = the struct ndpi_protocol contain the protocols name + * @par proto = the struct ndpi_master_app_protocol contain the protocols name * @par buf = the buffer to write the name of the protocols * @par buf_len = the length of the buffer * @return the buffer contains the master_protocol and protocol name * */ - char* ndpi_protocol2id(ndpi_protocol proto, char *buf, u_int buf_len); + char* ndpi_protocol2id(ndpi_master_app_protocol proto, char *buf, u_int buf_len); /** * Find out if a given category is custom/user-defined * * @par category = the category associated to the protocol - * @return 1 if this is a custom user category, 0 otherwise + * @return True if this is a custom user category, false otherwise * */ - int ndpi_is_custom_category(ndpi_protocol_category_t category); + bool ndpi_is_custom_category(ndpi_protocol_category_t category); + + /** + * Find out if a given protocol is custom/user-defined + * + * @par ndpi_str = the detection module + * @par proto_id = the proto_id to check + * @return True if this is a custom user protocol, false otherwise (nDPI protocol already supported in the engine) + * + */ + bool ndpi_is_custom_protocol(struct ndpi_detection_module_struct *ndpi_str, u_int16_t proto_id); /** * Overwrite a protocol category defined by nDPI with the custom category @@ -584,15 +579,35 @@ extern "C" { void ndpi_set_proto_category(struct ndpi_detection_module_struct *ndpi_mod, u_int16_t protoId, ndpi_protocol_category_t protoCategory); + /** + * Find the QoE category for the specified protocol + * + * @par ndpi_mod = the detection module + * @par protoId = the protocol identifier we're searching + * + */ + ndpi_protocol_qoe_category_t ndpi_find_protocol_qoe(struct ndpi_detection_module_struct *ndpi_str, + u_int16_t protoId); + + /** + * Return the name of a RTP payload type + * + * @par payload_type = the RTP payload type + * @par evs_payload_type = EVS payload type (only in case payload_type is EVS) + * @return The symbolic payload type or "Unknown" if not found + */ + const char* ndpi_rtp_payload_type2str(u_int8_t payload_type, u_int32_t evs_payload_type); + /** * Check if subprotocols of the specified master protocol are just * informative (and not real) * + * @par ndpi_mod = the detection module * @par protoId = the (master) protocol identifier to query * @return 1 = the subprotocol is informative, 0 otherwise. * */ - u_int8_t ndpi_is_subprotocol_informative(u_int16_t protoId); + u_int8_t ndpi_is_subprotocol_informative(struct ndpi_detection_module_struct *ndpi_mod, u_int16_t protoId); /** * Set hostname-based protocol @@ -643,7 +658,7 @@ extern "C" { * * @par mod = the detection module * @par category = the category associated to the protocol - * @paw name = the string name of the category + * @par name = the string name of the category * */ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_mod, @@ -681,6 +696,15 @@ extern "C" { ndpi_protocol_breed_t ndpi_get_proto_breed(struct ndpi_detection_module_struct *ndpi_struct, u_int16_t proto); + /** + * Get the protocol breed ID associated to the breed name + * + * @par name = the string name of the breed + * @return the breed ID associated to the name, or NDPI_PROTOCOL_UNRATED if not found + * + */ + ndpi_protocol_breed_t ndpi_get_breed_by_name(const char *name); + /** * Return the string name of the protocol breed * @@ -699,7 +723,7 @@ extern "C" { * @return the ID of the protocol * */ - extern u_int16_t ndpi_get_proto_by_name(struct ndpi_detection_module_struct *ndpi_mod, const char *name); + extern u_int16_t ndpi_get_proto_by_name(const struct ndpi_detection_module_struct *ndpi_mod, const char *name); /** * Return the name of the protocol given its ID @@ -709,7 +733,7 @@ extern "C" { * @return the name of the protocol * */ - extern char* ndpi_get_proto_by_id(struct ndpi_detection_module_struct *ndpi_mod, u_int id); + extern char* ndpi_get_proto_by_id(const struct ndpi_detection_module_struct *ndpi_mod, u_int id); /** * Return the name of the protocol given its ID. You can specify TLS.YouTube or just TLS @@ -838,6 +862,19 @@ extern "C" { int ndpi_load_categories_dir(struct ndpi_detection_module_struct *ndpi_str, char* path); + /** + * Load files (whose name is _