├── .gitignore ├── COPYING ├── ChangeLog ├── Makefile ├── Makefile.am ├── Makefile.in ├── README ├── aclocal.m4 ├── api ├── Makefile.am ├── Makefile.in ├── daq.h ├── daq_api.h ├── daq_base.c ├── daq_common.h └── daq_mod_ops.c ├── compile ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── daq.dsp ├── depcomp ├── install-sh ├── ltmain.sh ├── m4 ├── ax_cflags_gcc_option.m4 ├── libtool.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 ├── lt~obsolete.m4 └── sf.m4 ├── missing ├── os-daq-modules ├── Makefile.am ├── Makefile.in ├── daq-modules-config.in ├── daq_afpacket.c ├── daq_dump.c ├── daq_ipfw.c ├── daq_ipq.c ├── daq_netmap.c ├── daq_nfq.c ├── daq_pcap.c ├── daq_static_modules.c └── daq_static_modules.h ├── packaging └── rpm │ ├── Makefile │ └── daq.spec └── sfbpf ├── IP6_misc.h ├── Makefile.am ├── Makefile.in ├── arcnet.h ├── atmuni31.h ├── bittypes.h ├── ethertype.h ├── gencode.h ├── grammar.y ├── ieee80211.h ├── ipnet.h ├── llc.h ├── namedb.h ├── nlpid.h ├── ppp.h ├── runlex.sh ├── scanner.l ├── sf-redefines.h ├── sf_bpf_filter.c ├── sf_bpf_printer.c ├── sf_gencode.c ├── sf_nametoaddr.c ├── sf_optimize.c ├── sfbpf-int.c ├── sfbpf-int.h ├── sfbpf.h ├── sfbpf_dlt.h ├── sll.h ├── sunatmpos.h └── win32-stdinc.h /.gitignore: -------------------------------------------------------------------------------- 1 | #RPM 2 | pkgs 3 | SOURCES 4 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2019-03-09 Hariharan Chandrashekar 2 | 3 | * ChangeLog, configure.ac, daq.vcxproj : 4 | Bump to 2.0.7 and added DAQ project file for supporting windows 64-bit. 5 | 6 | 2015-07-15 17:13 mialtize 7 | 8 | * ChangeLog, configure.ac, daq.spec, api/daq_api.h, 9 | os-daq-modules/daq_static_modules.c (IMS_5_4_0): Bugs Fixed: 10 | CSCuv26782 Change description: Add lost Netmap DAQ module. Sync 11 | Changelog from 2.0.5 release tarball. Bump to 2.0.6. Update RPM 12 | spec file for appropriate library name. Reviewedboard Link: 13 | http://kingart.cisco.com/reviews/r/30004/ Karma Granted By: Ron 14 | Testing Done: Documentation: 15 | 16 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: rpm 2 | 3 | rpm: 4 | $(MAKE) -C packaging/rpm 5 | 6 | rpmtest: 7 | $(MAKE) LATEST=`git stash create` -C packaging/rpm -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | if BUILD_MODULES 4 | MODULES_DIR = os-daq-modules 5 | endif 6 | SUBDIRS = api sfbpf $(MODULES_DIR) 7 | 8 | ACLOCAL_AMFLAGS = -I m4 9 | 10 | EXTRA_DIST = \ 11 | daq.dsp 12 | -------------------------------------------------------------------------------- /api/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | include_HEADERS = daq.h daq_api.h daq_common.h 6 | 7 | lib_LTLIBRARIES = libdaq.la libdaq_static.la 8 | 9 | libdaq_la_SOURCES = daq_base.c daq_mod_ops.c daq.h daq_api.h daq_common.h 10 | libdaq_la_LDFLAGS = -version-info 2:4:0 @XCCFLAGS@ 11 | libdaq_la_LIBADD = @LIBDL@ 12 | 13 | libdaq_static_la_SOURCES = daq_base.c daq_mod_ops.c daq.h daq_api.h daq_common.h 14 | libdaq_static_la_CFLAGS = -DSTATIC_MODULE_LIST 15 | libdaq_static_la_LDFLAGS = -static 16 | -------------------------------------------------------------------------------- /api/daq.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _DAQ_H 23 | #define _DAQ_H 24 | 25 | #include 26 | #include 27 | 28 | #define DAQ_VERSION_2 29 | 30 | /* Definition of the structures returned by daq_get_module_list(). */ 31 | typedef struct { 32 | char *name; /* Module name */ 33 | uint32_t version; /* Module version */ 34 | uint32_t type; /* Module capabilities */ 35 | } DAQ_Module_Info_t; 36 | 37 | /* Functions for loading, handling, and unloading DAQ modules. */ 38 | DAQ_LINKAGE void daq_set_verbosity(int level); 39 | DAQ_LINKAGE int daq_load_modules(const char *module_dirs[]); 40 | DAQ_LINKAGE const DAQ_Module_t *daq_find_module(const char *name); 41 | DAQ_LINKAGE int daq_get_module_list(DAQ_Module_Info_t *list[]); 42 | DAQ_LINKAGE void daq_free_module_list(DAQ_Module_Info_t *list, int size); 43 | DAQ_LINKAGE void daq_unload_modules(void); 44 | DAQ_LINKAGE void daq_print_stats(DAQ_Stats_t *stats, FILE *fp); 45 | 46 | /* Enumeration to String translation functions. */ 47 | DAQ_LINKAGE const char *daq_mode_string(DAQ_Mode mode); 48 | DAQ_LINKAGE const char *daq_state_string(DAQ_State state); 49 | DAQ_LINKAGE const char *daq_verdict_string(DAQ_Verdict verdict); 50 | 51 | /* DAQ Configuration Dictionary Functions */ 52 | DAQ_LINKAGE const char *daq_config_get_value(DAQ_Config_t *config, const char *key); 53 | DAQ_LINKAGE void daq_config_set_value(DAQ_Config_t *config, const char *key, const char *value); 54 | DAQ_LINKAGE void daq_config_clear_value(DAQ_Config_t *config, const char *key); 55 | DAQ_LINKAGE void daq_config_clear_values(DAQ_Config_t *config); 56 | 57 | /* DAQ Module functions. */ 58 | DAQ_LINKAGE const char *daq_get_name(const DAQ_Module_t *module); 59 | DAQ_LINKAGE uint32_t daq_get_type(const DAQ_Module_t *module); 60 | 61 | /* DAQ Module Instance functions */ 62 | DAQ_LINKAGE int daq_initialize(const DAQ_Module_t *module, const DAQ_Config_t *config, void **handle, char *errbuf, size_t len); 63 | DAQ_LINKAGE int daq_set_filter(const DAQ_Module_t *module, void *handle, const char *filter); 64 | DAQ_LINKAGE int daq_start(const DAQ_Module_t *module, void *handle); 65 | DAQ_LINKAGE int daq_acquire(const DAQ_Module_t *module, void *handle, int cnt, DAQ_Analysis_Func_t callback, void *user); 66 | DAQ_LINKAGE int daq_acquire_with_meta(const DAQ_Module_t *module, void *handle, int cnt, 67 | DAQ_Analysis_Func_t callback, DAQ_Meta_Func_t metaback, 68 | void *user); 69 | DAQ_LINKAGE int daq_inject(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, const uint8_t *packet_data, uint32_t len, int reverse); 70 | DAQ_LINKAGE int daq_breakloop(const DAQ_Module_t *module, void *handle); 71 | DAQ_LINKAGE int daq_stop(const DAQ_Module_t *module, void *handle); 72 | DAQ_LINKAGE int daq_shutdown(const DAQ_Module_t *module, void *handle); 73 | DAQ_LINKAGE DAQ_State daq_check_status(const DAQ_Module_t *module, void *handle); 74 | DAQ_LINKAGE int daq_get_stats(const DAQ_Module_t *module, void *handle, DAQ_Stats_t *stats); 75 | DAQ_LINKAGE void daq_reset_stats(const DAQ_Module_t *module, void *handle); 76 | DAQ_LINKAGE int daq_get_snaplen(const DAQ_Module_t *module, void *handle); 77 | DAQ_LINKAGE uint32_t daq_get_capabilities(const DAQ_Module_t *module, void *handle); 78 | DAQ_LINKAGE int daq_get_datalink_type(const DAQ_Module_t *module, void *handle); 79 | DAQ_LINKAGE const char *daq_get_error(const DAQ_Module_t *module, void *handle); 80 | DAQ_LINKAGE void daq_clear_error(const DAQ_Module_t *module, void *handle); 81 | DAQ_LINKAGE int daq_modify_flow(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_ModFlow_t *modify); 82 | DAQ_LINKAGE int daq_hup_prep(const DAQ_Module_t *module, void *handle, void **new_config); 83 | DAQ_LINKAGE int daq_hup_apply(const DAQ_Module_t *module, void *handle, void *new_config, void **old_config); 84 | DAQ_LINKAGE int daq_hup_post(const DAQ_Module_t *module, void *handle, void *old_config); 85 | DAQ_LINKAGE int daq_dp_add_dc(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_DP_key_t *dp_key, const uint8_t *packet_data); 86 | 87 | #endif /* _DAQ_H */ 88 | -------------------------------------------------------------------------------- /api/daq_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _DAQ_API_H 23 | #define _DAQ_API_H 24 | 25 | #include 26 | 27 | struct _daq_dict_entry 28 | { 29 | char *key; 30 | char *value; 31 | struct _daq_dict_entry *next; 32 | }; 33 | 34 | struct _daq_module 35 | { 36 | /* The version of the API this module implements. 37 | This *must* be the first element in the structure. */ 38 | const uint32_t api_version; 39 | /* The version of the DAQ module itself - can be completely arbitrary. */ 40 | const uint32_t module_version; 41 | /* The name of the module (sfpacket, xvnim, pcap, etc.) */ 42 | const char *name; 43 | /* Various flags describing the module and its capabilities (Inline-capabale, etc.) */ 44 | const uint32_t type; 45 | /* Initialize the device for packet acquisition with the supplied configuration. 46 | This should not start queuing packets for the application. */ 47 | int (*initialize) (const DAQ_Config_t *config, void **ctxt_ptr, char *errbuf, size_t len); 48 | /* Set the module's BPF based on the given string */ 49 | int (*set_filter) (void *handle, const char *filter); 50 | /* Complete device opening and begin queuing packets if they have not been already. */ 51 | int (*start) (void *handle); 52 | /* Acquire up to packets and call for each with as the final argument. 53 | The return value of the callback will determine the action taken by the DAQ for each packet. 54 | If is 0, packets will continue to be acquired until some other factor breaks the 55 | acquisition loop. */ 56 | int (*acquire) (void *handle, int cnt, DAQ_Analysis_Func_t callback, DAQ_Meta_Func_t metaback, void *user); 57 | /* Inject a new packet going either the same or opposite direction as the specified packet. */ 58 | int (*inject) (void *handle, const DAQ_PktHdr_t *hdr, const uint8_t *packet_data, uint32_t len, int reverse); 59 | /* Force breaking out of the acquisition loop after the current iteration. */ 60 | int (*breakloop) (void *handle); 61 | /* Stop queuing packets, if possible */ 62 | int (*stop) (void *handle); 63 | /* Close the device and clean up */ 64 | void (*shutdown) (void *handle); 65 | /* Get the status of the module (one of DAQ_STATE_*). */ 66 | DAQ_State (*check_status) (void *handle); 67 | /* Populates the structure with the current DAQ stats. These stats are cumulative. */ 68 | int (*get_stats) (void *handle, DAQ_Stats_t *stats); 69 | /* Resets the DAQ module's internal stats. */ 70 | void (*reset_stats) (void *handle); 71 | /* Return the configured snaplen */ 72 | int (*get_snaplen) (void *handle); 73 | /* Return a bitfield of the device's capabilities */ 74 | uint32_t (*get_capabilities) (void *handle); 75 | /* Return the instance's Data Link Type */ 76 | int (*get_datalink_type) (void *handle); 77 | /* Return a pointer to the module's internal error buffer */ 78 | const char * (*get_errbuf) (void *handle); 79 | /* Write a string to the module instance's internal error buffer */ 80 | void (*set_errbuf) (void *handle, const char *string); 81 | /* Return the index of the given named device if possible. */ 82 | int (*get_device_index) (void *handle, const char *device); 83 | /* Modify a flow */ 84 | int (*modify_flow) (void *handle, const DAQ_PktHdr_t *hdr, DAQ_ModFlow_t *modify); 85 | /* Read new configuration */ 86 | int (*hup_prep) (void *handle, void **new_config); 87 | /* Swap new and old configuration */ 88 | int (*hup_apply) (void *handle, void *new_config, void **old_config); 89 | /* Destroy old configuration */ 90 | int (*hup_post) (void *handle, void *old_config); 91 | /** DAQ API to program a FST/EFT entry for dynamic protocol data channel 92 | * 93 | * @param [in] handle DAQ module handle 94 | * @param [in] hdr DAQ packet header of the control channel packet. 95 | * @param [in] dp_key Key structure of the data channel flow 96 | * @param [in] packet_data Packet of the companion control channel packet. 97 | * @return Error code of the API. 0 - success. 98 | */ 99 | int (*dp_add_dc) (void *handle, const DAQ_PktHdr_t * hdr, DAQ_DP_key_t * dp_key, const uint8_t * packet_data); 100 | }; 101 | 102 | #define DAQ_API_VERSION 0x00010002 103 | 104 | #define DAQ_ERRBUF_SIZE 256 105 | /* This is a convenience macro for safely printing to DAQ error buffers. It must be called on a known-size character array. */ 106 | 107 | #ifdef WIN32 108 | inline void DPE(char *var, char *fmt, ...) 109 | { 110 | va_list ap; 111 | va_start(ap, fmt); 112 | 113 | snprintf(var, sizeof(var), ap); 114 | 115 | va_end(ap); 116 | } 117 | #else 118 | #define DPE(var, ...) snprintf(var, sizeof(var), __VA_ARGS__) 119 | #endif 120 | 121 | #endif /* _DAQ_API_H */ 122 | -------------------------------------------------------------------------------- /api/daq_mod_ops.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include "daq.h" 28 | #include "daq_api.h" 29 | 30 | /* 31 | * Functions that apply to instances of DAQ modules go here. 32 | */ 33 | DAQ_LINKAGE int daq_initialize(const DAQ_Module_t *module, const DAQ_Config_t *config, void **handle, char *errbuf, size_t len) 34 | { 35 | /* Don't do this. */ 36 | if (!errbuf) 37 | return DAQ_ERROR; 38 | 39 | if (!module) 40 | return DAQ_ERROR_NOMOD; 41 | 42 | if (!config) 43 | { 44 | snprintf(errbuf, len, "Can't initialize without a configuration!"); 45 | return DAQ_ERROR_INVAL; 46 | } 47 | 48 | if (!handle) 49 | { 50 | snprintf(errbuf, len, "Can't initialize without a context pointer!"); 51 | return DAQ_ERROR_INVAL; 52 | } 53 | 54 | if ((config->mode == DAQ_MODE_PASSIVE && !(module->type & DAQ_TYPE_INTF_CAPABLE)) || 55 | (config->mode == DAQ_MODE_INLINE && !(module->type & DAQ_TYPE_INLINE_CAPABLE)) || 56 | (config->mode == DAQ_MODE_READ_FILE && !(module->type & DAQ_TYPE_FILE_CAPABLE))) 57 | { 58 | snprintf(errbuf, len, "The %s DAQ module does not support %s mode!", module->name, daq_mode_string(config->mode)); 59 | return DAQ_ERROR_INVAL; 60 | } 61 | 62 | 63 | return module->initialize(config, handle, errbuf, len); 64 | } 65 | 66 | DAQ_LINKAGE int daq_set_filter(const DAQ_Module_t *module, void *handle, const char *filter) 67 | { 68 | if (!module) 69 | return DAQ_ERROR_NOMOD; 70 | 71 | if (!handle) 72 | return DAQ_ERROR_NOCTX; 73 | 74 | if (!filter) 75 | { 76 | module->set_errbuf(handle, "No filter string specified!"); 77 | return DAQ_ERROR_INVAL; 78 | } 79 | 80 | return module->set_filter(handle, filter); 81 | } 82 | 83 | DAQ_LINKAGE int daq_start(const DAQ_Module_t *module, void *handle) 84 | { 85 | if (!module) 86 | return DAQ_ERROR_NOMOD; 87 | 88 | if (!handle) 89 | return DAQ_ERROR_NOCTX; 90 | 91 | if (module->check_status(handle) != DAQ_STATE_INITIALIZED) 92 | { 93 | module->set_errbuf(handle, "Can't start an instance that isn't initialized!"); 94 | return DAQ_ERROR; 95 | } 96 | 97 | return module->start(handle); 98 | } 99 | 100 | DAQ_LINKAGE int daq_acquire(const DAQ_Module_t *module, void *handle, int cnt, 101 | DAQ_Analysis_Func_t callback, void *user) 102 | { 103 | if (!module) 104 | return DAQ_ERROR_NOMOD; 105 | 106 | if (!handle) 107 | return DAQ_ERROR_NOCTX; 108 | 109 | if (module->check_status(handle) != DAQ_STATE_STARTED) 110 | { 111 | module->set_errbuf(handle, "Can't acquire packets from an instance that isn't started!"); 112 | return DAQ_ERROR; 113 | } 114 | 115 | return module->acquire(handle, cnt, callback, NULL, user); 116 | } 117 | 118 | DAQ_LINKAGE int daq_acquire_with_meta(const DAQ_Module_t *module, void *handle, int cnt, 119 | DAQ_Analysis_Func_t callback, 120 | DAQ_Meta_Func_t metaback, void *user) 121 | { 122 | if (!module) 123 | return DAQ_ERROR_NOMOD; 124 | 125 | if (!handle) 126 | return DAQ_ERROR_NOCTX; 127 | 128 | if (module->check_status(handle) != DAQ_STATE_STARTED) 129 | { 130 | module->set_errbuf(handle, "Can't acquire packets from an instance that isn't started!"); 131 | return DAQ_ERROR; 132 | } 133 | 134 | return module->acquire(handle, cnt, callback, metaback, user); 135 | } 136 | 137 | DAQ_LINKAGE int daq_inject(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, const uint8_t *packet_data, uint32_t len, int reverse) 138 | { 139 | if (!module) 140 | return DAQ_ERROR_NOMOD; 141 | 142 | if (!handle) 143 | return DAQ_ERROR_NOCTX; 144 | 145 | if (!hdr) 146 | { 147 | module->set_errbuf(handle, "No originating packet header specified!"); 148 | return DAQ_ERROR_INVAL; 149 | } 150 | 151 | if (!packet_data) 152 | { 153 | module->set_errbuf(handle, "No packet data specified!"); 154 | return DAQ_ERROR_INVAL; 155 | } 156 | 157 | return module->inject(handle, hdr, packet_data, len, reverse); 158 | } 159 | 160 | DAQ_LINKAGE int daq_breakloop(const DAQ_Module_t *module, void *handle) 161 | { 162 | if (!module) 163 | return DAQ_ERROR_NOMOD; 164 | 165 | if (!handle) 166 | return DAQ_ERROR_NOCTX; 167 | 168 | return module->breakloop(handle); 169 | } 170 | 171 | DAQ_LINKAGE int daq_stop(const DAQ_Module_t *module, void *handle) 172 | { 173 | if (!module) 174 | return DAQ_ERROR_NOMOD; 175 | 176 | if (!handle) 177 | return DAQ_ERROR_NOCTX; 178 | 179 | if (module->check_status(handle) != DAQ_STATE_STARTED) 180 | { 181 | module->set_errbuf(handle, "Can't stop an instance that hasn't started!"); 182 | return DAQ_ERROR; 183 | } 184 | 185 | return module->stop(handle); 186 | } 187 | 188 | DAQ_LINKAGE int daq_shutdown(const DAQ_Module_t *module, void *handle) 189 | { 190 | if (!module) 191 | return DAQ_ERROR_NOMOD; 192 | if (!handle) 193 | return DAQ_ERROR_NOCTX; 194 | 195 | module->shutdown(handle); 196 | 197 | return DAQ_SUCCESS; 198 | } 199 | 200 | DAQ_LINKAGE DAQ_State daq_check_status(const DAQ_Module_t *module, void *handle) 201 | { 202 | if (!module || !handle) 203 | return DAQ_STATE_UNKNOWN; 204 | 205 | return module->check_status(handle); 206 | } 207 | 208 | DAQ_LINKAGE int daq_get_stats(const DAQ_Module_t *module, void *handle, DAQ_Stats_t *stats) 209 | { 210 | if (!module) 211 | return DAQ_ERROR_NOMOD; 212 | 213 | if (!handle) 214 | return DAQ_ERROR_NOCTX; 215 | 216 | if (!stats) 217 | { 218 | module->set_errbuf(handle, "No place to put the statistics!"); 219 | return DAQ_ERROR_INVAL; 220 | } 221 | 222 | return module->get_stats(handle, stats); 223 | } 224 | 225 | DAQ_LINKAGE void daq_reset_stats(const DAQ_Module_t *module, void *handle) 226 | { 227 | if (module && handle) 228 | module->reset_stats(handle); 229 | } 230 | 231 | DAQ_LINKAGE int daq_get_snaplen(const DAQ_Module_t *module, void *handle) 232 | { 233 | if (!module) 234 | return DAQ_ERROR_NOMOD; 235 | 236 | if (!handle) 237 | return DAQ_ERROR_NOCTX; 238 | 239 | return module->get_snaplen(handle); 240 | } 241 | 242 | DAQ_LINKAGE uint32_t daq_get_capabilities(const DAQ_Module_t *module, void *handle) 243 | { 244 | if (!module) 245 | return DAQ_ERROR_NOMOD; 246 | 247 | if (!handle) 248 | return DAQ_ERROR_NOCTX; 249 | 250 | return module->get_capabilities(handle); 251 | } 252 | 253 | DAQ_LINKAGE int daq_get_datalink_type(const DAQ_Module_t *module, void *handle) 254 | { 255 | if (!module) 256 | return DAQ_ERROR_NOMOD; 257 | 258 | if (!handle) 259 | return DAQ_ERROR_NOCTX; 260 | 261 | return module->get_datalink_type(handle); 262 | } 263 | 264 | DAQ_LINKAGE const char *daq_get_error(const DAQ_Module_t *module, void *handle) 265 | { 266 | if (!module || !handle) 267 | return NULL; 268 | 269 | return module->get_errbuf(handle); 270 | } 271 | 272 | DAQ_LINKAGE void daq_clear_error(const DAQ_Module_t *module, void *handle) 273 | { 274 | if (!module || !handle) 275 | return; 276 | 277 | module->set_errbuf(handle, ""); 278 | } 279 | 280 | DAQ_LINKAGE int daq_get_device_index(const DAQ_Module_t *module, void *handle, const char *device) 281 | { 282 | if (!module) 283 | return DAQ_ERROR_NOMOD; 284 | 285 | if (!handle) 286 | return DAQ_ERROR_NOCTX; 287 | 288 | if (!device) 289 | { 290 | module->set_errbuf(handle, "No device name to find the index of!"); 291 | return DAQ_ERROR_INVAL; 292 | } 293 | 294 | return module->get_device_index(handle, device); 295 | } 296 | 297 | DAQ_LINKAGE int daq_hup_prep(const DAQ_Module_t *module, void *handle, void **new_config) 298 | { 299 | if (!module) 300 | return DAQ_ERROR_NOMOD; 301 | 302 | if (!handle) 303 | return DAQ_ERROR_NOCTX; 304 | 305 | if (!module->hup_prep) 306 | { 307 | if (!module->hup_apply) 308 | return 1; 309 | return DAQ_SUCCESS; 310 | } 311 | 312 | return module->hup_prep(handle, new_config); 313 | } 314 | 315 | DAQ_LINKAGE int daq_hup_apply(const DAQ_Module_t *module, void *handle, void *new_config, void **old_config) 316 | { 317 | if (!module) 318 | return DAQ_ERROR_NOMOD; 319 | 320 | if (!handle) 321 | return DAQ_ERROR_NOCTX; 322 | 323 | if (!module->hup_apply) 324 | return DAQ_SUCCESS; 325 | 326 | return module->hup_apply(handle, new_config, old_config); 327 | } 328 | 329 | DAQ_LINKAGE int daq_hup_post(const DAQ_Module_t *module, void *handle, void *old_config) 330 | { 331 | if (!module) 332 | return DAQ_ERROR_NOMOD; 333 | 334 | if (!handle) 335 | return DAQ_ERROR_NOCTX; 336 | 337 | if (!module->hup_post) 338 | return DAQ_SUCCESS; 339 | 340 | return module->hup_post(handle, old_config); 341 | } 342 | 343 | DAQ_LINKAGE int daq_modify_flow(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_ModFlow_t *modify) 344 | { 345 | if (!module) 346 | return DAQ_ERROR_NOMOD; 347 | 348 | if (!module->modify_flow) 349 | return DAQ_SUCCESS; 350 | 351 | return module->modify_flow(handle, hdr, modify); 352 | } 353 | 354 | /* 355 | * Functions that apply to DAQ modules themselves go here. 356 | */ 357 | DAQ_LINKAGE const char *daq_get_name(const DAQ_Module_t *module) 358 | { 359 | if (!module) 360 | return NULL; 361 | 362 | return module->name; 363 | } 364 | 365 | DAQ_LINKAGE uint32_t daq_get_type(const DAQ_Module_t *module) 366 | { 367 | if (!module) 368 | return DAQ_ERROR_NOMOD; 369 | 370 | return module->type; 371 | } 372 | 373 | DAQ_LINKAGE int daq_dp_add_dc(const DAQ_Module_t *module, void *handle, const DAQ_PktHdr_t *hdr, DAQ_DP_key_t *dp_key, const uint8_t *packet_data) 374 | { 375 | if (!module) 376 | return DAQ_ERROR_NOMOD; 377 | 378 | if (!handle) 379 | return DAQ_ERROR_NOCTX; 380 | 381 | if (!module->dp_add_dc) 382 | return DAQ_SUCCESS; 383 | 384 | return module->dp_add_dc(handle, hdr, dp_key, packet_data); 385 | } 386 | -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand '-c -o'. 3 | 4 | scriptversion=2012-10-14.11; # UTC 5 | 6 | # Copyright (C) 1999-2014 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # This file is maintained in Automake, please report 28 | # bugs to or send patches to 29 | # . 30 | 31 | nl=' 32 | ' 33 | 34 | # We need space, tab and new line, in precisely that order. Quoting is 35 | # there to prevent tools from complaining about whitespace usage. 36 | IFS=" "" $nl" 37 | 38 | file_conv= 39 | 40 | # func_file_conv build_file lazy 41 | # Convert a $build file to $host form and store it in $file 42 | # Currently only supports Windows hosts. If the determined conversion 43 | # type is listed in (the comma separated) LAZY, no conversion will 44 | # take place. 45 | func_file_conv () 46 | { 47 | file=$1 48 | case $file in 49 | / | /[!/]*) # absolute file, and not a UNC file 50 | if test -z "$file_conv"; then 51 | # lazily determine how to convert abs files 52 | case `uname -s` in 53 | MINGW*) 54 | file_conv=mingw 55 | ;; 56 | CYGWIN*) 57 | file_conv=cygwin 58 | ;; 59 | *) 60 | file_conv=wine 61 | ;; 62 | esac 63 | fi 64 | case $file_conv/,$2, in 65 | *,$file_conv,*) 66 | ;; 67 | mingw/*) 68 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 69 | ;; 70 | cygwin/*) 71 | file=`cygpath -m "$file" || echo "$file"` 72 | ;; 73 | wine/*) 74 | file=`winepath -w "$file" || echo "$file"` 75 | ;; 76 | esac 77 | ;; 78 | esac 79 | } 80 | 81 | # func_cl_dashL linkdir 82 | # Make cl look for libraries in LINKDIR 83 | func_cl_dashL () 84 | { 85 | func_file_conv "$1" 86 | if test -z "$lib_path"; then 87 | lib_path=$file 88 | else 89 | lib_path="$lib_path;$file" 90 | fi 91 | linker_opts="$linker_opts -LIBPATH:$file" 92 | } 93 | 94 | # func_cl_dashl library 95 | # Do a library search-path lookup for cl 96 | func_cl_dashl () 97 | { 98 | lib=$1 99 | found=no 100 | save_IFS=$IFS 101 | IFS=';' 102 | for dir in $lib_path $LIB 103 | do 104 | IFS=$save_IFS 105 | if $shared && test -f "$dir/$lib.dll.lib"; then 106 | found=yes 107 | lib=$dir/$lib.dll.lib 108 | break 109 | fi 110 | if test -f "$dir/$lib.lib"; then 111 | found=yes 112 | lib=$dir/$lib.lib 113 | break 114 | fi 115 | if test -f "$dir/lib$lib.a"; then 116 | found=yes 117 | lib=$dir/lib$lib.a 118 | break 119 | fi 120 | done 121 | IFS=$save_IFS 122 | 123 | if test "$found" != yes; then 124 | lib=$lib.lib 125 | fi 126 | } 127 | 128 | # func_cl_wrapper cl arg... 129 | # Adjust compile command to suit cl 130 | func_cl_wrapper () 131 | { 132 | # Assume a capable shell 133 | lib_path= 134 | shared=: 135 | linker_opts= 136 | for arg 137 | do 138 | if test -n "$eat"; then 139 | eat= 140 | else 141 | case $1 in 142 | -o) 143 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 144 | eat=1 145 | case $2 in 146 | *.o | *.[oO][bB][jJ]) 147 | func_file_conv "$2" 148 | set x "$@" -Fo"$file" 149 | shift 150 | ;; 151 | *) 152 | func_file_conv "$2" 153 | set x "$@" -Fe"$file" 154 | shift 155 | ;; 156 | esac 157 | ;; 158 | -I) 159 | eat=1 160 | func_file_conv "$2" mingw 161 | set x "$@" -I"$file" 162 | shift 163 | ;; 164 | -I*) 165 | func_file_conv "${1#-I}" mingw 166 | set x "$@" -I"$file" 167 | shift 168 | ;; 169 | -l) 170 | eat=1 171 | func_cl_dashl "$2" 172 | set x "$@" "$lib" 173 | shift 174 | ;; 175 | -l*) 176 | func_cl_dashl "${1#-l}" 177 | set x "$@" "$lib" 178 | shift 179 | ;; 180 | -L) 181 | eat=1 182 | func_cl_dashL "$2" 183 | ;; 184 | -L*) 185 | func_cl_dashL "${1#-L}" 186 | ;; 187 | -static) 188 | shared=false 189 | ;; 190 | -Wl,*) 191 | arg=${1#-Wl,} 192 | save_ifs="$IFS"; IFS=',' 193 | for flag in $arg; do 194 | IFS="$save_ifs" 195 | linker_opts="$linker_opts $flag" 196 | done 197 | IFS="$save_ifs" 198 | ;; 199 | -Xlinker) 200 | eat=1 201 | linker_opts="$linker_opts $2" 202 | ;; 203 | -*) 204 | set x "$@" "$1" 205 | shift 206 | ;; 207 | *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 208 | func_file_conv "$1" 209 | set x "$@" -Tp"$file" 210 | shift 211 | ;; 212 | *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 213 | func_file_conv "$1" mingw 214 | set x "$@" "$file" 215 | shift 216 | ;; 217 | *) 218 | set x "$@" "$1" 219 | shift 220 | ;; 221 | esac 222 | fi 223 | shift 224 | done 225 | if test -n "$linker_opts"; then 226 | linker_opts="-link$linker_opts" 227 | fi 228 | exec "$@" $linker_opts 229 | exit 1 230 | } 231 | 232 | eat= 233 | 234 | case $1 in 235 | '') 236 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 237 | exit 1; 238 | ;; 239 | -h | --h*) 240 | cat <<\EOF 241 | Usage: compile [--help] [--version] PROGRAM [ARGS] 242 | 243 | Wrapper for compilers which do not understand '-c -o'. 244 | Remove '-o dest.o' from ARGS, run PROGRAM with the remaining 245 | arguments, and rename the output as expected. 246 | 247 | If you are trying to build a whole package this is not the 248 | right script to run: please start by reading the file 'INSTALL'. 249 | 250 | Report bugs to . 251 | EOF 252 | exit $? 253 | ;; 254 | -v | --v*) 255 | echo "compile $scriptversion" 256 | exit $? 257 | ;; 258 | cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) 259 | func_cl_wrapper "$@" # Doesn't return... 260 | ;; 261 | esac 262 | 263 | ofile= 264 | cfile= 265 | 266 | for arg 267 | do 268 | if test -n "$eat"; then 269 | eat= 270 | else 271 | case $1 in 272 | -o) 273 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 274 | # So we strip '-o arg' only if arg is an object. 275 | eat=1 276 | case $2 in 277 | *.o | *.obj) 278 | ofile=$2 279 | ;; 280 | *) 281 | set x "$@" -o "$2" 282 | shift 283 | ;; 284 | esac 285 | ;; 286 | *.c) 287 | cfile=$1 288 | set x "$@" "$1" 289 | shift 290 | ;; 291 | *) 292 | set x "$@" "$1" 293 | shift 294 | ;; 295 | esac 296 | fi 297 | shift 298 | done 299 | 300 | if test -z "$ofile" || test -z "$cfile"; then 301 | # If no '-o' option was seen then we might have been invoked from a 302 | # pattern rule where we don't need one. That is ok -- this is a 303 | # normal compilation that the losing compiler can handle. If no 304 | # '.c' file was seen then we are probably linking. That is also 305 | # ok. 306 | exec "$@" 307 | fi 308 | 309 | # Name of file we expect compiler to create. 310 | cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 311 | 312 | # Create the lock directory. 313 | # Note: use '[/\\:.-]' here to ensure that we don't use the same name 314 | # that we are using for the .o file. Also, base the name on the expected 315 | # object file name, since that is what matters with a parallel build. 316 | lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 317 | while true; do 318 | if mkdir "$lockdir" >/dev/null 2>&1; then 319 | break 320 | fi 321 | sleep 1 322 | done 323 | # FIXME: race condition here if user kills between mkdir and trap. 324 | trap "rmdir '$lockdir'; exit 1" 1 2 15 325 | 326 | # Run the compile. 327 | "$@" 328 | ret=$? 329 | 330 | if test -f "$cofile"; then 331 | test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 332 | elif test -f "${cofile}bj"; then 333 | test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 334 | fi 335 | 336 | rmdir "$lockdir" 337 | exit $ret 338 | 339 | # Local Variables: 340 | # mode: shell-script 341 | # sh-indentation: 2 342 | # eval: (add-hook 'write-file-hooks 'time-stamp) 343 | # time-stamp-start: "scriptversion=" 344 | # time-stamp-format: "%:y-%02m-%02d.%02H" 345 | # time-stamp-time-zone: "UTC" 346 | # time-stamp-end: "; # UTC" 347 | # End: 348 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the declaration of `PACKET_TX_RING', and to 0 if 4 | you don't. */ 5 | #undef HAVE_DECL_PACKET_TX_RING 6 | 7 | /* Define to 1 if you have the declaration of `TPACKET2_HDRLEN', and to 0 if 8 | you don't. */ 9 | #undef HAVE_DECL_TPACKET2_HDRLEN 10 | 11 | /* Define to 1 if you have the header file. */ 12 | #undef HAVE_DLFCN_H 13 | 14 | /* Define to 1 if you have the header file. */ 15 | #undef HAVE_DNET_H 16 | 17 | /* Define to 1 if you have the header file. */ 18 | #undef HAVE_DUMBNET_H 19 | 20 | /* Define to 1 if you have the `gethostbyname' function. */ 21 | #undef HAVE_GETHOSTBYNAME 22 | 23 | /* Define to 1 if you have the `getpagesize' function. */ 24 | #undef HAVE_GETPAGESIZE 25 | 26 | /* Define to 1 if you have the header file. */ 27 | #undef HAVE_INTTYPES_H 28 | 29 | /* Define to 1 if you have the `dnet' library (-ldnet). */ 30 | #undef HAVE_LIBDNET 31 | 32 | /* Define to 1 if you have the `dumbnet' library (-ldumbnet). */ 33 | #undef HAVE_LIBDUMBNET 34 | 35 | /* Define to 1 if you have the header file. */ 36 | #undef HAVE_LIBIPQ_H 37 | 38 | /* Define to 1 if you have the 39 | header file. */ 40 | #undef HAVE_LIBNETFILTER_QUEUE_LIBNETFILTER_QUEUE_H 41 | 42 | /* Define to 1 if you have the `pcap' library (-lpcap). */ 43 | #undef HAVE_LIBPCAP 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_LINUX_IF_ETHER_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_LINUX_IF_PACKET_H 50 | 51 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 52 | to 0 otherwise. */ 53 | #undef HAVE_MALLOC 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #undef HAVE_MEMORY_H 57 | 58 | /* Define to 1 if you have the `memset' function. */ 59 | #undef HAVE_MEMSET 60 | 61 | /* Define to 1 if you have a working `mmap' system call. */ 62 | #undef HAVE_MMAP 63 | 64 | /* Define to 1 if you have the `munmap' function. */ 65 | #undef HAVE_MUNMAP 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #undef HAVE_NETDB_H 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #undef HAVE_NETINET_IN_H 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #undef HAVE_NET_NETMAP_H 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #undef HAVE_NET_NETMAP_USER_H 78 | 79 | /* Define to 1 if you have the `socket' function. */ 80 | #undef HAVE_SOCKET 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #undef HAVE_STDINT_H 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #undef HAVE_STDLIB_H 87 | 88 | /* Define to 1 if you have the `strchr' function. */ 89 | #undef HAVE_STRCHR 90 | 91 | /* Define to 1 if you have the `strcspn' function. */ 92 | #undef HAVE_STRCSPN 93 | 94 | /* Define to 1 if you have the `strdup' function. */ 95 | #undef HAVE_STRDUP 96 | 97 | /* Define to 1 if you have the `strerror' function. */ 98 | #undef HAVE_STRERROR 99 | 100 | /* Define to 1 if you have the header file. */ 101 | #undef HAVE_STRINGS_H 102 | 103 | /* Define to 1 if you have the header file. */ 104 | #undef HAVE_STRING_H 105 | 106 | /* Define to 1 if you have the `strrchr' function. */ 107 | #undef HAVE_STRRCHR 108 | 109 | /* Define to 1 if you have the `strstr' function. */ 110 | #undef HAVE_STRSTR 111 | 112 | /* Define to 1 if you have the `strtoul' function. */ 113 | #undef HAVE_STRTOUL 114 | 115 | /* Define to 1 if you have the header file. */ 116 | #undef HAVE_SYS_IOCTL_H 117 | 118 | /* Define to 1 if you have the header file. */ 119 | #undef HAVE_SYS_PARAM_H 120 | 121 | /* Define to 1 if you have the header file. */ 122 | #undef HAVE_SYS_SOCKET_H 123 | 124 | /* Define to 1 if you have the header file. */ 125 | #undef HAVE_SYS_STAT_H 126 | 127 | /* Define to 1 if you have the header file. */ 128 | #undef HAVE_SYS_TIME_H 129 | 130 | /* Define to 1 if you have the header file. */ 131 | #undef HAVE_SYS_TYPES_H 132 | 133 | /* Define to 1 if you have the header file. */ 134 | #undef HAVE_UNISTD_H 135 | 136 | /* Define if the compiler supports visibility declarations. */ 137 | #undef HAVE_VISIBILITY 138 | 139 | /* System IPv6 support */ 140 | #undef INET6 141 | 142 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ 143 | #undef LT_OBJDIR 144 | 145 | /* Name of package */ 146 | #undef PACKAGE 147 | 148 | /* Define to the address where bug reports for this package should be sent. */ 149 | #undef PACKAGE_BUGREPORT 150 | 151 | /* Define to the full name of this package. */ 152 | #undef PACKAGE_NAME 153 | 154 | /* Define to the full name and version of this package. */ 155 | #undef PACKAGE_STRING 156 | 157 | /* Define to the one symbol short name of this package. */ 158 | #undef PACKAGE_TARNAME 159 | 160 | /* Define to the home page for this package. */ 161 | #undef PACKAGE_URL 162 | 163 | /* Define to the version of this package. */ 164 | #undef PACKAGE_VERSION 165 | 166 | /* Define to 1 if you have the ANSI C header files. */ 167 | #undef STDC_HEADERS 168 | 169 | /* Version number of package */ 170 | #undef VERSION 171 | 172 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 173 | , or is not used. If the typedef were allowed, the 174 | #define below would cause a syntax error. */ 175 | #undef _UINT32_T 176 | 177 | /* Define for Solaris 2.5.1 so the uint64_t typedef from , 178 | , or is not used. If the typedef were allowed, the 179 | #define below would cause a syntax error. */ 180 | #undef _UINT64_T 181 | 182 | /* Define for Solaris 2.5.1 so the uint8_t typedef from , 183 | , or is not used. If the typedef were allowed, the 184 | #define below would cause a syntax error. */ 185 | #undef _UINT8_T 186 | 187 | /* Define to `__inline__' or `__inline' if that's what the C compiler 188 | calls it, or to nothing if 'inline' is not supported under any name. */ 189 | #ifndef __cplusplus 190 | #undef inline 191 | #endif 192 | 193 | /* Define to rpl_malloc if the replacement function should be used. */ 194 | #undef malloc 195 | 196 | /* Define to `unsigned int' if does not define. */ 197 | #undef size_t 198 | 199 | /* Define to the type of an unsigned integer type of width exactly 16 bits if 200 | such a type exists and the standard includes do not define it. */ 201 | #undef uint16_t 202 | 203 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 204 | such a type exists and the standard includes do not define it. */ 205 | #undef uint32_t 206 | 207 | /* Define to the type of an unsigned integer type of width exactly 64 bits if 208 | such a type exists and the standard includes do not define it. */ 209 | #undef uint64_t 210 | 211 | /* Define to the type of an unsigned integer type of width exactly 8 bits if 212 | such a type exists and the standard includes do not define it. */ 213 | #undef uint8_t 214 | -------------------------------------------------------------------------------- /daq.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="daq" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=daq - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "daq.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "daq.mak" CFG="daq - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "daq - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "daq - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "daq - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 2 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /MD /W3 /GX /O2 /I "api" /I "sfbpf" /I "../src/win32/WIN32-Includes" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "DAQ_DLL" /D "HAVE_CONFIG_H" /D "BUILD_PCAP_MODULE" /D "STATIC_MODULE_LIST" /D "_AFXDLL" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "daq - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 2 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "api" /I "sfbpf" /I "../src/win32/WIN32-Includes" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "DAQ_DLL" /D "HAVE_CONFIG_H" /D "BUILD_PCAP_MODULE" /D "STATIC_MODULE_LIST" /D "_AFXDLL" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "daq - Win32 Release" 82 | # Name "daq - Win32 Debug" 83 | # Begin Group "api" 84 | 85 | # PROP Default_Filter "" 86 | # Begin Source File 87 | 88 | SOURCE=.\api\daq.h 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=.\api\daq_api.h 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=.\api\daq_base.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=.\api\daq_common.h 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=.\api\daq_mod_ops.c 105 | # End Source File 106 | # End Group 107 | # Begin Group "sfbpf" 108 | 109 | # PROP Default_Filter "" 110 | # Begin Source File 111 | 112 | SOURCE=.\sfbpf\arcnet.h 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\sfbpf\atmuni31.h 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\sfbpf\bittypes.h 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE=.\sfbpf\ethertype.h 125 | # End Source File 126 | # Begin Source File 127 | 128 | SOURCE=.\sfbpf\gencode.h 129 | # End Source File 130 | # Begin Source File 131 | 132 | SOURCE=.\sfbpf\grammar.y 133 | 134 | !IF "$(CFG)" == "daq - Win32 Release" 135 | 136 | # Begin Custom Build 137 | InputPath=.\sfbpf\grammar.y 138 | InputName=grammar 139 | 140 | BuildCmds= \ 141 | c:\cygwin\bin\bison -d -psfbpf_lval -osfbpf/$(InputName).c sfbpf/$(InputName).y \ 142 | c:\cygwin\bin\mv sfbpf/$(InputName).h sfbpf/tokdefs.h \ 143 | 144 | 145 | "sfbpf/$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 146 | $(BuildCmds) 147 | 148 | "sfbpf/tokdefs.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 149 | $(BuildCmds) 150 | # End Custom Build 151 | 152 | !ELSEIF "$(CFG)" == "daq - Win32 Debug" 153 | 154 | # Begin Custom Build 155 | InputPath=.\sfbpf\grammar.y 156 | InputName=grammar 157 | 158 | BuildCmds= \ 159 | c:\cygwin\bin\bison -d -psfbpf_lval -osfbpf/$(InputName).c sfbpf/$(InputName).y \ 160 | c:\cygwin\bin\mv sfbpf/$(InputName).h sfbpf/tokdefs.h \ 161 | 162 | 163 | "sfbpf/$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 164 | $(BuildCmds) 165 | 166 | "sfbpf/tokdefs.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 167 | $(BuildCmds) 168 | # End Custom Build 169 | 170 | !ENDIF 171 | 172 | # End Source File 173 | # Begin Source File 174 | 175 | SOURCE=.\sfbpf\ieee80211.h 176 | # End Source File 177 | # Begin Source File 178 | 179 | SOURCE=.\sfbpf\IP6_misc.h 180 | # End Source File 181 | # Begin Source File 182 | 183 | SOURCE=.\sfbpf\ipnet.h 184 | # End Source File 185 | # Begin Source File 186 | 187 | SOURCE=.\sfbpf\llc.h 188 | # End Source File 189 | # Begin Source File 190 | 191 | SOURCE=.\sfbpf\namedb.h 192 | # End Source File 193 | # Begin Source File 194 | 195 | SOURCE=.\sfbpf\nlpid.h 196 | # End Source File 197 | # Begin Source File 198 | 199 | SOURCE=.\sfbpf\ppp.h 200 | # End Source File 201 | # Begin Source File 202 | 203 | SOURCE=.\sfbpf\scanner.l 204 | 205 | !IF "$(CFG)" == "daq - Win32 Release" 206 | 207 | # Begin Custom Build 208 | InputPath=.\sfbpf\scanner.l 209 | InputName=scanner 210 | 211 | "sfbpf/$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 212 | c:\cygwin\bin\flex -i -Psfbpf_lval -osfbpf/$(InputName).c sfbpf/$(InputName).l 213 | 214 | # End Custom Build 215 | 216 | !ELSEIF "$(CFG)" == "daq - Win32 Debug" 217 | 218 | # Begin Custom Build 219 | InputPath=.\sfbpf\scanner.l 220 | InputName=scanner 221 | 222 | "sfbpf/$(InputName).c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" 223 | c:\cygwin\bin\flex -i -Psfbpf_lval -osfbpf/$(InputName).c sfbpf/$(InputName).l 224 | 225 | # End Custom Build 226 | 227 | !ENDIF 228 | 229 | # End Source File 230 | # Begin Source File 231 | 232 | SOURCE=".\sfbpf\sf-redefines.h" 233 | # End Source File 234 | # Begin Source File 235 | 236 | SOURCE=.\sfbpf\sf_bpf_filter.c 237 | # End Source File 238 | # Begin Source File 239 | 240 | SOURCE=.\sfbpf\sf_bpf_printer.c 241 | # End Source File 242 | # Begin Source File 243 | 244 | SOURCE=.\sfbpf\sf_gencode.c 245 | # End Source File 246 | # Begin Source File 247 | 248 | SOURCE=.\sfbpf\sf_nametoaddr.c 249 | # ADD CPP /I "../src/win32/WIN32-Includes/WinPCAP" 250 | # End Source File 251 | # Begin Source File 252 | 253 | SOURCE=.\sfbpf\sf_optimize.c 254 | # End Source File 255 | # Begin Source File 256 | 257 | SOURCE=".\sfbpf\sfbpf-int.c" 258 | # End Source File 259 | # Begin Source File 260 | 261 | SOURCE=".\sfbpf\sfbpf-int.h" 262 | # End Source File 263 | # Begin Source File 264 | 265 | SOURCE=.\sfbpf\sfbpf.h 266 | # End Source File 267 | # Begin Source File 268 | 269 | SOURCE=.\sfbpf\sfbpf_dlt.h 270 | # End Source File 271 | # Begin Source File 272 | 273 | SOURCE=.\sfbpf\sll.h 274 | # End Source File 275 | # Begin Source File 276 | 277 | SOURCE=.\sfbpf\sunatmpos.h 278 | # End Source File 279 | # Begin Source File 280 | 281 | SOURCE=".\sfbpf\win32-stdinc.h" 282 | # End Source File 283 | # End Group 284 | # Begin Group "os-daq-modules" 285 | 286 | # PROP Default_Filter "" 287 | # Begin Source File 288 | 289 | SOURCE=".\os-daq-modules\daq_pcap.c" 290 | # ADD CPP /I "../src/win32/WIN32-Includes/WinPCAP" 291 | # End Source File 292 | # Begin Source File 293 | 294 | SOURCE=".\os-daq-modules\daq_static_modules.c" 295 | # End Source File 296 | # Begin Source File 297 | 298 | SOURCE=".\os-daq-modules\daq_static_modules.h" 299 | # End Source File 300 | # End Group 301 | # End Target 302 | # End Project 303 | -------------------------------------------------------------------------------- /m4/ax_cflags_gcc_option.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cflags_gcc_option.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_CFLAGS_GCC_OPTION(-fomit-frame-pointer) would show a message like 12 | # "checking CFLAGS for gcc -fomit-frame-pointer ... yes" and add the 13 | # optionflag to CFLAGS if it is understood. You can override the 14 | # shellvar-default of CFLAGS of course. The order of arguments stems from 15 | # the explicit macros like AX_CFLAGS_WARN_ALL. 16 | # 17 | # The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add to 18 | # CXXFLAGS - and it uses the autoconf setup for C++ instead of C (since it 19 | # is possible to use different compilers for C and C++). 20 | # 21 | # The macro is a lot simpler than any special AX_CFLAGS_* macro (or 22 | # ax_cxx_rtti.m4 macro) but allows to check for arbitrary options. 23 | # However, if you use this macro in a few places, it would be great if you 24 | # would make up a new function-macro and submit it to the ac-archive. 25 | # 26 | # - $1 option-to-check-for : required ("-option" as non-value) 27 | # - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case) 28 | # - $3 action-if-found : add value to shellvariable 29 | # - $4 action-if-not-found : nothing 30 | # 31 | # Note: in earlier versions, $1-$2 were swapped. We try to detect the 32 | # situation and accept a $2=~/-/ as being the old option-to-check-for. 33 | # 34 | # There are other variants that emerged from the original macro variant 35 | # which did just test an option to be possibly added. However, some 36 | # compilers accept an option silently, or possibly for just another option 37 | # that was not intended. Therefore, we have to do a generic test for a 38 | # compiler family. For gcc we check "-pedantic" being accepted which is 39 | # also understood by compilers who just want to be compatible with gcc 40 | # even when not being made from gcc sources. 41 | # 42 | # See also: AX_CFLAGS_SUN_OPTION, AX_CFLAGS_HPUX_OPTION, 43 | # AX_CFLAGS_AIX_OPTION, and AX_CFLAGS_IRIX_OPTION. 44 | # 45 | # LICENSE 46 | # 47 | # Copyright (c) 2008 Guido U. Draheim 48 | # 49 | # This program is free software; you can redistribute it and/or modify it 50 | # under the terms of the GNU General Public License as published by the 51 | # Free Software Foundation; either version 3 of the License, or (at your 52 | # option) any later version. 53 | # 54 | # This program is distributed in the hope that it will be useful, but 55 | # WITHOUT ANY WARRANTY; without even the implied warranty of 56 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 57 | # Public License for more details. 58 | # 59 | # You should have received a copy of the GNU General Public License along 60 | # with this program. If not, see . 61 | # 62 | # As a special exception, the respective Autoconf Macro's copyright owner 63 | # gives unlimited permission to copy, distribute and modify the configure 64 | # scripts that are the output of Autoconf when processing the Macro. You 65 | # need not follow the terms of the GNU General Public License when using 66 | # or distributing such scripts, even though portions of the text of the 67 | # Macro appear in them. The GNU General Public License (GPL) does govern 68 | # all other use of the material that constitutes the Autoconf Macro. 69 | # 70 | # This special exception to the GPL applies to versions of the Autoconf 71 | # Macro released by the Autoconf Archive. When you make and distribute a 72 | # modified version of the Autoconf Macro, you may extend this special 73 | # exception to the GPL to apply to your modified version as well. 74 | 75 | #serial 13 76 | 77 | AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl 78 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl 79 | AS_VAR_PUSHDEF([VAR],[ax_cv_cflags_gcc_option_$2])dnl 80 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], 81 | VAR,[AS_VAR_SET([VAR],["no, unknown"]) 82 | AC_LANG_SAVE 83 | AC_LANG_C 84 | ac_save_[]FLAGS="$[]FLAGS" 85 | for ac_arg dnl 86 | in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC 87 | "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC 88 | # 89 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 90 | AC_TRY_COMPILE([],[return 0;], 91 | [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 92 | done 93 | FLAGS="$ac_save_[]FLAGS" 94 | AC_LANG_RESTORE 95 | ]) 96 | m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 97 | case ".$var" in 98 | .ok|.ok,*) m4_ifvaln($3,$3) ;; 99 | .|.no|.no,*) m4_ifvaln($4,$4) ;; 100 | *) m4_ifvaln($3,$3,[ 101 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $var " 2>&1 >/dev/null 102 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $var]) 103 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var"]) 104 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var" 105 | fi ]) ;; 106 | esac 107 | AS_VAR_POPDEF([VAR])dnl 108 | AS_VAR_POPDEF([FLAGS])dnl 109 | ]) 110 | 111 | 112 | dnl the only difference - the LANG selection... and the default FLAGS 113 | 114 | AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl 115 | AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 116 | AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_gcc_option_$2])dnl 117 | AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], 118 | VAR,[AS_VAR_SET([VAR],["no, unknown"]) 119 | AC_LANG_SAVE 120 | AC_LANG_CPLUSPLUS 121 | ac_save_[]FLAGS="$[]FLAGS" 122 | for ac_arg dnl 123 | in "-pedantic -Werror % m4_ifval($2,$2,-option)" dnl GCC 124 | "-pedantic % m4_ifval($2,$2,-option) %% no, obsolete" dnl new GCC 125 | # 126 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 127 | AC_TRY_COMPILE([],[return 0;], 128 | [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 129 | done 130 | FLAGS="$ac_save_[]FLAGS" 131 | AC_LANG_RESTORE 132 | ]) 133 | m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 134 | case ".$var" in 135 | .ok|.ok,*) m4_ifvaln($3,$3) ;; 136 | .|.no|.no,*) m4_ifvaln($4,$4) ;; 137 | *) m4_ifvaln($3,$3,[ 138 | if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $var " 2>&1 >/dev/null 139 | then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $var]) 140 | else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var"]) 141 | m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $var" 142 | fi ]) ;; 143 | esac 144 | AS_VAR_POPDEF([VAR])dnl 145 | AS_VAR_POPDEF([FLAGS])dnl 146 | ]) 147 | 148 | dnl ------------------------------------------------------------------------- 149 | 150 | AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl 151 | AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl 152 | AS_VAR_PUSHDEF([VAR],[ax_cv_cflags_gcc_option_$1])dnl 153 | AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], 154 | VAR,[AS_VAR_SET([VAR],["no, unknown"]) 155 | AC_LANG_SAVE 156 | AC_LANG_C 157 | ac_save_[]FLAGS="$[]FLAGS" 158 | for ac_arg dnl 159 | in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC 160 | "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC 161 | # 162 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 163 | AC_TRY_COMPILE([],[return 0;], 164 | [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 165 | done 166 | FLAGS="$ac_save_[]FLAGS" 167 | AC_LANG_RESTORE 168 | ]) 169 | m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 170 | case ".$var" in 171 | .ok|.ok,*) m4_ifvaln($3,$3) ;; 172 | .|.no|.no,*) m4_ifvaln($4,$4) ;; 173 | *) m4_ifvaln($3,$3,[ 174 | if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null 175 | then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var]) 176 | else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"]) 177 | m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var" 178 | fi ]) ;; 179 | esac 180 | AS_VAR_POPDEF([VAR])dnl 181 | AS_VAR_POPDEF([FLAGS])dnl 182 | ]) 183 | 184 | 185 | dnl the only difference - the LANG selection... and the default FLAGS 186 | 187 | AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl 188 | AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl 189 | AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_gcc_option_$1])dnl 190 | AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], 191 | VAR,[AS_VAR_SET([VAR],["no, unknown"]) 192 | AC_LANG_SAVE 193 | AC_LANG_CPLUSPLUS 194 | ac_save_[]FLAGS="$[]FLAGS" 195 | for ac_arg dnl 196 | in "-pedantic -Werror % m4_ifval($1,$1,-option)" dnl GCC 197 | "-pedantic % m4_ifval($1,$1,-option) %% no, obsolete" dnl new GCC 198 | # 199 | do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` 200 | AC_TRY_COMPILE([],[return 0;], 201 | [AS_VAR_SET([VAR],[`echo $ac_arg | sed -e 's,.*% *,,'`]); break]) 202 | done 203 | FLAGS="$ac_save_[]FLAGS" 204 | AC_LANG_RESTORE 205 | ]) 206 | m4_ifdef([AS_VAR_COPY],[AS_VAR_COPY([var],[VAR])],[var=AS_VAR_GET([VAR])]) 207 | case ".$var" in 208 | .ok|.ok,*) m4_ifvaln($3,$3) ;; 209 | .|.no|.no,*) m4_ifvaln($4,$4) ;; 210 | *) m4_ifvaln($3,$3,[ 211 | if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $var " 2>&1 >/dev/null 212 | then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $var]) 213 | else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var"]) 214 | m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $var" 215 | fi ]) ;; 216 | esac 217 | AS_VAR_POPDEF([VAR])dnl 218 | AS_VAR_POPDEF([FLAGS])dnl 219 | ]) 220 | 221 | AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, 222 | [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])]) 223 | 224 | AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, 225 | [AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])]) 226 | -------------------------------------------------------------------------------- /m4/ltsugar.m4: -------------------------------------------------------------------------------- 1 | # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software 4 | # Foundation, Inc. 5 | # Written by Gary V. Vaughan, 2004 6 | # 7 | # This file is free software; the Free Software Foundation gives 8 | # unlimited permission to copy and/or distribute it, with or without 9 | # modifications, as long as this notice is preserved. 10 | 11 | # serial 6 ltsugar.m4 12 | 13 | # This is to help aclocal find these macros, as it can't see m4_define. 14 | AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) 15 | 16 | 17 | # lt_join(SEP, ARG1, [ARG2...]) 18 | # ----------------------------- 19 | # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their 20 | # associated separator. 21 | # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier 22 | # versions in m4sugar had bugs. 23 | m4_define([lt_join], 24 | [m4_if([$#], [1], [], 25 | [$#], [2], [[$2]], 26 | [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) 27 | m4_define([_lt_join], 28 | [m4_if([$#$2], [2], [], 29 | [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) 30 | 31 | 32 | # lt_car(LIST) 33 | # lt_cdr(LIST) 34 | # ------------ 35 | # Manipulate m4 lists. 36 | # These macros are necessary as long as will still need to support 37 | # Autoconf-2.59, which quotes differently. 38 | m4_define([lt_car], [[$1]]) 39 | m4_define([lt_cdr], 40 | [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], 41 | [$#], 1, [], 42 | [m4_dquote(m4_shift($@))])]) 43 | m4_define([lt_unquote], $1) 44 | 45 | 46 | # lt_append(MACRO-NAME, STRING, [SEPARATOR]) 47 | # ------------------------------------------ 48 | # Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. 49 | # Note that neither SEPARATOR nor STRING are expanded; they are appended 50 | # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). 51 | # No SEPARATOR is output if MACRO-NAME was previously undefined (different 52 | # than defined and empty). 53 | # 54 | # This macro is needed until we can rely on Autoconf 2.62, since earlier 55 | # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. 56 | m4_define([lt_append], 57 | [m4_define([$1], 58 | m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) 59 | 60 | 61 | 62 | # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) 63 | # ---------------------------------------------------------- 64 | # Produce a SEP delimited list of all paired combinations of elements of 65 | # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list 66 | # has the form PREFIXmINFIXSUFFIXn. 67 | # Needed until we can rely on m4_combine added in Autoconf 2.62. 68 | m4_define([lt_combine], 69 | [m4_if(m4_eval([$# > 3]), [1], 70 | [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl 71 | [[m4_foreach([_Lt_prefix], [$2], 72 | [m4_foreach([_Lt_suffix], 73 | ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, 74 | [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) 75 | 76 | 77 | # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) 78 | # ----------------------------------------------------------------------- 79 | # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited 80 | # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. 81 | m4_define([lt_if_append_uniq], 82 | [m4_ifdef([$1], 83 | [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], 84 | [lt_append([$1], [$2], [$3])$4], 85 | [$5])], 86 | [lt_append([$1], [$2], [$3])$4])]) 87 | 88 | 89 | # lt_dict_add(DICT, KEY, VALUE) 90 | # ----------------------------- 91 | m4_define([lt_dict_add], 92 | [m4_define([$1($2)], [$3])]) 93 | 94 | 95 | # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) 96 | # -------------------------------------------- 97 | m4_define([lt_dict_add_subkey], 98 | [m4_define([$1($2:$3)], [$4])]) 99 | 100 | 101 | # lt_dict_fetch(DICT, KEY, [SUBKEY]) 102 | # ---------------------------------- 103 | m4_define([lt_dict_fetch], 104 | [m4_ifval([$3], 105 | m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), 106 | m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) 107 | 108 | 109 | # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) 110 | # ----------------------------------------------------------------- 111 | m4_define([lt_if_dict_fetch], 112 | [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], 113 | [$5], 114 | [$6])]) 115 | 116 | 117 | # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) 118 | # -------------------------------------------------------------- 119 | m4_define([lt_dict_filter], 120 | [m4_if([$5], [], [], 121 | [lt_join(m4_quote(m4_default([$4], [[, ]])), 122 | lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), 123 | [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl 124 | ]) 125 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 4179 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.6]) 16 | m4_define([LT_PACKAGE_REVISION], [2.4.6]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.6' 20 | macro_revision='2.4.6' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /m4/lt~obsolete.m4: -------------------------------------------------------------------------------- 1 | # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- 2 | # 3 | # Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software 4 | # Foundation, Inc. 5 | # Written by Scott James Remnant, 2004. 6 | # 7 | # This file is free software; the Free Software Foundation gives 8 | # unlimited permission to copy and/or distribute it, with or without 9 | # modifications, as long as this notice is preserved. 10 | 11 | # serial 5 lt~obsolete.m4 12 | 13 | # These exist entirely to fool aclocal when bootstrapping libtool. 14 | # 15 | # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), 16 | # which have later been changed to m4_define as they aren't part of the 17 | # exported API, or moved to Autoconf or Automake where they belong. 18 | # 19 | # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN 20 | # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us 21 | # using a macro with the same name in our local m4/libtool.m4 it'll 22 | # pull the old libtool.m4 in (it doesn't see our shiny new m4_define 23 | # and doesn't know about Autoconf macros at all.) 24 | # 25 | # So we provide this file, which has a silly filename so it's always 26 | # included after everything else. This provides aclocal with the 27 | # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything 28 | # because those macros already exist, or will be overwritten later. 29 | # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 30 | # 31 | # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. 32 | # Yes, that means every name once taken will need to remain here until 33 | # we give up compatibility with versions before 1.7, at which point 34 | # we need to keep only those names which we still refer to. 35 | 36 | # This is to help aclocal find these macros, as it can't see m4_define. 37 | AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) 38 | 39 | m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) 40 | m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) 41 | m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) 42 | m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) 43 | m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) 44 | m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) 45 | m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) 46 | m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) 47 | m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) 48 | m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) 49 | m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) 50 | m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) 51 | m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) 52 | m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) 53 | m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) 54 | m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) 55 | m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) 56 | m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) 57 | m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) 58 | m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) 59 | m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) 60 | m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) 61 | m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) 62 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) 63 | m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) 64 | m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) 65 | m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) 66 | m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) 67 | m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) 68 | m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) 69 | m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) 70 | m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) 71 | m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) 72 | m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) 73 | m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) 74 | m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) 75 | m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) 76 | m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) 77 | m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) 78 | m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) 79 | m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) 80 | m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) 81 | m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) 82 | m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) 83 | m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) 84 | m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) 85 | m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) 86 | m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) 87 | m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) 88 | m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) 89 | m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) 90 | m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) 91 | m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) 92 | m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) 93 | m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) 94 | m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) 95 | m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) 96 | m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) 97 | m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) 98 | m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) 99 | m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) 100 | -------------------------------------------------------------------------------- /m4/sf.m4: -------------------------------------------------------------------------------- 1 | dnl Enable visibility if we can 2 | dnl modified from gnulib/m4/visibility.m4 3 | AC_DEFUN([AC_ENABLE_VISIBILITY], 4 | [ 5 | AC_REQUIRE([AC_PROG_CC]) 6 | AC_MSG_CHECKING([for visibility support]) 7 | AC_CACHE_VAL(gl_cv_cc_visibility, [ 8 | gl_save_CFLAGS="$CFLAGS" 9 | # Add -Werror flag since some compilers, e.g. icc 7.1, don't support it, 10 | # but only warn about it instead of compilation failing 11 | CFLAGS="$CFLAGS -Werror -fvisibility=hidden" 12 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 13 | extern __attribute__((__visibility__("hidden"))) int hiddenvar; 14 | extern __attribute__((__visibility__("default"))) int exportedvar; 15 | extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 16 | extern __attribute__((__visibility__("default"))) int exportedfunc (void);]], 17 | [[]])], 18 | [gl_cv_cc_visibility="yes"], 19 | [gl_cv_cc_visibility="no"]) 20 | ]) 21 | AC_MSG_RESULT([$gl_cv_cc_visibility]) 22 | if test "x$gl_cv_cc_visibility" = "xyes"; then 23 | CFLAGS="$gl_save_CFLAGS -fvisibility=hidden" 24 | AC_DEFINE([HAVE_VISIBILITY],[1], 25 | [Define if the compiler supports visibility declarations.]) 26 | else 27 | CFLAGS="$gl_save_CFLAGS" 28 | fi 29 | ]) 30 | 31 | dnl Special compiler flags for ICC 32 | dnl GCC strict CFLAGS 33 | AC_DEFUN([AC_SF_COMPILER_SETUP], 34 | [AC_REQUIRE([AC_PROG_CC]) 35 | ICC=no 36 | if eval "echo $CC | grep icc > /dev/null" ; then 37 | if eval "$CC -help | grep libcxa > /dev/null" ; then 38 | CFLAGS="$CFLAGS -static-libcxa" 39 | LDFLAGS="$LDFLAGS -static-libcxa" 40 | XCCFLAGS="-XCClinker -static-libcxa" 41 | else 42 | CFLAGS="$CFLAGS -static-intel" 43 | LDFLAGS="$LDFLAGS -static-intel" 44 | XCCFLAGS="-XCClinker -static-intel" 45 | fi 46 | CFLAGS=`echo $CFLAGS | sed 's/-O2/-O3/'` 47 | CFLAGS="$CFLAGS -ip -w1" 48 | ICC=yes 49 | GCC=no 50 | fi 51 | 52 | if test "$GCC" = yes ; then 53 | AX_CFLAGS_GCC_OPTION(-Wall) 54 | AX_CFLAGS_GCC_OPTION(-Wwrite-strings) 55 | AX_CFLAGS_GCC_OPTION(-Wsign-compare) 56 | AX_CFLAGS_GCC_OPTION(-Wcast-align) 57 | AX_CFLAGS_GCC_OPTION(-Wextra) 58 | AX_CFLAGS_GCC_OPTION(-Wformat) 59 | AX_CFLAGS_GCC_OPTION(-Wformat-security) 60 | AX_CFLAGS_GCC_OPTION(-Wno-unused-parameter) 61 | AX_CFLAGS_GCC_OPTION(-fno-strict-aliasing) 62 | AX_CFLAGS_GCC_OPTION(-fdiagnostics-show-option) 63 | AX_CFLAGS_GCC_OPTION(-pedantic -std=c99 -D_GNU_SOURCE) 64 | fi 65 | ]) 66 | 67 | dnl 68 | dnl Check for flex, default to lex 69 | dnl Require flex 2.4 or higher 70 | dnl Check for bison, default to yacc 71 | dnl Default to lex/yacc if both flex and bison are not available 72 | dnl Define the yy prefix string if using flex and bison 73 | dnl 74 | dnl usage: 75 | dnl 76 | dnl AC_LBL_LEX_AND_YACC(lex, yacc, yyprefix) 77 | dnl 78 | dnl results: 79 | dnl 80 | dnl $1 (lex set) 81 | dnl $2 (yacc appended) 82 | dnl $3 (optional flex and bison -P prefix) 83 | dnl 84 | AC_DEFUN([AC_LBL_LEX_AND_YACC], 85 | [AC_ARG_WITH(flex, [ --without-flex don't use flex]) 86 | AC_ARG_WITH(bison, [ --without-bison don't use bison]) 87 | if test "$with_flex" = no ; then 88 | $1=lex 89 | else 90 | AC_CHECK_PROGS($1, flex, lex) 91 | fi 92 | if test "$$1" = flex ; then 93 | # The -V flag was added in 2.4 94 | AC_MSG_CHECKING(for flex 2.4 or higher) 95 | AC_CACHE_VAL(ac_cv_lbl_flex_v24, 96 | if flex -V >/dev/null 2>&1; then 97 | ac_cv_lbl_flex_v24=yes 98 | else 99 | ac_cv_lbl_flex_v24=no 100 | fi) 101 | AC_MSG_RESULT($ac_cv_lbl_flex_v24) 102 | if test $ac_cv_lbl_flex_v24 = no ; then 103 | s="2.4 or higher required" 104 | AC_MSG_WARN(ignoring obsolete flex executable ($s)) 105 | $1=lex 106 | fi 107 | fi 108 | if test "$with_bison" = no ; then 109 | $2=yacc 110 | else 111 | AC_CHECK_PROGS($2, bison, yacc) 112 | fi 113 | if test "$$2" = bison ; then 114 | $2="$$2 -y" 115 | fi 116 | if test "$$1" != lex -a "$$2" = yacc -o "$$1" = lex -a "$$2" != yacc ; then 117 | AC_MSG_WARN(don't have both flex and bison; reverting to lex/yacc) 118 | $1=lex 119 | $2=yacc 120 | fi 121 | if test "$$1" = flex -a -n "$3" ; then 122 | $1="$$1 -P$3" 123 | $2="$$2 -p $3" 124 | fi]) 125 | 126 | AC_DEFUN([AC_CHECK_PCAP_VER], 127 | [ 128 | AC_REQUIRE([AC_PROG_CC]) 129 | AC_MSG_CHECKING([for pcap_lib_version]) 130 | AC_CHECK_LIB([pcap],[pcap_lib_version],[LIBS="-lpcap ${LIBS}"],[have_pcap_lib_version="no"],[]) 131 | if test "x$have_pcap_lib_version" = "xno"; then 132 | echo 133 | echo " ERROR! Libpcap library version >= $1 not found." 134 | echo " Get it from http://www.tcpdump.org" 135 | echo 136 | exit 1 137 | fi 138 | AC_CACHE_CHECK([for libpcap version >= $1], [daq_cv_libpcap_version_1x], [ 139 | AC_RUN_IFELSE( 140 | [AC_LANG_PROGRAM( 141 | [[ 142 | #include 143 | #include 144 | extern char pcap_version[]; 145 | ]], 146 | [[ 147 | if (strcmp(pcap_version, $1) < 0) 148 | return 1; 149 | ]])], 150 | [daq_cv_libpcap_version_1x="yes"], 151 | [daq_cv_libpcap_version_1x="no"])]) 152 | if test "x$daq_cv_libpcap_version_1x" = "xno"; then 153 | echo 154 | echo " ERROR! Libpcap library version >= $1 not found." 155 | echo " Get it from http://www.tcpdump.org" 156 | echo 157 | exit 1 158 | fi 159 | ]) 160 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common wrapper for a few potentially missing GNU programs. 3 | 4 | scriptversion=2013-10-28.13; # UTC 5 | 6 | # Copyright (C) 1996-2014 Free Software Foundation, Inc. 7 | # Originally written by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | case $1 in 33 | 34 | --is-lightweight) 35 | # Used by our autoconf macros to check whether the available missing 36 | # script is modern enough. 37 | exit 0 38 | ;; 39 | 40 | --run) 41 | # Back-compat with the calling convention used by older automake. 42 | shift 43 | ;; 44 | 45 | -h|--h|--he|--hel|--help) 46 | echo "\ 47 | $0 [OPTION]... PROGRAM [ARGUMENT]... 48 | 49 | Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50 | to PROGRAM being missing or too old. 51 | 52 | Options: 53 | -h, --help display this help and exit 54 | -v, --version output version information and exit 55 | 56 | Supported PROGRAM values: 57 | aclocal autoconf autoheader autom4te automake makeinfo 58 | bison yacc flex lex help2man 59 | 60 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61 | 'g' are ignored when checking the name. 62 | 63 | Send bug reports to ." 64 | exit $? 65 | ;; 66 | 67 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68 | echo "missing $scriptversion (GNU Automake)" 69 | exit $? 70 | ;; 71 | 72 | -*) 73 | echo 1>&2 "$0: unknown '$1' option" 74 | echo 1>&2 "Try '$0 --help' for more information" 75 | exit 1 76 | ;; 77 | 78 | esac 79 | 80 | # Run the given program, remember its exit status. 81 | "$@"; st=$? 82 | 83 | # If it succeeded, we are done. 84 | test $st -eq 0 && exit 0 85 | 86 | # Also exit now if we it failed (or wasn't found), and '--version' was 87 | # passed; such an option is passed most likely to detect whether the 88 | # program is present and works. 89 | case $2 in --version|--help) exit $st;; esac 90 | 91 | # Exit code 63 means version mismatch. This often happens when the user 92 | # tries to use an ancient version of a tool on a file that requires a 93 | # minimum version. 94 | if test $st -eq 63; then 95 | msg="probably too old" 96 | elif test $st -eq 127; then 97 | # Program was missing. 98 | msg="missing on your system" 99 | else 100 | # Program was found and executed, but failed. Give up. 101 | exit $st 102 | fi 103 | 104 | perl_URL=http://www.perl.org/ 105 | flex_URL=http://flex.sourceforge.net/ 106 | gnu_software_URL=http://www.gnu.org/software 107 | 108 | program_details () 109 | { 110 | case $1 in 111 | aclocal|automake) 112 | echo "The '$1' program is part of the GNU Automake package:" 113 | echo "<$gnu_software_URL/automake>" 114 | echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115 | echo "<$gnu_software_URL/autoconf>" 116 | echo "<$gnu_software_URL/m4/>" 117 | echo "<$perl_URL>" 118 | ;; 119 | autoconf|autom4te|autoheader) 120 | echo "The '$1' program is part of the GNU Autoconf package:" 121 | echo "<$gnu_software_URL/autoconf/>" 122 | echo "It also requires GNU m4 and Perl in order to run:" 123 | echo "<$gnu_software_URL/m4/>" 124 | echo "<$perl_URL>" 125 | ;; 126 | esac 127 | } 128 | 129 | give_advice () 130 | { 131 | # Normalize program name to check for. 132 | normalized_program=`echo "$1" | sed ' 133 | s/^gnu-//; t 134 | s/^gnu//; t 135 | s/^g//; t'` 136 | 137 | printf '%s\n' "'$1' is $msg." 138 | 139 | configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140 | case $normalized_program in 141 | autoconf*) 142 | echo "You should only need it if you modified 'configure.ac'," 143 | echo "or m4 files included by it." 144 | program_details 'autoconf' 145 | ;; 146 | autoheader*) 147 | echo "You should only need it if you modified 'acconfig.h' or" 148 | echo "$configure_deps." 149 | program_details 'autoheader' 150 | ;; 151 | automake*) 152 | echo "You should only need it if you modified 'Makefile.am' or" 153 | echo "$configure_deps." 154 | program_details 'automake' 155 | ;; 156 | aclocal*) 157 | echo "You should only need it if you modified 'acinclude.m4' or" 158 | echo "$configure_deps." 159 | program_details 'aclocal' 160 | ;; 161 | autom4te*) 162 | echo "You might have modified some maintainer files that require" 163 | echo "the 'autom4te' program to be rebuilt." 164 | program_details 'autom4te' 165 | ;; 166 | bison*|yacc*) 167 | echo "You should only need it if you modified a '.y' file." 168 | echo "You may want to install the GNU Bison package:" 169 | echo "<$gnu_software_URL/bison/>" 170 | ;; 171 | lex*|flex*) 172 | echo "You should only need it if you modified a '.l' file." 173 | echo "You may want to install the Fast Lexical Analyzer package:" 174 | echo "<$flex_URL>" 175 | ;; 176 | help2man*) 177 | echo "You should only need it if you modified a dependency" \ 178 | "of a man page." 179 | echo "You may want to install the GNU Help2man package:" 180 | echo "<$gnu_software_URL/help2man/>" 181 | ;; 182 | makeinfo*) 183 | echo "You should only need it if you modified a '.texi' file, or" 184 | echo "any other file indirectly affecting the aspect of the manual." 185 | echo "You might want to install the Texinfo package:" 186 | echo "<$gnu_software_URL/texinfo/>" 187 | echo "The spurious makeinfo call might also be the consequence of" 188 | echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189 | echo "want to install GNU make:" 190 | echo "<$gnu_software_URL/make/>" 191 | ;; 192 | *) 193 | echo "You might have modified some files without having the proper" 194 | echo "tools for further handling them. Check the 'README' file, it" 195 | echo "often tells you about the needed prerequisites for installing" 196 | echo "this package. You may also peek at any GNU archive site, in" 197 | echo "case some other package contains this missing '$1' program." 198 | ;; 199 | esac 200 | } 201 | 202 | give_advice "$1" | sed -e '1s/^/WARNING: /' \ 203 | -e '2,$s/^/ /' >&2 204 | 205 | # Propagate the correct exit status (expected to be 127 for a program 206 | # not found, 63 for a program that failed due to version mismatch). 207 | exit $st 208 | 209 | # Local variables: 210 | # eval: (add-hook 'write-file-hooks 'time-stamp) 211 | # time-stamp-start: "scriptversion=" 212 | # time-stamp-format: "%:y-%02m-%02d.%02H" 213 | # time-stamp-time-zone: "UTC" 214 | # time-stamp-end: "; # UTC" 215 | # End: 216 | -------------------------------------------------------------------------------- /os-daq-modules/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | bin_SCRIPTS = daq-modules-config 6 | 7 | pkglib_LTLIBRARIES = 8 | 9 | lib_LTLIBRARIES = libdaq_static_modules.la 10 | libdaq_static_modules_la_SOURCES = \ 11 | daq_static_modules.c \ 12 | daq_static_modules.h 13 | libdaq_static_modules_la_CFLAGS = 14 | libdaq_static_modules_la_LDFLAGS = -static -avoid-version 15 | libdaq_static_modules_la_LIBADD = 16 | 17 | if BUILD_AFPACKET_MODULE 18 | if BUILD_SHARED_MODULES 19 | pkglib_LTLIBRARIES += daq_afpacket.la 20 | daq_afpacket_la_SOURCES = daq_afpacket.c 21 | daq_afpacket_la_CFLAGS = -DBUILDING_SO 22 | daq_afpacket_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @XCCFLAGS@ 23 | daq_afpacket_la_LIBADD = $(top_builddir)/sfbpf/libsfbpf.la 24 | endif 25 | libdaq_static_modules_la_SOURCES += daq_afpacket.c 26 | libdaq_static_modules_la_CFLAGS += -DBUILD_AFPACKET_MODULE 27 | endif 28 | 29 | if BUILD_PCAP_MODULE 30 | if BUILD_SHARED_MODULES 31 | pkglib_LTLIBRARIES += daq_pcap.la 32 | daq_pcap_la_SOURCES = daq_pcap.c 33 | daq_pcap_la_CFLAGS = -DBUILDING_SO 34 | daq_pcap_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @XCCFLAGS@ 35 | daq_pcap_la_LIBADD = -lpcap 36 | endif 37 | libdaq_static_modules_la_SOURCES += daq_pcap.c 38 | libdaq_static_modules_la_CFLAGS += -DBUILD_PCAP_MODULE 39 | endif 40 | 41 | if BUILD_DUMP_MODULE 42 | if BUILD_SHARED_MODULES 43 | pkglib_LTLIBRARIES += daq_dump.la 44 | daq_dump_la_SOURCES = daq_dump.c 45 | daq_dump_la_CFLAGS = -DBUILDING_SO 46 | daq_dump_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @XCCFLAGS@ 47 | daq_dump_la_LIBADD = -lpcap 48 | endif 49 | libdaq_static_modules_la_SOURCES += daq_dump.c 50 | libdaq_static_modules_la_CFLAGS += -DBUILD_DUMP_MODULE 51 | endif 52 | 53 | if BUILD_IPFW_MODULE 54 | if BUILD_SHARED_MODULES 55 | pkglib_LTLIBRARIES += daq_ipfw.la 56 | daq_ipfw_la_SOURCES = daq_ipfw.c 57 | daq_ipfw_la_CFLAGS = -DBUILDING_SO 58 | daq_ipfw_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @XCCFLAGS@ 59 | daq_ipfw_la_LIBADD = $(top_builddir)/sfbpf/libsfbpf.la 60 | endif 61 | libdaq_static_modules_la_SOURCES += daq_ipfw.c 62 | libdaq_static_modules_la_CFLAGS += -DBUILD_IPFW_MODULE 63 | endif 64 | 65 | if BUILD_IPQ_MODULE 66 | if BUILD_SHARED_MODULES 67 | pkglib_LTLIBRARIES += daq_ipq.la 68 | daq_ipq_la_SOURCES = daq_ipq.c 69 | daq_ipq_la_CFLAGS = -DBUILDING_SO 70 | daq_ipq_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @DNET_LDFLAGS@ @XCCFLAGS@ 71 | daq_ipq_la_LIBADD = -lipq @DNET_LDFLAGS@ $(top_builddir)/sfbpf/libsfbpf.la 72 | endif 73 | libdaq_static_modules_la_SOURCES += daq_ipq.c 74 | libdaq_static_modules_la_CFLAGS += -DBUILD_IPQ_MODULE 75 | endif 76 | 77 | if BUILD_NFQ_MODULE 78 | if BUILD_SHARED_MODULES 79 | pkglib_LTLIBRARIES += daq_nfq.la 80 | daq_nfq_la_SOURCES = daq_nfq.c 81 | daq_nfq_la_CFLAGS = -DBUILDING_SO 82 | daq_nfq_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @DNET_LDFLAGS@ @XCCFLAGS@ 83 | daq_nfq_la_LIBADD = -lnfnetlink -lnetfilter_queue @DNET_LDFLAGS@ $(top_builddir)/sfbpf/libsfbpf.la 84 | endif 85 | libdaq_static_modules_la_SOURCES += daq_nfq.c 86 | libdaq_static_modules_la_CFLAGS += -DBUILD_NFQ_MODULE 87 | endif 88 | 89 | if BUILD_NETMAP_MODULE 90 | if BUILD_SHARED_MODULES 91 | pkglib_LTLIBRARIES += daq_netmap.la 92 | daq_netmap_la_SOURCES = daq_netmap.c 93 | daq_netmap_la_CFLAGS = -DBUILDING_SO 94 | daq_netmap_la_LDFLAGS = -module -export-dynamic -avoid-version -shared @XCCFLAGS@ 95 | daq_netmap_la_LIBADD = $(top_builddir)/sfbpf/libsfbpf.la 96 | endif 97 | libdaq_static_modules_la_SOURCES += daq_netmap.c 98 | libdaq_static_modules_la_CFLAGS += -DBUILD_NETMAP_MODULE 99 | endif 100 | 101 | AM_CPPFLAGS = -I$(top_srcdir)/api -I$(top_srcdir)/sfbpf -I$(top_builddir)/sfbpf 102 | 103 | EXTRA_DIST = daq-modules-config.in 104 | 105 | -------------------------------------------------------------------------------- /os-daq-modules/daq-modules-config.in: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # 4 | # Script to give the appropriate compiler flags and linker flags 5 | # to use when building code that uses LibDAQ modules. 6 | # 7 | 8 | prefix=@prefix@ 9 | exec_prefix=@exec_prefix@ 10 | LIBDIR=@libdir@ 11 | STATIC_LIBS="@STATIC_LIBS@" 12 | 13 | static=0 14 | show_libs=0 15 | while [ "$#" != 0 ] 16 | do 17 | case "$1" in 18 | 19 | --static) 20 | static=1 21 | ;; 22 | 23 | --libs) 24 | show_libs=1 25 | ;; 26 | 27 | esac 28 | shift 29 | done 30 | 31 | if [ "$static" = 1 ] 32 | then 33 | # 34 | # Include LIBS so that the flags include libraries containing 35 | # routines that LibDAQ uses. 36 | # 37 | if [ "$show_libs" = 1 ] ; then 38 | echo "-L$LIBDIR -ldaq_static_modules $STATIC_LIBS" 39 | fi 40 | fi 41 | -------------------------------------------------------------------------------- /os-daq-modules/daq_dump.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * 3 | * Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 4 | * Copyright (C) 2007-2013 Sourcefire, Inc. 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License Version 2 as 8 | * published by the Free Software Foundation. You may not use, modify or 9 | * distribute this program under any other version of the GNU General 10 | * Public License. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | ****************************************************************************/ 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "daq.h" 31 | #include "daq_api.h" 32 | 33 | #define DAQ_MOD_VERSION 3 34 | 35 | #define DAQ_NAME "dump" 36 | #define DAQ_TYPE (DAQ_TYPE_FILE_CAPABLE | DAQ_TYPE_INTF_CAPABLE | \ 37 | DAQ_TYPE_INLINE_CAPABLE | DAQ_TYPE_MULTI_INSTANCE) 38 | 39 | #define DAQ_DUMP_FILE "inline-out.pcap" 40 | 41 | typedef struct { 42 | // delegate most stuff to daq_pcap 43 | DAQ_Module_t* module; 44 | void* handle; 45 | 46 | // but write all output packets here 47 | pcap_dumper_t* dump; 48 | char* name; 49 | 50 | // by linking in with these 51 | DAQ_Analysis_Func_t callback; 52 | void* user; 53 | 54 | DAQ_Stats_t stats; 55 | } DumpImpl; 56 | 57 | static int dump_daq_stop(void*); 58 | 59 | static int daq_dump_get_vars ( 60 | DumpImpl* impl, DAQ_Config_t* cfg, char* errBuf, size_t errMax 61 | ) { 62 | const char* s = NULL; 63 | DAQ_Dict* entry; 64 | 65 | for ( entry = cfg->values; entry; entry = entry->next) 66 | { 67 | if ( !strcmp(entry->key, "load-mode") ) 68 | { 69 | s = entry->value; 70 | } 71 | else if ( !strcmp(entry->key, "file") ) 72 | { 73 | impl->name = strdup(entry->value); 74 | } 75 | } 76 | if ( !s ) 77 | return 1; 78 | 79 | if ( !strcasecmp(s, "read-file") ) 80 | { 81 | cfg->mode = DAQ_MODE_READ_FILE; 82 | return 1; 83 | } 84 | else if ( !strcasecmp(s, "passive") ) 85 | { 86 | cfg->mode = DAQ_MODE_PASSIVE; 87 | return 1; 88 | } 89 | else if ( !strcasecmp(s, "inline") ) 90 | { 91 | cfg->mode = DAQ_MODE_INLINE; 92 | return 1; 93 | } 94 | snprintf(errBuf, errMax, "invalid load-mode (%s)", s); 95 | return 0; 96 | } 97 | 98 | //------------------------------------------------------------------------- 99 | // constructor / destructor 100 | 101 | static int dump_daq_initialize ( 102 | const DAQ_Config_t* cfg, void** handle, char* errBuf, size_t errMax) 103 | { 104 | DumpImpl* impl; 105 | impl = calloc(1, sizeof(*impl)); 106 | DAQ_Module_t* mod = (DAQ_Module_t*)cfg->extra; 107 | DAQ_Config_t sub_cfg = *cfg; 108 | int err; 109 | 110 | if ( !impl ) 111 | { 112 | snprintf(errBuf, errMax, 113 | "%s: Couldn't allocate memory for the DAQ context", 114 | __FUNCTION__); 115 | return DAQ_ERROR_NOMEM; 116 | } 117 | if ( !mod || !(mod->type & DAQ_TYPE_FILE_CAPABLE) ) 118 | { 119 | snprintf(errBuf, errMax, "%s: no file capable daq provided", __FUNCTION__); 120 | free(impl); 121 | return DAQ_ERROR; 122 | } 123 | 124 | if ( !daq_dump_get_vars(impl, &sub_cfg, errBuf, errMax) ) 125 | { 126 | free(impl); 127 | return DAQ_ERROR; 128 | } 129 | err = mod->initialize(&sub_cfg, &impl->handle, errBuf, errMax); 130 | 131 | if ( err ) 132 | { 133 | free(impl); 134 | return err; 135 | } 136 | impl->module = mod; 137 | *handle = impl; 138 | 139 | return DAQ_SUCCESS; 140 | } 141 | 142 | static void dump_daq_shutdown (void* handle) 143 | { 144 | DumpImpl* impl = (DumpImpl*)handle; 145 | impl->module->shutdown(impl->handle); 146 | if ( impl->name ) 147 | free(impl->name); 148 | free(impl); 149 | } 150 | 151 | //------------------------------------------------------------------------- 152 | // packet processing functions: 153 | // forward all but blocks, retries and blacklists: 154 | static const int s_fwd[MAX_DAQ_VERDICT] = { 1, 0, 1, 1, 0, 1, 0 }; 155 | 156 | static DAQ_Verdict daq_dump_capture ( 157 | void* user, const DAQ_PktHdr_t* hdr, const uint8_t* pkt) 158 | { 159 | DumpImpl* impl = (DumpImpl*)user; 160 | DAQ_Verdict verdict = impl->callback(impl->user, hdr, pkt); 161 | 162 | if ( verdict >= MAX_DAQ_VERDICT ) 163 | verdict = DAQ_VERDICT_BLOCK; 164 | 165 | impl->stats.verdicts[verdict]++; 166 | 167 | if ( s_fwd[verdict] ) 168 | pcap_dump((u_char*)impl->dump, (struct pcap_pkthdr*)hdr, pkt); 169 | 170 | return verdict; 171 | } 172 | 173 | static int dump_daq_acquire ( 174 | void* handle, int cnt, DAQ_Analysis_Func_t callback, DAQ_Meta_Func_t metaback, void* user) 175 | { 176 | DumpImpl* impl = (DumpImpl*)handle; 177 | impl->callback = callback; 178 | impl->user = user; 179 | return impl->module->acquire(impl->handle, cnt, daq_dump_capture, metaback, impl); 180 | } 181 | 182 | static int dump_daq_inject ( 183 | void* handle, const DAQ_PktHdr_t* hdr, const uint8_t* data, uint32_t len, 184 | int reverse) 185 | { 186 | DumpImpl* impl = (DumpImpl*)handle; 187 | 188 | // copy the original header to get the same 189 | // timestamps but overwrite the lengths 190 | DAQ_PktHdr_t h = *hdr; 191 | 192 | h.pktlen = h.caplen = len; 193 | pcap_dump((u_char*)impl->dump, (struct pcap_pkthdr*)&h, data); 194 | 195 | if ( ferror(pcap_dump_file(impl->dump)) ) 196 | { 197 | impl->module->set_errbuf(impl->handle, "inject can't write to dump file"); 198 | return DAQ_ERROR; 199 | } 200 | impl->stats.packets_injected++; 201 | return DAQ_SUCCESS; 202 | } 203 | 204 | //------------------------------------------------------------------------- 205 | 206 | static int dump_daq_start (void* handle) 207 | { 208 | DumpImpl* impl = (DumpImpl*)handle; 209 | const char* name = impl->name ? impl->name : DAQ_DUMP_FILE; 210 | pcap_t* pcap; 211 | int dlt; 212 | int snap; 213 | 214 | int ret = impl->module->start(impl->handle); 215 | 216 | if ( ret ) 217 | return ret; 218 | 219 | dlt = impl->module->get_datalink_type(impl->handle); 220 | snap = impl->module->get_snaplen(impl->handle); 221 | 222 | pcap = pcap_open_dead(dlt, snap); 223 | 224 | impl->dump = pcap ? pcap_dump_open(pcap, name) : NULL; 225 | 226 | if ( !impl->dump ) 227 | { 228 | impl->module->stop(impl->handle); 229 | impl->module->set_errbuf(impl->handle, "can't open dump file"); 230 | return DAQ_ERROR; 231 | } 232 | pcap_close(pcap); 233 | return DAQ_SUCCESS; 234 | } 235 | 236 | static int dump_daq_stop (void* handle) 237 | { 238 | DumpImpl* impl = (DumpImpl*)handle; 239 | int err = impl->module->stop(impl->handle); 240 | 241 | if ( err ) 242 | return err; 243 | 244 | if ( impl->dump ) 245 | { 246 | pcap_dump_close(impl->dump); 247 | impl->dump = NULL; 248 | } 249 | 250 | return DAQ_SUCCESS; 251 | } 252 | 253 | //------------------------------------------------------------------------- 254 | // these methods are delegated to the pcap daq 255 | 256 | static int dump_daq_set_filter (void* handle, const char* filter) 257 | { 258 | DumpImpl* impl = (DumpImpl*)handle; 259 | return impl->module->set_filter(impl->handle, filter); 260 | } 261 | 262 | static int dump_daq_breakloop (void* handle) 263 | { 264 | DumpImpl* impl = (DumpImpl*)handle; 265 | return impl->module->breakloop(impl->handle); 266 | } 267 | 268 | static DAQ_State dump_daq_check_status (void* handle) 269 | { 270 | DumpImpl* impl = (DumpImpl*)handle; 271 | return impl->module->check_status(impl->handle); 272 | } 273 | 274 | static int dump_daq_get_stats (void* handle, DAQ_Stats_t* stats) 275 | { 276 | DumpImpl* impl = (DumpImpl*)handle; 277 | int ret = impl->module->get_stats(impl->handle, stats); 278 | int i; 279 | 280 | for ( i = 0; i < MAX_DAQ_VERDICT; i++ ) 281 | stats->verdicts[i] = impl->stats.verdicts[i]; 282 | 283 | stats->packets_injected = impl->stats.packets_injected; 284 | return ret; 285 | } 286 | 287 | static void dump_daq_reset_stats (void* handle) 288 | { 289 | DumpImpl* impl = (DumpImpl*)handle; 290 | impl->module->reset_stats(impl->handle); 291 | memset(&impl->stats, 0, sizeof(impl->stats)); 292 | } 293 | 294 | static int dump_daq_get_snaplen (void* handle) 295 | { 296 | DumpImpl* impl = (DumpImpl*)handle; 297 | return impl->module->get_snaplen(impl->handle); 298 | } 299 | 300 | static uint32_t dump_daq_get_capabilities (void* handle) 301 | { 302 | DumpImpl* impl = (DumpImpl*)handle; 303 | uint32_t caps = impl->module->get_capabilities(impl->handle); 304 | caps |= DAQ_CAPA_BLOCK | DAQ_CAPA_REPLACE | DAQ_CAPA_INJECT; 305 | return caps; 306 | } 307 | 308 | static int dump_daq_get_datalink_type (void *handle) 309 | { 310 | DumpImpl* impl = (DumpImpl*)handle; 311 | return impl->module->get_datalink_type(impl->handle); 312 | } 313 | 314 | static const char* dump_daq_get_errbuf (void* handle) 315 | { 316 | DumpImpl* impl = (DumpImpl*)handle; 317 | return impl->module->get_errbuf(impl->handle); 318 | } 319 | 320 | static void dump_daq_set_errbuf (void* handle, const char* s) 321 | { 322 | DumpImpl* impl = (DumpImpl*)handle; 323 | impl->module->set_errbuf(impl->handle, s ? s : ""); 324 | } 325 | 326 | static int dump_daq_get_device_index(void* handle, const char* device) 327 | { 328 | DumpImpl* impl = (DumpImpl*)handle; 329 | return impl->module->get_device_index(impl->handle, device); 330 | } 331 | 332 | //------------------------------------------------------------------------- 333 | 334 | #ifdef BUILDING_SO 335 | DAQ_SO_PUBLIC DAQ_Module_t DAQ_MODULE_DATA = 336 | #else 337 | DAQ_Module_t dump_daq_module_data = 338 | #endif 339 | { 340 | .api_version = DAQ_API_VERSION, 341 | .module_version = DAQ_MOD_VERSION, 342 | .name = DAQ_NAME, 343 | .type = DAQ_TYPE, 344 | .initialize = dump_daq_initialize, 345 | .set_filter = dump_daq_set_filter, 346 | .start = dump_daq_start, 347 | .acquire = dump_daq_acquire, 348 | .inject = dump_daq_inject, 349 | .breakloop = dump_daq_breakloop, 350 | .stop = dump_daq_stop, 351 | .shutdown = dump_daq_shutdown, 352 | .check_status = dump_daq_check_status, 353 | .get_stats = dump_daq_get_stats, 354 | .reset_stats = dump_daq_reset_stats, 355 | .get_snaplen = dump_daq_get_snaplen, 356 | .get_capabilities = dump_daq_get_capabilities, 357 | .get_datalink_type = dump_daq_get_datalink_type, 358 | .get_errbuf = dump_daq_get_errbuf, 359 | .set_errbuf = dump_daq_set_errbuf, 360 | .get_device_index = dump_daq_get_device_index, 361 | .modify_flow = NULL, 362 | .hup_prep = NULL, 363 | .hup_apply = NULL, 364 | .hup_post = NULL, 365 | .dp_add_dc = NULL, 366 | }; 367 | 368 | -------------------------------------------------------------------------------- /os-daq-modules/daq_static_modules.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "daq_static_modules.h" 23 | 24 | const DAQ_Module_t *static_modules[] = 25 | { 26 | #ifdef BUILD_AFPACKET_MODULE 27 | &afpacket_daq_module_data, 28 | #endif 29 | #ifdef BUILD_DUMP_MODULE 30 | &dump_daq_module_data, 31 | #endif 32 | #ifdef BUILD_IPFW_MODULE 33 | &ipfw_daq_module_data, 34 | #endif 35 | #ifdef BUILD_IPQ_MODULE 36 | &ipq_daq_module_data, 37 | #endif 38 | #ifdef BUILD_NFQ_MODULE 39 | &nfq_daq_module_data, 40 | #endif 41 | #ifdef BUILD_PCAP_MODULE 42 | &pcap_daq_module_data, 43 | #endif 44 | #ifdef BUILD_NETMAP_MODULE 45 | &netmap_daq_module_data, 46 | #endif 47 | }; 48 | const int num_static_modules = sizeof(static_modules) / sizeof(static_modules[0]); 49 | -------------------------------------------------------------------------------- /os-daq-modules/daq_static_modules.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | 24 | #ifdef BUILD_AFPACKET_MODULE 25 | extern const DAQ_Module_t afpacket_daq_module_data; 26 | #endif 27 | #ifdef BUILD_DUMP_MODULE 28 | extern const DAQ_Module_t dump_daq_module_data; 29 | #endif 30 | #ifdef BUILD_IPFW_MODULE 31 | extern const DAQ_Module_t ipfw_daq_module_data; 32 | #endif 33 | #ifdef BUILD_IPQ_MODULE 34 | extern const DAQ_Module_t ipq_daq_module_data; 35 | #endif 36 | #ifdef BUILD_NFQ_MODULE 37 | extern const DAQ_Module_t nfq_daq_module_data; 38 | #endif 39 | #ifdef BUILD_PCAP_MODULE 40 | extern const DAQ_Module_t pcap_daq_module_data; 41 | #endif 42 | #ifdef BUILD_NETMAP_MODULE 43 | extern const DAQ_Module_t netmap_daq_module_data; 44 | #endif 45 | -------------------------------------------------------------------------------- /packaging/rpm/Makefile: -------------------------------------------------------------------------------- 1 | PACKAGE_NAME?= daq 2 | 3 | VERSION?= $(shell git describe --abbrev=6 --tags HEAD --always | sed 's/-/_/g') 4 | 5 | BUILD_NUMBER?= 1 6 | 7 | MOCK_CONFIG?=default 8 | 9 | RESULT_DIR?=pkgs 10 | 11 | LATEST?=HEAD 12 | 13 | all: rpm 14 | 15 | 16 | SOURCES: 17 | mkdir -p SOURCES 18 | 19 | archive: SOURCES 20 | cd ../../ && \ 21 | git archive --prefix=$(PACKAGE_NAME)-$(VERSION)/ \ 22 | -o packaging/rpm/SOURCES/$(PACKAGE_NAME)-$(VERSION).tar.gz $(LATEST) 23 | 24 | 25 | build_prepare: archive 26 | mkdir -p $(RESULT_DIR) 27 | rm -f $(RESULT_DIR)/$(PACKAGE_NAME)*.rpm 28 | 29 | 30 | srpm: build_prepare 31 | /usr/bin/mock \ 32 | -r $(MOCK_CONFIG) \ 33 | --define "__version $(VERSION)" \ 34 | --define "__release $(BUILD_NUMBER)" \ 35 | --resultdir=$(RESULT_DIR) \ 36 | --buildsrpm \ 37 | --spec=${PACKAGE_NAME}.spec \ 38 | --sources=SOURCES 39 | @echo "======= Source RPM now available in $(RESULT_DIR) =======" 40 | 41 | rpm: srpm 42 | /usr/bin/mock \ 43 | -r $(MOCK_CONFIG) \ 44 | --define "__version $(VERSION)"\ 45 | --define "__release $(BUILD_NUMBER)"\ 46 | --resultdir=$(RESULT_DIR) \ 47 | --rebuild $(RESULT_DIR)/$(PACKAGE_NAME)*.src.rpm 48 | @echo "======= Binary RPMs now available in $(RESULT_DIR) =======" 49 | 50 | clean: 51 | rm -rf SOURCES pkgs 52 | -------------------------------------------------------------------------------- /packaging/rpm/daq.spec: -------------------------------------------------------------------------------- 1 | # Warning: 2 | # Anyone editing this spec file please make sure the same spec file 3 | # works on other fedora and epel releases, which are supported by this software. 4 | # No quick Rawhide-only fixes will be allowed. 5 | 6 | %global upstream_name daq 7 | 8 | %if 0%{?el7} 9 | # el7/{ppc64,ppc64le} Error: No Package found for libdnet-devel 10 | ExclusiveArch: x86_64 aarch64 11 | %endif 12 | 13 | Summary: Data Acquisition Library 14 | Name: daq 15 | Version: %{__version} 16 | Release: 1%{?dist} 17 | # sfbpf is BSD (various versions) 18 | License: GPLv2 and BSD 19 | URL: https://www.snort.org 20 | Source0: https://www.snort.org/downloads/snort/%{upstream_name}-%{version}.tar.gz 21 | 22 | BuildRequires: autoconf 23 | BuildRequires: automake 24 | BuildRequires: bison 25 | BuildRequires: flex 26 | BuildRequires: libtool 27 | BuildRequires: libdnet-devel 28 | BuildRequires: libpcap-devel 29 | BuildRequires: make 30 | 31 | # handle license on el{6,7}: global must be defined after the License field above 32 | %{!?_licensedir: %global license %doc} 33 | 34 | 35 | %description 36 | Snort 2.9 introduces the DAQ, or Data Acquisition library, for packet I/O. The 37 | DAQ replaces direct calls to libpcap functions with an abstraction layer that 38 | facilitates operation on a variety of hardware and software interfaces without 39 | requiring changes to Snort. 40 | 41 | 42 | %package modules 43 | Summary: Dynamic DAQ modules 44 | 45 | %description modules 46 | Dynamic DAQ modules. 47 | 48 | 49 | %package devel 50 | Summary: Development libraries and headers for %{name} 51 | Requires: %{name}%{?_isa} = %{version}-%{release} 52 | 53 | %description devel 54 | Development libraries and headers for %{name}. 55 | 56 | 57 | %prep 58 | %autosetup -n %{upstream_name}-%{version} 59 | autoreconf -ivf -Wobsolete 60 | 61 | 62 | %build 63 | %{configure} 64 | # get rid of rpath 65 | %{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool 66 | %{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool 67 | VERSION=2.0.7 %{__make} 68 | 69 | 70 | %install 71 | %{make_install} 72 | # get rid of la files 73 | #find $RPM_BUILD_ROOT -type f -name "*.la" -delete -print 74 | # get rid of static libraries 75 | #find $RPM_BUILD_ROOT -type f -name "*.a" -delete -print 76 | 77 | %ldconfig_scriptlets 78 | 79 | %files 80 | %{_libdir}/libdaq.so.2 81 | %{_libdir}/libdaq.so.2.0.4 82 | %{_libdir}/libsfbpf.so.0 83 | %{_libdir}/libsfbpf.so.0.0.1 84 | %{_libdir}/daq/daq_afpacket.la 85 | %{_libdir}/daq/daq_dump.la 86 | %{_libdir}/daq/daq_ipfw.la 87 | %{_libdir}/daq/daq_pcap.la 88 | %{_libdir}/libdaq.a 89 | %{_libdir}/libdaq.la 90 | %{_libdir}/libdaq_static.a 91 | %{_libdir}/libdaq_static.la 92 | %{_libdir}/libdaq_static_modules.a 93 | %{_libdir}/libdaq_static_modules.la 94 | %{_libdir}/libsfbpf.a 95 | %{_libdir}/libsfbpf.la 96 | %doc ChangeLog README 97 | %license COPYING 98 | 99 | 100 | %files devel 101 | %{_bindir}/daq-modules-config 102 | %{_includedir}/daq.h 103 | %{_includedir}/daq_api.h 104 | %{_includedir}/daq_common.h 105 | %{_includedir}/sfbpf.h 106 | %{_includedir}/sfbpf_dlt.h 107 | %{_libdir}/libdaq.so 108 | %{_libdir}/libsfbpf.so 109 | 110 | 111 | %files modules 112 | %dir %{_libdir}/%{name} 113 | %{_libdir}/%{name}/daq_dump.so 114 | %{_libdir}/%{name}/daq_ipfw.so 115 | %{_libdir}/%{name}/daq_pcap.so 116 | %{_libdir}/%{name}/daq_afpacket.so 117 | %license COPYING 118 | 119 | %changelog 120 | * Wed Mar 27 2024 David Vanhoucke - 2.0.7-1 121 | - update to version 2.0.7 122 | * Thu Jan 25 2024 David Vanhoucke - 2.0.4-1 123 | - initial version, based on Lawrence R. Rogers's daq.spec from forensics.cert.org 124 | -------------------------------------------------------------------------------- /sfbpf/IP6_misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that: (1) source code distributions 9 | * retain the above copyright notice and this paragraph in its entirety, (2) 10 | * distributions including binary code include the above copyright notice and 11 | * this paragraph in its entirety in the documentation or other materials 12 | * provided with the distribution, and (3) all advertising materials mentioning 13 | * features or use of this software display the following acknowledgement: 14 | * ``This product includes software developed by the University of California, 15 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16 | * the University nor the names of its contributors may be used to endorse 17 | * or promote products derived from this software without specific prior 18 | * written permission. 19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/IP6_misc.h#2 $ (LBL) 24 | */ 25 | 26 | /* 27 | * This file contains a collage of declarations for IPv6 from FreeBSD not present in Windows 28 | */ 29 | 30 | #include 31 | 32 | #include 33 | 34 | #ifndef __MINGW32__ 35 | #define IN_MULTICAST(a) IN_CLASSD(a) 36 | #endif 37 | 38 | #define IN_EXPERIMENTAL(a) ((((u_int32_t) (a)) & 0xf0000000) == 0xf0000000) 39 | 40 | #define IN_LOOPBACKNET 127 41 | 42 | #if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) 43 | /* IPv6 address */ 44 | struct in6_addr 45 | { 46 | union 47 | { 48 | u_int8_t u6_addr8[16]; 49 | u_int16_t u6_addr16[8]; 50 | u_int32_t u6_addr32[4]; 51 | } in6_u; 52 | #define s6_addr in6_u.u6_addr8 53 | #define s6_addr16 in6_u.u6_addr16 54 | #define s6_addr32 in6_u.u6_addr32 55 | #define s6_addr64 in6_u.u6_addr64 56 | }; 57 | 58 | #define IN6ADDR_ANY_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } 59 | #define IN6ADDR_LOOPBACK_INIT { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } 60 | #endif /* __MINGW32__ */ 61 | 62 | 63 | #if (defined _MSC_VER) || (defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF)) 64 | typedef unsigned short sa_family_t; 65 | #endif 66 | 67 | 68 | #if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) 69 | 70 | #define __SOCKADDR_COMMON(sa_prefix) \ 71 | sa_family_t sa_prefix##family 72 | 73 | /* Ditto, for IPv6. */ 74 | struct sockaddr_in6 75 | { 76 | __SOCKADDR_COMMON (sin6_); 77 | u_int16_t sin6_port; /* Transport layer port # */ 78 | u_int32_t sin6_flowinfo; /* IPv6 flow information */ 79 | struct in6_addr sin6_addr; /* IPv6 address */ 80 | }; 81 | 82 | #define IN6_IS_ADDR_V4MAPPED(a) \ 83 | ((((u_int32_t *) (a))[0] == 0) && (((u_int32_t *) (a))[1] == 0) && \ 84 | (((u_int32_t *) (a))[2] == htonl (0xffff))) 85 | 86 | #define IN6_IS_ADDR_MULTICAST(a) (((u_int8_t *) (a))[0] == 0xff) 87 | 88 | #define IN6_IS_ADDR_LINKLOCAL(a) \ 89 | ((((u_int32_t *) (a))[0] & htonl (0xffc00000)) == htonl (0xfe800000)) 90 | 91 | #define IN6_IS_ADDR_LOOPBACK(a) \ 92 | (((u_int32_t *) (a))[0] == 0 && ((u_int32_t *) (a))[1] == 0 && \ 93 | ((u_int32_t *) (a))[2] == 0 && ((u_int32_t *) (a))[3] == htonl (1)) 94 | #endif /* __MINGW32__ */ 95 | 96 | #define ip6_vfc ip6_ctlun.ip6_un2_vfc 97 | #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow 98 | #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen 99 | #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt 100 | #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim 101 | #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim 102 | 103 | #define nd_rd_type nd_rd_hdr.icmp6_type 104 | #define nd_rd_code nd_rd_hdr.icmp6_code 105 | #define nd_rd_cksum nd_rd_hdr.icmp6_cksum 106 | #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] 107 | 108 | /* 109 | * IPV6 extension headers 110 | */ 111 | #define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ 112 | #define IPPROTO_IPV6 41 /* IPv6 header. */ 113 | #define IPPROTO_ROUTING 43 /* IPv6 routing header */ 114 | #define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ 115 | #define IPPROTO_ESP 50 /* encapsulating security payload */ 116 | #define IPPROTO_AH 51 /* authentication header */ 117 | #define IPPROTO_ICMPV6 58 /* ICMPv6 */ 118 | #define IPPROTO_NONE 59 /* IPv6 no next header */ 119 | #define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ 120 | #define IPPROTO_PIM 103 /* Protocol Independent Multicast. */ 121 | 122 | #define IPV6_RTHDR_TYPE_0 0 123 | 124 | /* Option types and related macros */ 125 | #define IP6OPT_PAD1 0x00 /* 00 0 00000 */ 126 | #define IP6OPT_PADN 0x01 /* 00 0 00001 */ 127 | #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */ 128 | #define IP6OPT_JUMBO_LEN 6 129 | #define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 */ 130 | 131 | #define IP6OPT_RTALERT_LEN 4 132 | #define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */ 133 | #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */ 134 | #define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */ 135 | #define IP6OPT_MINLEN 2 136 | 137 | #define IP6OPT_BINDING_UPDATE 0xc6 /* 11 0 00110 */ 138 | #define IP6OPT_BINDING_ACK 0x07 /* 00 0 00111 */ 139 | #define IP6OPT_BINDING_REQ 0x08 /* 00 0 01000 */ 140 | #define IP6OPT_HOME_ADDRESS 0xc9 /* 11 0 01001 */ 141 | #define IP6OPT_EID 0x8a /* 10 0 01010 */ 142 | 143 | #define IP6OPT_TYPE(o) ((o) & 0xC0) 144 | #define IP6OPT_TYPE_SKIP 0x00 145 | #define IP6OPT_TYPE_DISCARD 0x40 146 | #define IP6OPT_TYPE_FORCEICMP 0x80 147 | #define IP6OPT_TYPE_ICMP 0xC0 148 | 149 | #define IP6OPT_MUTABLE 0x20 150 | 151 | 152 | #if defined(__MINGW32__) && defined(DEFINE_ADDITIONAL_IPV6_STUFF) 153 | #ifndef EAI_ADDRFAMILY 154 | struct addrinfo { 155 | int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ 156 | int ai_family; /* PF_xxx */ 157 | int ai_socktype; /* SOCK_xxx */ 158 | int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ 159 | size_t ai_addrlen; /* length of ai_addr */ 160 | char *ai_canonname; /* canonical name for hostname */ 161 | struct sockaddr *ai_addr; /* binary address */ 162 | struct addrinfo *ai_next; /* next structure in linked list */ 163 | }; 164 | #endif 165 | #endif /* __MINGW32__ */ 166 | -------------------------------------------------------------------------------- /sfbpf/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | 5 | lib_LTLIBRARIES = libsfbpf.la 6 | 7 | include_HEADERS = sfbpf.h sfbpf_dlt.h 8 | 9 | libsfbpf_la_SOURCES = \ 10 | arcnet.h \ 11 | atmuni31.h \ 12 | bittypes.h \ 13 | ethertype.h \ 14 | gencode.h \ 15 | ieee80211.h \ 16 | IP6_misc.h \ 17 | ipnet.h \ 18 | llc.h \ 19 | namedb.h \ 20 | nlpid.h \ 21 | ppp.h \ 22 | sfbpf.h \ 23 | sfbpf_dlt.h \ 24 | sf-redefines.h \ 25 | sf_bpf_filter.c \ 26 | sf_bpf_printer.c \ 27 | sf_gencode.c \ 28 | sf_nametoaddr.c \ 29 | sf_optimize.c \ 30 | sfbpf-int.c \ 31 | sll.h \ 32 | sunatmpos.h 33 | 34 | EXTRA_DIST = grammar.y scanner.l \ 35 | win32-stdinc.h \ 36 | sfbpf-int.h \ 37 | sfbpf-int.c \ 38 | runlex.sh 39 | 40 | nodist_libsfbpf_la_SOURCES = sf_grammar.c sf_scanner.c tokdefs.h 41 | 42 | libsfbpf_la_CFLAGS = -Dyylval=sfbpf_lval 43 | libsfbpf_la_LDFLAGS = -version-info 0:1:0 @XCCFLAGS@ 44 | 45 | # use of $@ and $< here is a GNU idiom that borks BSD 46 | sf_scanner.c: $(srcdir)/scanner.l 47 | @rm -f $(srcdir)/sf_scanner.c 48 | $(srcdir)/runlex.sh $(V_LEX) -osf_scanner.c $(srcdir)/scanner.l 49 | 50 | sf_scanner.o: sf_scanner.c tokdefs.h 51 | 52 | tokdefs.h: sf_grammar.c 53 | sf_grammar.c: $(srcdir)/grammar.y 54 | @rm -f sf_grammar.c tokdefs.h 55 | $(V_YACC) -d $(srcdir)/grammar.y 56 | mv y.tab.c sf_grammar.c 57 | mv y.tab.h tokdefs.h 58 | 59 | CLEANFILES = sf_scanner.c sf_grammar.c tokdefs.h sf_scanner.h 60 | -------------------------------------------------------------------------------- /sfbpf/arcnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1982, 1986, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. All advertising materials mentioning features or use of this software 16 | * must display the following acknowledgement: 17 | * This product includes software developed by the University of 18 | * California, Berkeley and its contributors. 19 | * 4. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * @(#) $Id: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/arcnet.h#2 $ (LBL) 36 | * 37 | * from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp 38 | */ 39 | 40 | /* RFC 1051 */ 41 | #define ARCTYPE_IP_OLD 240 /* IP protocol */ 42 | #define ARCTYPE_ARP_OLD 241 /* address resolution protocol */ 43 | 44 | /* RFC 1201 */ 45 | #define ARCTYPE_IP 212 /* IP protocol */ 46 | #define ARCTYPE_ARP 213 /* address resolution protocol */ 47 | #define ARCTYPE_REVARP 214 /* reverse addr resolution protocol */ 48 | 49 | #define ARCTYPE_ATALK 221 /* Appletalk */ 50 | #define ARCTYPE_BANIAN 247 /* Banyan Vines */ 51 | #define ARCTYPE_IPX 250 /* Novell IPX */ 52 | 53 | #define ARCTYPE_INET6 0xc4 /* IPng */ 54 | #define ARCTYPE_DIAGNOSE 0x80 /* as per ANSI/ATA 878.1 */ 55 | -------------------------------------------------------------------------------- /sfbpf/atmuni31.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 3 | * All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. All advertising materials mentioning features or use of this software 16 | * must display the following acknowledgement: 17 | * This product includes software developed by Yen Yen Lim and 18 | North Dakota State University 19 | * 4. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 26 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/atmuni31.h#2 $ (LBL) 35 | */ 36 | 37 | /* Based on UNI3.1 standard by ATM Forum */ 38 | 39 | /* ATM traffic types based on VPI=0 and (the following VCI */ 40 | #define VCI_PPC 0x05 /* Point-to-point signal msg */ 41 | #define VCI_BCC 0x02 /* Broadcast signal msg */ 42 | #define VCI_OAMF4SC 0x03 /* Segment OAM F4 flow cell */ 43 | #define VCI_OAMF4EC 0x04 /* End-to-end OAM F4 flow cell */ 44 | #define VCI_METAC 0x01 /* Meta signal msg */ 45 | #define VCI_ILMIC 0x10 /* ILMI msg */ 46 | 47 | /* Q.2931 signalling messages */ 48 | #define CALL_PROCEED 0x02 /* call proceeding */ 49 | #define CONNECT 0x07 /* connect */ 50 | #define CONNECT_ACK 0x0f /* connect_ack */ 51 | #define SETUP 0x05 /* setup */ 52 | #define RELEASE 0x4d /* release */ 53 | #define RELEASE_DONE 0x5a /* release_done */ 54 | #define RESTART 0x46 /* restart */ 55 | #define RESTART_ACK 0x4e /* restart ack */ 56 | #define STATUS 0x7d /* status */ 57 | #define STATUS_ENQ 0x75 /* status ack */ 58 | #define ADD_PARTY 0x80 /* add party */ 59 | #define ADD_PARTY_ACK 0x81 /* add party ack */ 60 | #define ADD_PARTY_REJ 0x82 /* add party rej */ 61 | #define DROP_PARTY 0x83 /* drop party */ 62 | #define DROP_PARTY_ACK 0x84 /* drop party ack */ 63 | 64 | /* Information Element Parameters in the signalling messages */ 65 | #define CAUSE 0x08 /* cause */ 66 | #define ENDPT_REF 0x54 /* endpoint reference */ 67 | #define AAL_PARA 0x58 /* ATM adaptation layer parameters */ 68 | #define TRAFF_DESCRIP 0x59 /* atm traffic descriptors */ 69 | #define CONNECT_ID 0x5a /* connection identifier */ 70 | #define QOS_PARA 0x5c /* quality of service parameters */ 71 | #define B_HIGHER 0x5d /* broadband higher layer information */ 72 | #define B_BEARER 0x5e /* broadband bearer capability */ 73 | #define B_LOWER 0x5f /* broadband lower information */ 74 | #define CALLING_PARTY 0x6c /* calling party number */ 75 | #define CALLED_PARTY 0x70 /* called party nmber */ 76 | 77 | #define Q2931 0x09 78 | 79 | /* Q.2931 signalling general messages format */ 80 | #define PROTO_POS 0 /* offset of protocol discriminator */ 81 | #define CALL_REF_POS 2 /* offset of call reference value */ 82 | #define MSG_TYPE_POS 5 /* offset of message type */ 83 | #define MSG_LEN_POS 7 /* offset of mesage length */ 84 | #define IE_BEGIN_POS 9 /* offset of first information element */ 85 | 86 | /* format of signalling messages */ 87 | #define TYPE_POS 0 88 | #define LEN_POS 2 89 | #define FIELD_BEGIN_POS 4 90 | -------------------------------------------------------------------------------- /sfbpf/bittypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 WIDE Project. 3 | * All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. Neither the name of the project nor the names of its contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | */ 31 | #ifndef _BITTYPES_H 32 | #define _BITTYPES_H 33 | 34 | #ifndef HAVE_U_INT8_T 35 | 36 | #if SIZEOF_CHAR == 1 37 | typedef unsigned char u_int8_t; 38 | typedef signed char int8_t; 39 | #elif SIZEOF_INT == 1 40 | typedef unsigned int u_int8_t; 41 | typedef signed int int8_t; 42 | #else /* XXX */ 43 | #error "there's no appropriate type for u_int8_t" 44 | #endif 45 | #define HAVE_U_INT8_T 1 46 | #define HAVE_INT8_T 1 47 | 48 | #endif /* HAVE_U_INT8_T */ 49 | 50 | #ifndef HAVE_U_INT16_T 51 | 52 | #if SIZEOF_SHORT == 2 53 | typedef unsigned short u_int16_t; 54 | typedef signed short int16_t; 55 | #elif SIZEOF_INT == 2 56 | typedef unsigned int u_int16_t; 57 | typedef signed int int16_t; 58 | #elif SIZEOF_CHAR == 2 59 | typedef unsigned char u_int16_t; 60 | typedef signed char int16_t; 61 | #else /* XXX */ 62 | #error "there's no appropriate type for u_int16_t" 63 | #endif 64 | #define HAVE_U_INT16_T 1 65 | #define HAVE_INT16_T 1 66 | 67 | #endif /* HAVE_U_INT16_T */ 68 | 69 | #ifndef HAVE_U_INT32_T 70 | 71 | #if SIZEOF_INT == 4 72 | typedef unsigned int u_int32_t; 73 | typedef signed int int32_t; 74 | #elif SIZEOF_LONG == 4 75 | typedef unsigned long u_int32_t; 76 | typedef signed long int32_t; 77 | #elif SIZEOF_SHORT == 4 78 | typedef unsigned short u_int32_t; 79 | typedef signed short int32_t; 80 | #else /* XXX */ 81 | #error "there's no appropriate type for u_int32_t" 82 | #endif 83 | #define HAVE_U_INT32_T 1 84 | #define HAVE_INT32_T 1 85 | 86 | #endif /* HAVE_U_INT32_T */ 87 | 88 | #ifndef HAVE_U_INT64_T 89 | #if SIZEOF_LONG_LONG == 8 90 | typedef unsigned long long u_int64_t; 91 | typedef long long int64_t; 92 | #elif defined(_MSC_EXTENSIONS) 93 | typedef unsigned _int64 u_int64_t; 94 | typedef _int64 int64_t; 95 | #elif SIZEOF_INT == 8 96 | typedef unsigned int u_int64_t; 97 | #elif SIZEOF_LONG == 8 98 | typedef unsigned long u_int64_t; 99 | #elif SIZEOF_SHORT == 8 100 | typedef unsigned short u_int64_t; 101 | #else /* XXX */ 102 | #error "there's no appropriate type for u_int64_t" 103 | #endif 104 | #define HAVE_U_INT64_T 1 105 | #define HAVE_INT64_T 1 106 | 107 | #endif /* HAVE_U_INT64_T */ 108 | 109 | #ifndef PRId64 110 | #ifdef _MSC_EXTENSIONS 111 | #define PRId64 "I64d" 112 | #else /* _MSC_EXTENSIONS */ 113 | #define PRId64 "lld" 114 | #endif /* _MSC_EXTENSIONS */ 115 | #endif /* PRId64 */ 116 | 117 | #ifndef PRIo64 118 | #ifdef _MSC_EXTENSIONS 119 | #define PRIo64 "I64o" 120 | #else /* _MSC_EXTENSIONS */ 121 | #define PRIo64 "llo" 122 | #endif /* _MSC_EXTENSIONS */ 123 | #endif /* PRIo64 */ 124 | 125 | #ifndef PRIx64 126 | #ifdef _MSC_EXTENSIONS 127 | #define PRIx64 "I64x" 128 | #else /* _MSC_EXTENSIONS */ 129 | #define PRIx64 "llx" 130 | #endif /* _MSC_EXTENSIONS */ 131 | #endif /* PRIx64 */ 132 | 133 | #ifndef PRIu64 134 | #ifdef _MSC_EXTENSIONS 135 | #define PRIu64 "I64u" 136 | #else /* _MSC_EXTENSIONS */ 137 | #define PRIu64 "llu" 138 | #endif /* _MSC_EXTENSIONS */ 139 | #endif /* PRIu64 */ 140 | 141 | #endif /* _BITTYPES_H */ 142 | -------------------------------------------------------------------------------- /sfbpf/ethertype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that: (1) source code distributions 9 | * retain the above copyright notice and this paragraph in its entirety, (2) 10 | * distributions including binary code include the above copyright notice and 11 | * this paragraph in its entirety in the documentation or other materials 12 | * provided with the distribution, and (3) all advertising materials mentioning 13 | * features or use of this software display the following acknowledgement: 14 | * ``This product includes software developed by the University of California, 15 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16 | * the University nor the names of its contributors may be used to endorse 17 | * or promote products derived from this software without specific prior 18 | * written permission. 19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/ethertype.h#2 $ (LBL) 24 | */ 25 | 26 | /* 27 | * Ethernet types. 28 | * 29 | * We wrap the declarations with #ifdef, so that if a file includes 30 | * , which may declare some of these, we don't 31 | * get a bunch of complaints from the C compiler about redefinitions 32 | * of these values. 33 | * 34 | * We declare all of them here so that no file has to include 35 | * if all it needs are ETHERTYPE_ values. 36 | */ 37 | 38 | #ifndef ETHERTYPE_PUP 39 | #define ETHERTYPE_PUP 0x0200 /* PUP protocol */ 40 | #endif 41 | #ifndef ETHERTYPE_IP 42 | #define ETHERTYPE_IP 0x0800 /* IP protocol */ 43 | #endif 44 | #ifndef ETHERTYPE_ARP 45 | #define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */ 46 | #endif 47 | #ifndef ETHERTYPE_REVARP 48 | #define ETHERTYPE_REVARP 0x8035 /* reverse Addr. resolution protocol */ 49 | #endif 50 | #ifndef ETHERTYPE_NS 51 | #define ETHERTYPE_NS 0x0600 52 | #endif 53 | #ifndef ETHERTYPE_SPRITE 54 | #define ETHERTYPE_SPRITE 0x0500 55 | #endif 56 | #ifndef ETHERTYPE_TRAIL 57 | #define ETHERTYPE_TRAIL 0x1000 58 | #endif 59 | #ifndef ETHERTYPE_MOPDL 60 | #define ETHERTYPE_MOPDL 0x6001 61 | #endif 62 | #ifndef ETHERTYPE_MOPRC 63 | #define ETHERTYPE_MOPRC 0x6002 64 | #endif 65 | #ifndef ETHERTYPE_DN 66 | #define ETHERTYPE_DN 0x6003 67 | #endif 68 | #ifndef ETHERTYPE_LAT 69 | #define ETHERTYPE_LAT 0x6004 70 | #endif 71 | #ifndef ETHERTYPE_SCA 72 | #define ETHERTYPE_SCA 0x6007 73 | #endif 74 | #ifndef ETHERTYPE_REVARP 75 | #define ETHERTYPE_REVARP 0x8035 76 | #endif 77 | #ifndef ETHERTYPE_LANBRIDGE 78 | #define ETHERTYPE_LANBRIDGE 0x8038 79 | #endif 80 | #ifndef ETHERTYPE_DECDNS 81 | #define ETHERTYPE_DECDNS 0x803c 82 | #endif 83 | #ifndef ETHERTYPE_DECDTS 84 | #define ETHERTYPE_DECDTS 0x803e 85 | #endif 86 | #ifndef ETHERTYPE_VEXP 87 | #define ETHERTYPE_VEXP 0x805b 88 | #endif 89 | #ifndef ETHERTYPE_VPROD 90 | #define ETHERTYPE_VPROD 0x805c 91 | #endif 92 | #ifndef ETHERTYPE_ATALK 93 | #define ETHERTYPE_ATALK 0x809b 94 | #endif 95 | #ifndef ETHERTYPE_AARP 96 | #define ETHERTYPE_AARP 0x80f3 97 | #endif 98 | #ifndef ETHERTYPE_8021Q 99 | #define ETHERTYPE_8021Q 0x8100 100 | #endif 101 | #ifndef ETHERTYPE_IPX 102 | #define ETHERTYPE_IPX 0x8137 103 | #endif 104 | #ifndef ETHERTYPE_IPV6 105 | #define ETHERTYPE_IPV6 0x86dd 106 | #endif 107 | #ifndef ETHERTYPE_MPLS 108 | #define ETHERTYPE_MPLS 0x8847 109 | #endif 110 | #ifndef ETHERTYPE_MPLS_MULTI 111 | #define ETHERTYPE_MPLS_MULTI 0x8848 112 | #endif 113 | #ifndef ETHERTYPE_PPPOED 114 | #define ETHERTYPE_PPPOED 0x8863 115 | #endif 116 | #ifndef ETHERTYPE_PPPOES 117 | #define ETHERTYPE_PPPOES 0x8864 118 | #endif 119 | #ifndef ETHERTYPE_LOOPBACK 120 | #define ETHERTYPE_LOOPBACK 0x9000 121 | #endif 122 | -------------------------------------------------------------------------------- /sfbpf/gencode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that: (1) source code distributions 9 | * retain the above copyright notice and this paragraph in its entirety, (2) 10 | * distributions including binary code include the above copyright notice and 11 | * this paragraph in its entirety in the documentation or other materials 12 | * provided with the distribution, and (3) all advertising materials mentioning 13 | * features or use of this software display the following acknowledgement: 14 | * ``This product includes software developed by the University of California, 15 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16 | * the University nor the names of its contributors may be used to endorse 17 | * or promote products derived from this software without specific prior 18 | * written permission. 19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/gencode.h#2 $ (LBL) 24 | */ 25 | 26 | /* 27 | * ATM support: 28 | * 29 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 30 | * All rights reserved. 31 | * 32 | * Redistribution and use in source and binary forms, with or without 33 | * modification, are permitted provided that the following conditions 34 | * are met: 35 | * 1. Redistributions of source code must retain the above copyright 36 | * notice, this list of conditions and the following disclaimer. 37 | * 2. Redistributions in binary form must reproduce the above copyright 38 | * notice, this list of conditions and the following disclaimer in the 39 | * documentation and/or other materials provided with the distribution. 40 | * 3. All advertising materials mentioning features or use of this software 41 | * must display the following acknowledgement: 42 | * This product includes software developed by Yen Yen Lim and 43 | * North Dakota State University 44 | * 4. The name of the author may not be used to endorse or promote products 45 | * derived from this software without specific prior written permission. 46 | * 47 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 48 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 49 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 50 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 51 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 52 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 53 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 55 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 56 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 57 | * POSSIBILITY OF SUCH DAMAGE. 58 | */ 59 | 60 | #include "sf-redefines.h" 61 | 62 | /* Address qualifiers. */ 63 | 64 | #define Q_HOST 1 65 | #define Q_NET 2 66 | #define Q_PORT 3 67 | #define Q_GATEWAY 4 68 | #define Q_PROTO 5 69 | #define Q_PROTOCHAIN 6 70 | #define Q_PORTRANGE 7 71 | 72 | /* Protocol qualifiers. */ 73 | 74 | #define Q_LINK 1 75 | #define Q_IP 2 76 | #define Q_ARP 3 77 | #define Q_RARP 4 78 | #define Q_SCTP 5 79 | #define Q_TCP 6 80 | #define Q_UDP 7 81 | #define Q_ICMP 8 82 | #define Q_IGMP 9 83 | #define Q_IGRP 10 84 | 85 | 86 | #define Q_ATALK 11 87 | #define Q_DECNET 12 88 | #define Q_LAT 13 89 | #define Q_SCA 14 90 | #define Q_MOPRC 15 91 | #define Q_MOPDL 16 92 | 93 | 94 | #define Q_IPV6 17 95 | #define Q_ICMPV6 18 96 | #define Q_AH 19 97 | #define Q_ESP 20 98 | 99 | #define Q_PIM 21 100 | #define Q_VRRP 22 101 | 102 | #define Q_AARP 23 103 | 104 | #define Q_ISO 24 105 | #define Q_ESIS 25 106 | #define Q_ISIS 26 107 | #define Q_CLNP 27 108 | 109 | #define Q_STP 28 110 | 111 | #define Q_IPX 29 112 | 113 | #define Q_NETBEUI 30 114 | 115 | /* IS-IS Levels */ 116 | #define Q_ISIS_L1 31 117 | #define Q_ISIS_L2 32 118 | /* PDU types */ 119 | #define Q_ISIS_IIH 33 120 | #define Q_ISIS_LAN_IIH 34 121 | #define Q_ISIS_PTP_IIH 35 122 | #define Q_ISIS_SNP 36 123 | #define Q_ISIS_CSNP 37 124 | #define Q_ISIS_PSNP 38 125 | #define Q_ISIS_LSP 39 126 | 127 | #define Q_RADIO 40 128 | 129 | /* Directional qualifiers. */ 130 | 131 | #define Q_SRC 1 132 | #define Q_DST 2 133 | #define Q_OR 3 134 | #define Q_AND 4 135 | #define Q_ADDR1 5 136 | #define Q_ADDR2 6 137 | #define Q_ADDR3 7 138 | #define Q_ADDR4 8 139 | 140 | #define Q_DEFAULT 0 141 | #define Q_UNDEF 255 142 | 143 | /* ATM types */ 144 | #define A_METAC 22 /* Meta signalling Circuit */ 145 | #define A_BCC 23 /* Broadcast Circuit */ 146 | #define A_OAMF4SC 24 /* Segment OAM F4 Circuit */ 147 | #define A_OAMF4EC 25 /* End-to-End OAM F4 Circuit */ 148 | #define A_SC 26 /* Signalling Circuit */ 149 | #define A_ILMIC 27 /* ILMI Circuit */ 150 | #define A_OAM 28 /* OAM cells : F4 only */ 151 | #define A_OAMF4 29 /* OAM F4 cells: Segment + End-to-end */ 152 | #define A_LANE 30 /* LANE traffic */ 153 | #define A_LLC 31 /* LLC-encapsulated traffic */ 154 | 155 | /* Based on Q.2931 signalling protocol */ 156 | #define A_SETUP 41 /* Setup message */ 157 | #define A_CALLPROCEED 42 /* Call proceeding message */ 158 | #define A_CONNECT 43 /* Connect message */ 159 | #define A_CONNECTACK 44 /* Connect Ack message */ 160 | #define A_RELEASE 45 /* Release message */ 161 | #define A_RELEASE_DONE 46 /* Release message */ 162 | 163 | /* ATM field types */ 164 | #define A_VPI 51 165 | #define A_VCI 52 166 | #define A_PROTOTYPE 53 167 | #define A_MSGTYPE 54 168 | #define A_CALLREFTYPE 55 169 | 170 | #define A_CONNECTMSG 70 /* returns Q.2931 signalling messages for 171 | establishing and destroying switched 172 | virtual connection */ 173 | #define A_METACONNECT 71 /* returns Q.2931 signalling messages for 174 | establishing and destroying predefined 175 | virtual circuits, such as broadcast 176 | circuit, oamf4 segment circuit, oamf4 177 | end-to-end circuits, ILMI circuits or 178 | connection signalling circuit. */ 179 | 180 | /* MTP2 types */ 181 | #define M_FISU 22 /* FISU */ 182 | #define M_LSSU 23 /* LSSU */ 183 | #define M_MSU 24 /* MSU */ 184 | 185 | /* MTP3 field types */ 186 | #define M_SIO 1 187 | #define M_OPC 2 188 | #define M_DPC 3 189 | #define M_SLS 4 190 | 191 | 192 | struct slist; 193 | 194 | struct stmt 195 | { 196 | int code; 197 | struct slist *jt; /*only for relative jump in block */ 198 | struct slist *jf; /*only for relative jump in block */ 199 | bpf_int32 k; 200 | }; 201 | 202 | struct slist 203 | { 204 | struct stmt s; 205 | struct slist *next; 206 | }; 207 | 208 | /* 209 | * A bit vector to represent definition sets. We assume TOT_REGISTERS 210 | * is smaller than 8*sizeof(atomset). 211 | */ 212 | typedef bpf_u_int32 atomset; 213 | #define ATOMMASK(n) (1 << (n)) 214 | #define ATOMELEM(d, n) (d & ATOMMASK(n)) 215 | 216 | /* 217 | * An unbounded set. 218 | */ 219 | typedef bpf_u_int32 *uset; 220 | 221 | /* 222 | * Total number of atomic entities, including accumulator (A) and index (X). 223 | * We treat all these guys similarly during flow analysis. 224 | */ 225 | #define N_ATOMS (BPF_MEMWORDS+2) 226 | 227 | struct edge 228 | { 229 | int id; 230 | int code; 231 | uset edom; 232 | struct block *succ; 233 | struct block *pred; 234 | struct edge *next; /* link list of incoming edges for a node */ 235 | }; 236 | 237 | struct block 238 | { 239 | int id; 240 | struct slist *stmts; /* side effect stmts */ 241 | struct stmt s; /* branch stmt */ 242 | int mark; 243 | int longjt; /* jt branch requires long jump */ 244 | int longjf; /* jf branch requires long jump */ 245 | int level; 246 | int offset; 247 | int sense; 248 | struct edge et; 249 | struct edge ef; 250 | struct block *head; 251 | struct block *link; /* link field used by optimizer */ 252 | uset dom; 253 | uset closure; 254 | struct edge *in_edges; 255 | atomset def, kill; 256 | atomset in_use; 257 | atomset out_use; 258 | int oval; 259 | int val[N_ATOMS]; 260 | }; 261 | 262 | struct arth 263 | { 264 | struct block *b; /* protocol checks */ 265 | struct slist *s; /* stmt list */ 266 | int regno; /* virtual register number of result */ 267 | }; 268 | 269 | struct qual 270 | { 271 | unsigned char addr; 272 | unsigned char proto; 273 | unsigned char dir; 274 | unsigned char pad; 275 | }; 276 | 277 | struct arth *gen_loadi(int); 278 | struct arth *gen_load(int, struct arth *, int); 279 | struct arth *gen_loadlen(void); 280 | struct arth *gen_neg(struct arth *); 281 | struct arth *gen_arth(int, struct arth *, struct arth *); 282 | 283 | void gen_and(struct block *, struct block *); 284 | void gen_or(struct block *, struct block *); 285 | void gen_not(struct block *); 286 | 287 | struct block *gen_scode(const char *, struct qual); 288 | struct block *gen_ecode(const u_char *, struct qual); 289 | struct block *gen_acode(const u_char *, struct qual); 290 | struct block *gen_mcode(const char *, const char *, int, struct qual); 291 | #ifdef INET6 292 | struct block *gen_mcode6(const char *, const char *, int, struct qual); 293 | #endif 294 | struct block *gen_ncode(const char *, bpf_u_int32, struct qual); 295 | struct block *gen_proto_abbrev(int); 296 | struct block *gen_relation(int, struct arth *, struct arth *, int); 297 | struct block *gen_less(int); 298 | struct block *gen_greater(int); 299 | struct block *gen_byteop(int, int, int); 300 | struct block *gen_broadcast(int); 301 | struct block *gen_multicast(int); 302 | struct block *gen_inbound(int); 303 | 304 | struct block *gen_vlan(int); 305 | struct block *gen_mpls(int); 306 | 307 | struct block *gen_pppoed(void); 308 | struct block *gen_pppoes(void); 309 | 310 | struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse); 311 | struct block *gen_atmtype_abbrev(int type); 312 | struct block *gen_atmmulti_abbrev(int type); 313 | 314 | struct block *gen_mtp2type_abbrev(int type); 315 | struct block *gen_mtp3field_code(int mtp3field, bpf_u_int32 jvalue, bpf_u_int32 jtype, int reverse); 316 | 317 | struct block *gen_pf_ifname(const char *); 318 | struct block *gen_pf_rnr(int); 319 | struct block *gen_pf_srnr(int); 320 | struct block *gen_pf_ruleset(char *); 321 | struct block *gen_pf_reason(int); 322 | struct block *gen_pf_action(int); 323 | struct block *gen_pf_dir(int); 324 | 325 | struct block *gen_p80211_type(int, int); 326 | struct block *gen_p80211_fcdir(int); 327 | 328 | void bpf_optimize(struct block **); 329 | #ifndef WIN32 330 | void bpf_error(const char *, ...) __attribute__ ((noreturn, format(printf, 1, 2))); 331 | #else 332 | __declspec(noreturn) void bpf_error(const char *, ...); 333 | #endif 334 | 335 | void finish_parse(struct block *); 336 | char *sdup(const char *); 337 | 338 | struct bpf_insn *icode_to_fcode(struct block *, int *); 339 | int pcap_parse(void); 340 | void lex_init(const char *); 341 | void lex_cleanup(void); 342 | void sappend(struct slist *, struct slist *); 343 | 344 | /* XXX */ 345 | #define JT(b) ((b)->et.succ) 346 | #define JF(b) ((b)->ef.succ) 347 | 348 | extern int no_optimize; 349 | -------------------------------------------------------------------------------- /sfbpf/ieee80211.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2001 Atsushi Onoe 3 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting 4 | * All rights reserved. 5 | * 6 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. The name of the author may not be used to endorse or promote products 17 | * derived from this software without specific prior written permission. 18 | * 19 | * Alternatively, this software may be distributed under the terms of the 20 | * GNU General Public License ("GPL") version 2 as published by the Free 21 | * Software Foundation. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 24 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * $FreeBSD: src/sys/net80211/ieee80211.h,v 1.10 2005/07/22 16:55:27 sam Exp $ 35 | */ 36 | #ifndef _NET80211_IEEE80211_H_ 37 | #define _NET80211_IEEE80211_H_ 38 | 39 | /* 40 | * 802.11 protocol definitions. 41 | */ 42 | 43 | #define IEEE80211_FC0_VERSION_MASK 0x03 44 | #define IEEE80211_FC0_VERSION_SHIFT 0 45 | #define IEEE80211_FC0_VERSION_0 0x00 46 | #define IEEE80211_FC0_TYPE_MASK 0x0c 47 | #define IEEE80211_FC0_TYPE_SHIFT 2 48 | #define IEEE80211_FC0_TYPE_MGT 0x00 49 | #define IEEE80211_FC0_TYPE_CTL 0x04 50 | #define IEEE80211_FC0_TYPE_DATA 0x08 51 | 52 | #define IEEE80211_FC0_SUBTYPE_MASK 0xf0 53 | #define IEEE80211_FC0_SUBTYPE_SHIFT 4 54 | /* for TYPE_MGT */ 55 | #define IEEE80211_FC0_SUBTYPE_ASSOC_REQ 0x00 56 | #define IEEE80211_FC0_SUBTYPE_ASSOC_RESP 0x10 57 | #define IEEE80211_FC0_SUBTYPE_REASSOC_REQ 0x20 58 | #define IEEE80211_FC0_SUBTYPE_REASSOC_RESP 0x30 59 | #define IEEE80211_FC0_SUBTYPE_PROBE_REQ 0x40 60 | #define IEEE80211_FC0_SUBTYPE_PROBE_RESP 0x50 61 | #define IEEE80211_FC0_SUBTYPE_BEACON 0x80 62 | #define IEEE80211_FC0_SUBTYPE_ATIM 0x90 63 | #define IEEE80211_FC0_SUBTYPE_DISASSOC 0xa0 64 | #define IEEE80211_FC0_SUBTYPE_AUTH 0xb0 65 | #define IEEE80211_FC0_SUBTYPE_DEAUTH 0xc0 66 | /* for TYPE_CTL */ 67 | #define IEEE80211_FC0_SUBTYPE_PS_POLL 0xa0 68 | #define IEEE80211_FC0_SUBTYPE_RTS 0xb0 69 | #define IEEE80211_FC0_SUBTYPE_CTS 0xc0 70 | #define IEEE80211_FC0_SUBTYPE_ACK 0xd0 71 | #define IEEE80211_FC0_SUBTYPE_CF_END 0xe0 72 | #define IEEE80211_FC0_SUBTYPE_CF_END_ACK 0xf0 73 | /* for TYPE_DATA (bit combination) */ 74 | #define IEEE80211_FC0_SUBTYPE_DATA 0x00 75 | #define IEEE80211_FC0_SUBTYPE_CF_ACK 0x10 76 | #define IEEE80211_FC0_SUBTYPE_CF_POLL 0x20 77 | #define IEEE80211_FC0_SUBTYPE_CF_ACPL 0x30 78 | #define IEEE80211_FC0_SUBTYPE_NODATA 0x40 79 | #define IEEE80211_FC0_SUBTYPE_NODATA_CF_ACK 0x50 80 | #define IEEE80211_FC0_SUBTYPE_NODATA_CF_POLL 0x60 81 | #define IEEE80211_FC0_SUBTYPE_NODATA_CF_ACPL 0x70 82 | #define IEEE80211_FC0_SUBTYPE_QOS 0x80 83 | #define IEEE80211_FC0_SUBTYPE_QOS_NULL 0xc0 84 | 85 | #define IEEE80211_FC1_DIR_MASK 0x03 86 | #define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */ 87 | #define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */ 88 | #define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */ 89 | #define IEEE80211_FC1_DIR_DSTODS 0x03 /* AP ->AP */ 90 | 91 | #define IEEE80211_FC1_MORE_FRAG 0x04 92 | #define IEEE80211_FC1_RETRY 0x08 93 | #define IEEE80211_FC1_PWR_MGT 0x10 94 | #define IEEE80211_FC1_MORE_DATA 0x20 95 | #define IEEE80211_FC1_WEP 0x40 96 | #define IEEE80211_FC1_ORDER 0x80 97 | 98 | #define IEEE80211_SEQ_FRAG_MASK 0x000f 99 | #define IEEE80211_SEQ_FRAG_SHIFT 0 100 | #define IEEE80211_SEQ_SEQ_MASK 0xfff0 101 | #define IEEE80211_SEQ_SEQ_SHIFT 4 102 | 103 | #define IEEE80211_NWID_LEN 32 104 | 105 | #define IEEE80211_QOS_TXOP 0x00ff 106 | /* bit 8 is reserved */ 107 | #define IEEE80211_QOS_ACKPOLICY 0x60 108 | #define IEEE80211_QOS_ACKPOLICY_S 5 109 | #define IEEE80211_QOS_ESOP 0x10 110 | #define IEEE80211_QOS_ESOP_S 4 111 | #define IEEE80211_QOS_TID 0x0f 112 | 113 | #define IEEE80211_MGT_SUBTYPE_NAMES { \ 114 | "assoc-req", "assoc-resp", \ 115 | "reassoc-req", "reassoc-resp", \ 116 | "probe-req", "probe-resp", \ 117 | "reserved#6", "reserved#7", \ 118 | "beacon", "atim", \ 119 | "disassoc", "auth", \ 120 | "deauth", "reserved#13", \ 121 | "reserved#14", "reserved#15" \ 122 | } 123 | 124 | #define IEEE80211_CTL_SUBTYPE_NAMES { \ 125 | "reserved#0", "reserved#1", \ 126 | "reserved#2", "reserved#3", \ 127 | "reserved#3", "reserved#5", \ 128 | "reserved#6", "reserved#7", \ 129 | "reserved#8", "reserved#9", \ 130 | "ps-poll", "rts", \ 131 | "cts", "ack", \ 132 | "cf-end", "cf-end-ack" \ 133 | } 134 | 135 | #define IEEE80211_DATA_SUBTYPE_NAMES { \ 136 | "data", "data-cf-ack", \ 137 | "data-cf-poll", "data-cf-ack-poll", \ 138 | "null", "cf-ack", \ 139 | "cf-poll", "cf-ack-poll", \ 140 | "qos-data", "qos-data-cf-ack", \ 141 | "qos-data-cf-poll", "qos-data-cf-ack-poll", \ 142 | "qos", "reserved#13", \ 143 | "qos-cf-poll", "qos-cf-ack-poll" \ 144 | } 145 | 146 | #define IEEE80211_TYPE_NAMES { "mgt", "ctl", "data", "reserved#4" } 147 | 148 | #endif /* _NET80211_IEEE80211_H_ */ 149 | -------------------------------------------------------------------------------- /sfbpf/ipnet.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * This code is derived from the Stanford/CMU enet packet filter, 8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 10 | * Berkeley Laboratory. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | */ 40 | 41 | #define IPH_AF_INET 2 /* Matches Solaris's AF_INET */ 42 | #define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */ 43 | 44 | #define IPNET_OUTBOUND 1 45 | #define IPNET_INBOUND 2 46 | -------------------------------------------------------------------------------- /sfbpf/llc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1993, 1994, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that: (1) source code distributions 9 | * retain the above copyright notice and this paragraph in its entirety, (2) 10 | * distributions including binary code include the above copyright notice and 11 | * this paragraph in its entirety in the documentation or other materials 12 | * provided with the distribution, and (3) all advertising materials mentioning 13 | * features or use of this software display the following acknowledgement: 14 | * ``This product includes software developed by the University of California, 15 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 16 | * the University nor the names of its contributors may be used to endorse 17 | * or promote products derived from this software without specific prior 18 | * written permission. 19 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 20 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 22 | * 23 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/llc.h#2 $ (LBL) 24 | */ 25 | 26 | /* 27 | * 802.2 LLC SAP values. 28 | */ 29 | 30 | #ifndef LLCSAP_NULL 31 | #define LLCSAP_NULL 0x00 32 | #endif 33 | #ifndef LLCSAP_GLOBAL 34 | #define LLCSAP_GLOBAL 0xff 35 | #endif 36 | #ifndef LLCSAP_8021B 37 | #define LLCSAP_8021B_I 0x02 38 | #endif 39 | #ifndef LLCSAP_8021B 40 | #define LLCSAP_8021B_G 0x03 41 | #endif 42 | #ifndef LLCSAP_IP 43 | #define LLCSAP_IP 0x06 44 | #endif 45 | #ifndef LLCSAP_PROWAYNM 46 | #define LLCSAP_PROWAYNM 0x0e 47 | #endif 48 | #ifndef LLCSAP_8021D 49 | #define LLCSAP_8021D 0x42 50 | #endif 51 | #ifndef LLCSAP_RS511 52 | #define LLCSAP_RS511 0x4e 53 | #endif 54 | #ifndef LLCSAP_ISO8208 55 | #define LLCSAP_ISO8208 0x7e 56 | #endif 57 | #ifndef LLCSAP_PROWAY 58 | #define LLCSAP_PROWAY 0x8e 59 | #endif 60 | #ifndef LLCSAP_SNAP 61 | #define LLCSAP_SNAP 0xaa 62 | #endif 63 | #ifndef LLCSAP_IPX 64 | #define LLCSAP_IPX 0xe0 65 | #endif 66 | #ifndef LLCSAP_NETBEUI 67 | #define LLCSAP_NETBEUI 0xf0 68 | #endif 69 | #ifndef LLCSAP_ISONS 70 | #define LLCSAP_ISONS 0xfe 71 | #endif 72 | -------------------------------------------------------------------------------- /sfbpf/namedb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1994, 1996 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. All advertising materials mentioning features or use of this software 16 | * must display the following acknowledgement: 17 | * This product includes software developed by the Computer Systems 18 | * Engineering Group at Lawrence Berkeley Laboratory. 19 | * 4. Neither the name of the University nor of the Laboratory may be used 20 | * to endorse or promote products derived from this software without 21 | * specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/namedb.h#2 $ (LBL) 36 | */ 37 | 38 | #ifndef lib_pcap_namedb_h 39 | #define lib_pcap_namedb_h 40 | 41 | #include "sf-redefines.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif 47 | 48 | /* 49 | * As returned by the pcap_next_etherent() 50 | * XXX this stuff doesn't belong in this interface, but this 51 | * library already must do name to address translation, so 52 | * on systems that don't have support for /etc/ethers, we 53 | * export these hooks since they'll 54 | */ 55 | struct pcap_etherent 56 | { 57 | u_char addr[6]; 58 | char name[122]; 59 | }; 60 | #ifndef PCAP_ETHERS_FILE 61 | #define PCAP_ETHERS_FILE "/etc/ethers" 62 | #endif 63 | struct pcap_etherent *pcap_next_etherent(FILE *); 64 | u_char *pcap_ether_hostton(const char *); 65 | u_char *pcap_ether_aton(const char *); 66 | 67 | bpf_u_int32 **pcap_nametoaddr(const char *); 68 | #ifdef INET6 69 | struct addrinfo *pcap_nametoaddrinfo(const char *); 70 | #endif 71 | bpf_u_int32 pcap_nametonetaddr(const char *); 72 | 73 | int pcap_nametoport(const char *, int *, int *); 74 | int pcap_nametoportrange(const char *, int *, int *, int *); 75 | int pcap_nametoproto(const char *); 76 | int pcap_nametoeproto(const char *); 77 | int pcap_nametollc(const char *); 78 | /* 79 | * If a protocol is unknown, PROTO_UNDEF is returned. 80 | * Also, pcap_nametoport() returns the protocol along with the port number. 81 | * If there are ambiguous entried in /etc/services (i.e. domain 82 | * can be either tcp or udp) PROTO_UNDEF is returned. 83 | */ 84 | #define PROTO_UNDEF -1 85 | 86 | /* XXX move these to pcap-int.h? */ 87 | int __pcap_atodn(const char *, bpf_u_int32 *); 88 | int __pcap_atoin(const char *, bpf_u_int32 *); 89 | u_short __pcap_nametodnaddr(const char *); 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /sfbpf/nlpid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1996 3 | * Juniper Networks, Inc. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that: (1) source code distributions 9 | * retain the above copyright notice and this paragraph in its entirety, (2) 10 | * distributions including binary code include the above copyright notice and 11 | * this paragraph in its entirety in the documentation or other materials 12 | * provided with the distribution. The name of Juniper Networks may not 13 | * be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/nlpid.h#2 $ (Juniper) 21 | */ 22 | 23 | /* Types missing from some systems */ 24 | 25 | /* 26 | * Network layer prototocol identifiers 27 | */ 28 | #ifndef ISO8473_CLNP 29 | #define ISO8473_CLNP 0x81 30 | #endif 31 | #ifndef ISO9542_ESIS 32 | #define ISO9542_ESIS 0x82 33 | #endif 34 | #ifndef ISO9542X25_ESIS 35 | #define ISO9542X25_ESIS 0x8a 36 | #endif 37 | #ifndef ISO10589_ISIS 38 | #define ISO10589_ISIS 0x83 39 | #endif 40 | /* 41 | * this does not really belong in the nlpid.h file 42 | * however we need it for generating nice 43 | * IS-IS related BPF filters 44 | */ 45 | #define ISIS_L1_LAN_IIH 15 46 | #define ISIS_L2_LAN_IIH 16 47 | #define ISIS_PTP_IIH 17 48 | #define ISIS_L1_LSP 18 49 | #define ISIS_L2_LSP 20 50 | #define ISIS_L1_CSNP 24 51 | #define ISIS_L2_CSNP 25 52 | #define ISIS_L1_PSNP 26 53 | #define ISIS_L2_PSNP 27 54 | 55 | #ifndef ISO8878A_CONS 56 | #define ISO8878A_CONS 0x84 57 | #endif 58 | #ifndef ISO10747_IDRP 59 | #define ISO10747_IDRP 0x85 60 | #endif 61 | -------------------------------------------------------------------------------- /sfbpf/ppp.h: -------------------------------------------------------------------------------- 1 | /* @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/ppp.h#2 $ (LBL) */ 2 | /* 3 | * Point to Point Protocol (PPP) RFC1331 4 | * 5 | * Copyright 1989 by Carnegie Mellon. 6 | * 7 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 8 | * 9 | * Permission to use, copy, modify, and distribute this program for any 10 | * purpose and without fee is hereby granted, provided that this copyright 11 | * and permission notice appear on all copies and supporting documentation, 12 | * the name of Carnegie Mellon not be used in advertising or publicity 13 | * pertaining to distribution of the program without specific prior 14 | * permission, and notice be given in supporting documentation that copying 15 | * and distribution is by permission of Carnegie Mellon and Stanford 16 | * University. Carnegie Mellon makes no representations about the 17 | * suitability of this software for any purpose. It is provided "as is" 18 | * without express or implied warranty. 19 | */ 20 | #define PPP_ADDRESS 0xff /* The address byte value */ 21 | #define PPP_CONTROL 0x03 /* The control byte value */ 22 | 23 | #define PPP_PPPD_IN 0x00 /* non-standard for DLT_PPP_PPPD */ 24 | #define PPP_PPPD_OUT 0x01 /* non-standard for DLT_PPP_PPPD */ 25 | 26 | /* Protocol numbers */ 27 | #define PPP_IP 0x0021 /* Raw IP */ 28 | #define PPP_OSI 0x0023 /* OSI Network Layer */ 29 | #define PPP_NS 0x0025 /* Xerox NS IDP */ 30 | #define PPP_DECNET 0x0027 /* DECnet Phase IV */ 31 | #define PPP_APPLE 0x0029 /* Appletalk */ 32 | #define PPP_IPX 0x002b /* Novell IPX */ 33 | #define PPP_VJC 0x002d /* Van Jacobson Compressed TCP/IP */ 34 | #define PPP_VJNC 0x002f /* Van Jacobson Uncompressed TCP/IP */ 35 | #define PPP_BRPDU 0x0031 /* Bridging PDU */ 36 | #define PPP_STII 0x0033 /* Stream Protocol (ST-II) */ 37 | #define PPP_VINES 0x0035 /* Banyan Vines */ 38 | #define PPP_IPV6 0x0057 /* Internet Protocol version 6 */ 39 | 40 | #define PPP_HELLO 0x0201 /* 802.1d Hello Packets */ 41 | #define PPP_LUXCOM 0x0231 /* Luxcom */ 42 | #define PPP_SNS 0x0233 /* Sigma Network Systems */ 43 | #define PPP_MPLS_UCAST 0x0281 /* rfc 3032 */ 44 | #define PPP_MPLS_MCAST 0x0283 /* rfc 3022 */ 45 | 46 | #define PPP_IPCP 0x8021 /* IP Control Protocol */ 47 | #define PPP_OSICP 0x8023 /* OSI Network Layer Control Protocol */ 48 | #define PPP_NSCP 0x8025 /* Xerox NS IDP Control Protocol */ 49 | #define PPP_DECNETCP 0x8027 /* DECnet Control Protocol */ 50 | #define PPP_APPLECP 0x8029 /* Appletalk Control Protocol */ 51 | #define PPP_IPXCP 0x802b /* Novell IPX Control Protocol */ 52 | #define PPP_STIICP 0x8033 /* Strean Protocol Control Protocol */ 53 | #define PPP_VINESCP 0x8035 /* Banyan Vines Control Protocol */ 54 | #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ 55 | #define PPP_MPLSCP 0x8281 /* rfc 3022 */ 56 | 57 | #define PPP_LCP 0xc021 /* Link Control Protocol */ 58 | #define PPP_PAP 0xc023 /* Password Authentication Protocol */ 59 | #define PPP_LQM 0xc025 /* Link Quality Monitoring */ 60 | #define PPP_CHAP 0xc223 /* Challenge Handshake Authentication Protocol */ 61 | -------------------------------------------------------------------------------- /sfbpf/runlex.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 4 | # 5 | # runlex.sh 6 | # Script to run Lex/Flex. 7 | # First argument is the (quoted) name of the command; if it's null, that 8 | # means that neither Flex nor Lex was found, so we report an error and 9 | # quit. 10 | # 11 | # @(#) $Header: /usr/cvsroot/sfeng/ims/src/libraries/daq/daq/sfbpf/runlex.sh,v 1.1 2010/04/15 19:18:35 maltizer Exp $ 12 | # 13 | 14 | # 15 | # Get the name of the command to run, and then shift to get the arguments. 16 | # 17 | if [ $# -eq 0 ] 18 | then 19 | echo "Usage: runlex [ arguments ]" 1>&2 20 | exit 1 21 | fi 22 | LEX="$1" 23 | shift 24 | 25 | # 26 | # Check whether we have Lex or Flex. 27 | # 28 | if [ -z "${LEX}" ] 29 | then 30 | echo "Neither lex nor flex was found" 1>&2 31 | exit 1 32 | fi 33 | 34 | # 35 | # Process the flags. We don't use getopt because we don't want to 36 | # embed complete knowledge of what options are supported by Lex/Flex. 37 | # 38 | flags="" 39 | outfile=lex.yy.c 40 | while [ $# -ne 0 ] 41 | do 42 | case "$1" in 43 | 44 | -o*) 45 | # 46 | # Set the output file name. 47 | # 48 | outfile=`echo "$1" | sed 's/-o\(.*\)/\1/'` 49 | ;; 50 | 51 | -*) 52 | # 53 | # Add this to the list of flags. 54 | # 55 | flags="$flags $1" 56 | ;; 57 | 58 | --|*) 59 | # 60 | # End of flags. 61 | # 62 | break 63 | ;; 64 | esac 65 | shift 66 | done 67 | 68 | # 69 | # Is it Lex, or is it Flex? 70 | # 71 | if [ "${LEX}" = flex ] 72 | then 73 | # 74 | # It's Flex. 75 | # 76 | have_flex=yes 77 | 78 | # 79 | # Does it support the --noFUNCTION options? If so, we pass 80 | # --nounput, as at least some versions that support those 81 | # options don't support disabling yyunput by defining 82 | # YY_NO_UNPUT. 83 | # 84 | if flex --help | egrep noFUNCTION >/dev/null 85 | then 86 | flags="$flags --nounput" 87 | 88 | # 89 | # Does it support -R, for generating reentrant scanners? 90 | # If so, we're not currently using that feature, but 91 | # it'll generate some unused functions anyway - and there 92 | # won't be any header file declaring them, so there'll be 93 | # defined-but-not-declared warnings. Therefore, we use 94 | # --noFUNCTION options to suppress generating those 95 | # functions. 96 | # 97 | if flex --help | egrep reentrant >/dev/null 98 | then 99 | flags="$flags --noyyget_lineno --noyyget_in --noyyget_out --noyyget_leng --noyyget_text --noyyset_lineno --noyyset_in --noyyset_out" 100 | fi 101 | fi 102 | else 103 | # 104 | # It's Lex. 105 | # 106 | have_flex=no 107 | fi 108 | 109 | # 110 | # OK, run it. 111 | # If it's lex, it doesn't support -o, so we just write to 112 | # lex.yy.c and, if it succeeds, rename it to the right name, 113 | # otherwise we remove lex.yy.c. 114 | # If it's flex, it supports -o, so we use that - flex with -P doesn't 115 | # write to lex.yy.c, it writes to a lex.{prefix from -P}.c. 116 | # 117 | if [ $have_flex = yes ] 118 | then 119 | ${LEX} $flags -o"$outfile" "$@" 120 | 121 | # 122 | # Did it succeed? 123 | # 124 | status=$? 125 | if [ $status -ne 0 ] 126 | then 127 | # 128 | # No. Exit with the failing exit status. 129 | # 130 | exit $status 131 | fi 132 | 133 | # 134 | # Flex has the annoying habit of stripping all but the last 135 | # component of the "-o" flag argument and using that as the 136 | # place to put the output. This gets in the way of building 137 | # in a directory different from the source directory. Try 138 | # to work around this. 139 | # 140 | # Is the outfile where we think it is? 141 | # 142 | outfile_base=`basename "$outfile"` 143 | if [ "$outfile_base" != "$outfile" -a \( ! -r "$outfile" \) -a -r "$outfile_base" ] 144 | then 145 | # 146 | # No, it's not, but it is in the current directory. Put it 147 | # where it's supposed to be. 148 | # 149 | mv "$outfile_base" "$outfile" 150 | 151 | # 152 | # Did that succeed? 153 | # 154 | status=$? 155 | if [ $status -ne 0 ] 156 | then 157 | # 158 | # No. Exit with the failing exit status. 159 | # 160 | exit $status 161 | fi 162 | fi 163 | else 164 | ${LEX} $flags "$@" 165 | 166 | # 167 | # Did it succeed? 168 | # 169 | status=$? 170 | if [ $status -ne 0 ] 171 | then 172 | # 173 | # No. Get rid of any lex.yy.c file we generated, and 174 | # exit with the failing exit status. 175 | # 176 | rm -f lex.yy.c 177 | exit $status 178 | fi 179 | 180 | # 181 | # OK, rename lex.yy.c to the right output file. 182 | # 183 | mv lex.yy.c "$outfile" 184 | 185 | # 186 | # Did that succeed? 187 | # 188 | status=$? 189 | if [ $status -ne 0 ] 190 | then 191 | # 192 | # No. Get rid of any lex.yy.c file we generated, and 193 | # exit with the failing exit status. 194 | # 195 | rm -f lex.yy.c 196 | exit $status 197 | fi 198 | fi 199 | 200 | # 201 | # OK, now let's generate a header file declaring the relevant functions 202 | # defined by the .c file; if the .c file is .../foo.c, the header file 203 | # will be .../foo.h. 204 | # 205 | # This works around some other Flex suckage, wherein it doesn't declare 206 | # the lex routine before defining it, causing compiler warnings. 207 | # XXX - newer versions of Flex support --header-file=, to generate the 208 | # appropriate header file. With those versions, we should use that option. 209 | # 210 | 211 | # 212 | # Get the name of the prefix; scan the source files for a %option prefix 213 | # line. We use the last one. 214 | # 215 | prefix=`sed -n 's/%option[ ][ ]*prefix="\(.*\)".*/\1/p' "$@" | tail -1` 216 | if [ ! -z "$prefix" ] 217 | then 218 | prefixline="#define yylex ${prefix}lex" 219 | fi 220 | 221 | # 222 | # Construct the name of the header file. 223 | # 224 | header_file=`dirname "$outfile"`/`basename "$outfile" .c`.h 225 | 226 | # 227 | # Spew out the declaration. 228 | # 229 | cat <$header_file 230 | /* This is generated by runlex.sh. Do not edit it. */ 231 | $prefixline 232 | #ifndef YY_DECL 233 | #define YY_DECL int yylex(void) 234 | #endif 235 | YY_DECL; 236 | EOF 237 | -------------------------------------------------------------------------------- /sfbpf/sf-redefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 4 | * Copyright (C) 2010-2013 Sourcefire, Inc. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that: (1) source code distributions 8 | * retain the above copyright notice and this paragraph in its entirety, (2) 9 | * distributions including binary code include the above copyright notice and 10 | * this paragraph in its entirety in the documentation or other materials 11 | * provided with the distribution, and (3) all advertising materials mentioning 12 | * features or use of this software display the following acknowledgement: 13 | * ``This product includes software developed by the University of California, 14 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 15 | * the University nor the names of its contributors may be used to endorse 16 | * or promote products derived from this software without specific prior 17 | * written permission. 18 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 19 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 | */ 22 | 23 | #ifndef _SF_REDEFINES 24 | #define _SF_REDEFINES 25 | 26 | #define gen_loadi sf_gen_loadi 27 | #define gen_load sf_gen_load 28 | #define gen_loadlen sf_gen_loadlen 29 | #define gen_neg sf_gen_neg 30 | #define gen_arth sf_gen_arth 31 | 32 | #define gen_and sf_gen_and 33 | #define gen_or sf_gen_or 34 | #define gen_not sf_gen_not 35 | 36 | #define gen_scode sf_gen_scode 37 | #define gen_ecode sf_gen_ecode 38 | #define gen_acode sf_gen_acode 39 | #define gen_mcode sf_gen_mcode 40 | #ifdef INET6 41 | #define gen_mcode6 sf_gen_mcode6 42 | #endif 43 | #define gen_ncode sf_gen_ncode 44 | #define gen_proto_abbrev sf_gen_proto_abbrev 45 | #define gen_relation sf_gen_relation 46 | #define gen_less sf_gen_less 47 | #define gen_greater sf_gen_greater 48 | #define gen_byteop sf_gen_byteop 49 | #define gen_broadcast sf_gen_broadcast 50 | #define gen_multicast sf_gen_multicast 51 | #define gen_inbound sf_gen_inbound 52 | 53 | #define gen_vlan sf_gen_vlan 54 | #define gen_mpls sf_gen_mpls 55 | 56 | #define gen_pppoed sf_gen_pppoed 57 | #define gen_pppoes sf_gen_pppoes 58 | 59 | #define gen_atmfield_code sf_gen_atmfield_code 60 | #define gen_atmtype_abbrev sf_gen_atmtype_abbrev 61 | #define gen_atmmulti_abbrev sf_gen_atmmulti_abbrev 62 | 63 | #define gen_mtp2type_abbrev sf_gen_mtp2type_abbrev 64 | #define gen_mtp3field_code sf_gen_mtp3field_code 65 | 66 | #define gen_pf_ifname sf_gen_pf_ifname 67 | #define gen_pf_rnr sf_gen_pf_rnr 68 | #define gen_pf_srnr sf_gen_pf_srnr 69 | #define gen_pf_ruleset sf_gen_pf_ruleset 70 | #define gen_pf_reason sf_gen_pf_reason 71 | #define gen_pf_action sf_gen_pf_action 72 | #define gen_pf_dir sf_gen_pf_dir 73 | 74 | #define gen_p80211_type sf_gen_p80211_type 75 | #define gen_p80211_fcdir sf_gen_p80211_fcdir 76 | 77 | #define gen_portop sf_gen_portop 78 | #define gen_portop6 sf_gen_portop6 79 | #define gen_portrangeop sf_gen_portrangeop 80 | #define gen_portrangeop6 sf_gen_portrangeop6 81 | #define n_errors sf_n_errors 82 | 83 | #define bpf_optimize sf_bpf_optimize 84 | #define bpf_error sf_bpf_error 85 | 86 | #define finish_parse sf_finish_parse 87 | #define sdup sf_sdup 88 | 89 | #define icode_to_fcode sf_icode_to_fcode 90 | #define lex_init sf_lex_init 91 | #define lex_cleanup sf_lex_cleanup 92 | #define sappend sf_append 93 | 94 | #define pcap_parse sfbpf_parse 95 | 96 | #define pcap_lval sfbpf_lval 97 | 98 | #define bpf_int32 sfbpf_int32 99 | #define bpf_u_int32 sfbpf_u_int32 100 | #define bpf_insn sfbpf_insn 101 | #define bpf_program sfbpf_program 102 | 103 | #define bpf_filter sfbpf_filter 104 | #define bpf_validate sfbpf_validate 105 | 106 | #define BPF_ALIGNMENT SFBPF_ALIGNMENT 107 | #define BPF_WORDALIGN SFBPF_WORDALIGN 108 | 109 | #define BPF_MAXBUFSIZE SFBPF_MAXBUFSIZE 110 | #define BPF_MINBUFSIZE SFBPF_MINBUFSIZE 111 | 112 | #define BPF_CLASS SFBPF_CLASS 113 | #define BPF_LD SFBPF_LD 114 | #define BPF_LDX SFBPF_LDX 115 | #define BPF_ST SFBPF_ST 116 | #define BPF_STX SFBPF_STX 117 | #define BPF_ALU SFBPF_ALU 118 | #define BPF_JMP SFBPF_JMP 119 | #define BPF_RET SFBPF_RET 120 | #define BPF_MISC SFBPF_MISC 121 | 122 | #define BPF_SIZE SFBPF_SIZE 123 | #define BPF_W SFBPF_W 124 | #define BPF_H SFBPF_H 125 | #define BPF_B SFBPF_B 126 | 127 | #define BPF_MODE SFBPF_MODE 128 | #define BPF_IMM SFBPF_IMM 129 | #define BPF_ABS SFBPF_ABS 130 | #define BPF_IND SFBPF_IND 131 | #define BPF_MEM SFBPF_MEM 132 | #define BPF_LEN SFBPF_LEN 133 | #define BPF_MSH SFBPF_MSH 134 | 135 | #define BPF_OP SFBPF_OP 136 | #define BPF_ADD SFBPF_ADD 137 | #define BPF_SUB SFBPF_SUB 138 | #define BPF_MUL SFBPF_MUL 139 | #define BPF_DIV SFBPF_DIV 140 | #define BPF_OR SFBPF_OR 141 | #define BPF_AND SFBPF_AND 142 | #define BPF_LSH SFBPF_LSH 143 | #define BPF_RSH SFBPF_RSH 144 | #define BPF_NEG SFBPF_NEG 145 | #define BPF_JA SFBPF_JA 146 | #define BPF_JEQ SFBPF_JEQ 147 | #define BPF_JGT SFBPF_JGT 148 | #define BPF_JGE SFBPF_JGE 149 | #define BPF_JSET SFBPF_JSET 150 | 151 | #define BPF_SRC SFBPF_SRC 152 | #define BPF_K SFBPF_K 153 | #define BPF_X SFBPF_X 154 | 155 | #define BPF_RVAL SFBPF_RVAL 156 | #define BPF_A SFBPF_A 157 | 158 | #define BPF_MISCOP SFBPF_MISCOP 159 | #define BPF_TAX SFBPF_TAX 160 | #define BPF_TXA SFBPF_TXA 161 | 162 | #define BPF_STMT SFBPF_STMT 163 | #define BPF_JUMP SFBPF_JUMP 164 | 165 | #define BPF_MEMWORDS SFBPF_MEMWORDS 166 | 167 | #define PCAP_NETMASK_UNKNOWN SFBPF_NETMASK_UNKNOWN 168 | 169 | #define pcap_compile sfbpf_compile 170 | #define pcap_compile_unsafe sfbpf_compile_unsafe 171 | #define pcap_freecode sfbpf_freecode 172 | 173 | #endif 174 | -------------------------------------------------------------------------------- /sfbpf/sf_bpf_printer.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 3 | ** Copyright (C) 2010-2013 Sourcefire, Inc. 4 | ** Author: Michael R. Altizer 5 | ** 6 | ** This program is free software; you can redistribute it and/or modify 7 | ** it under the terms of the GNU General Public License Version 2 as 8 | ** published by the Free Software Foundation. You may not use, modify or 9 | ** distribute this program under any other version of the GNU General 10 | ** Public License. 11 | ** 12 | ** This program is distributed in the hope that it will be useful, 13 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ** GNU General Public License for more details. 16 | ** 17 | ** You should have received a copy of the GNU General Public License 18 | ** along with this program; if not, write to the Free Software 19 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include "sfbpf-int.h" 30 | 31 | struct entry { 32 | uint32_t code; 33 | const char *name; 34 | }; 35 | 36 | static struct entry classes[] = { 37 | { BPF_LD , "LD "}, 38 | { BPF_LDX , "LDX "}, 39 | { BPF_ST , "ST "}, 40 | { BPF_STX , "STX "}, 41 | { BPF_ALU , "ALU "}, 42 | { BPF_JMP , "JMP "}, 43 | { BPF_RET , "RET "}, 44 | { BPF_MISC, "MISC"}, 45 | { 0, NULL } 46 | }; 47 | 48 | static struct entry ldx_sizes[] = { 49 | { BPF_W, "W"}, 50 | { BPF_H, "H"}, 51 | { BPF_B, "B"}, 52 | { 0, NULL } 53 | }; 54 | 55 | static struct entry ldx_modes[] = { 56 | { BPF_IMM, "IMM"}, 57 | { BPF_ABS, "ABS"}, 58 | { BPF_IND, "IND"}, 59 | { BPF_MEM, "MEM"}, 60 | { BPF_LEN, "LEN"}, 61 | { BPF_MSH, "MSH"}, 62 | { 0, NULL } 63 | }; 64 | 65 | static struct entry alu_ops[] = { 66 | { BPF_ADD, "ADD"}, 67 | { BPF_SUB, "SUB"}, 68 | { BPF_MUL, "MUL"}, 69 | { BPF_DIV, "DIV"}, 70 | { BPF_OR , "OR "}, 71 | { BPF_AND, "AND"}, 72 | { BPF_LSH, "LSH"}, 73 | { BPF_RSH, "RSH"}, 74 | { BPF_NEG, "NEG"}, 75 | { 0, NULL } 76 | }; 77 | 78 | static struct entry jmp_ops[] = { 79 | { BPF_JA , "JA "}, 80 | { BPF_JEQ , "JEQ "}, 81 | { BPF_JGT , "JGT "}, 82 | { BPF_JGE , "JGE "}, 83 | { BPF_JSET, "JSET"}, 84 | { 0, NULL } 85 | }; 86 | 87 | static struct entry srcs[] = { 88 | { BPF_K, "K"}, 89 | { BPF_X, "X"}, 90 | { 0, NULL } 91 | }; 92 | 93 | static struct entry rvals[] = { 94 | { BPF_K, "K"}, 95 | { BPF_X, "X"}, 96 | { BPF_A, "A"}, 97 | { 0, NULL } 98 | }; 99 | 100 | static struct entry misc_ops[] = { 101 | { BPF_TAX, "TAX"}, 102 | { BPF_TXA, "TXA"}, 103 | { 0, NULL } 104 | }; 105 | 106 | static const char *get_code_name(struct entry *table, uint32_t code) 107 | { 108 | int i; 109 | 110 | for (i = 0; table[i].name; i++) 111 | { 112 | if (code == table[i].code) 113 | return table[i].name; 114 | } 115 | return NULL; 116 | } 117 | 118 | static int get_size(uint32_t code) 119 | { 120 | code = BPF_SIZE(code); 121 | if (code == BPF_W) 122 | return 4; 123 | if (code == BPF_H) 124 | return 2; 125 | if (code == BPF_B) 126 | return 1; 127 | return 0; 128 | } 129 | 130 | static void print_ld(struct bpf_insn *inst) 131 | { 132 | printf("LD A <- "); 133 | switch (BPF_MODE(inst->code)) 134 | { 135 | case BPF_ABS: 136 | printf("P[%d:%d]", inst->k, get_size(inst->code)); 137 | break; 138 | case BPF_IND: 139 | printf("P[X+%d:%d]", inst->k, get_size(inst->code)); 140 | break; 141 | case BPF_LEN: 142 | printf("len"); 143 | break; 144 | case BPF_IMM: 145 | printf("%d", inst->k); 146 | break; 147 | case BPF_MEM: 148 | printf("M[%d]", inst->k); 149 | break; 150 | default: 151 | printf("???"); 152 | } 153 | printf("\n"); 154 | } 155 | 156 | static void print_ldx(struct bpf_insn *inst) 157 | { 158 | printf("LDX X <- "); 159 | switch (BPF_MODE(inst->code)) 160 | { 161 | case BPF_LEN: 162 | printf("len"); 163 | break; 164 | case BPF_IMM: 165 | printf("%d", inst->k); 166 | break; 167 | case BPF_MEM: 168 | printf("M[%d]", inst->k); 169 | break; 170 | case BPF_MSH: 171 | printf("4*(P[%d:1]&0xf)", inst->k); 172 | break; 173 | } 174 | printf("\n"); 175 | } 176 | 177 | static void print_alu(struct bpf_insn *inst) 178 | { 179 | const char *op; 180 | 181 | switch (BPF_OP(inst->code)) 182 | { 183 | case BPF_ADD: 184 | op = "+"; 185 | break; 186 | case BPF_SUB: 187 | op = "-"; 188 | break; 189 | case BPF_MUL: 190 | op = "*"; 191 | break; 192 | case BPF_DIV: 193 | op = "/"; 194 | break; 195 | case BPF_OR: 196 | op = "|"; 197 | break; 198 | case BPF_AND: 199 | op = "&"; 200 | break; 201 | case BPF_LSH: 202 | op = "<<"; 203 | break; 204 | case BPF_RSH: 205 | op = ">>"; 206 | break; 207 | case BPF_NEG: 208 | printf("ALU -A\n"); 209 | return; 210 | default: 211 | op = "???"; 212 | break; 213 | } 214 | printf("ALU A <- A %s \n", op); 215 | switch(BPF_SRC(inst->code)) 216 | { 217 | case BPF_K: 218 | printf("%d", inst->k); 219 | break; 220 | case BPF_X: 221 | printf("X"); 222 | break; 223 | default: 224 | printf("???"); 225 | } 226 | printf("\n"); 227 | } 228 | 229 | static void print_jmp(struct bpf_insn *inst, int line) 230 | { 231 | const char *op; 232 | 233 | switch(BPF_OP(inst->code)) 234 | { 235 | case BPF_JA: 236 | printf("JMP L%d\n", line + 1 + inst->k); 237 | return; 238 | case BPF_JEQ: 239 | op = "=="; 240 | break; 241 | case BPF_JGT: 242 | op = ">"; 243 | break; 244 | case BPF_JGE: 245 | op = ">="; 246 | break; 247 | case BPF_JSET: 248 | op = "&"; 249 | break; 250 | default: 251 | op = "???"; 252 | break; 253 | } 254 | printf("JMP (A %s ", op); 255 | switch(BPF_SRC(inst->code)) 256 | { 257 | case BPF_K: 258 | printf("%d", inst->k); 259 | break; 260 | case BPF_X: 261 | printf("X"); 262 | break; 263 | default: 264 | printf("???"); 265 | break; 266 | } 267 | printf(") ? L%d : L%d\n", line + 1 + inst->jt, line + 1 + inst->jf); 268 | } 269 | 270 | static void print_ret(struct bpf_insn *inst) 271 | { 272 | printf("RET accept "); 273 | switch (BPF_RVAL(inst->code)) 274 | { 275 | case BPF_K: 276 | printf("%d", inst->k); 277 | break; 278 | case BPF_X: 279 | printf("X"); 280 | break; 281 | case BPF_A: 282 | printf("A"); 283 | break; 284 | default: 285 | printf("???"); 286 | break; 287 | } 288 | printf(" bytes\n"); 289 | } 290 | 291 | static void print_misc(struct bpf_insn *inst) 292 | { 293 | printf("MISC "); 294 | switch (BPF_MISCOP(inst->code)) 295 | { 296 | case BPF_TAX: 297 | printf("X <- A"); 298 | break; 299 | case BPF_TXA: 300 | printf("A <- X"); 301 | break; 302 | default: 303 | printf("???"); 304 | break; 305 | } 306 | printf("\n"); 307 | } 308 | 309 | static void pretty_print_instruction(struct bpf_insn *inst, int line) 310 | { 311 | switch(BPF_CLASS(inst->code)) 312 | { 313 | case BPF_LD: 314 | print_ld(inst); 315 | break; 316 | case BPF_LDX: 317 | print_ldx(inst); 318 | break; 319 | case BPF_ST: 320 | printf("ST M[%d] <- A\n", inst->k); 321 | break; 322 | case BPF_STX: 323 | printf("STX M[%d] <- X\n", inst->k); 324 | break; 325 | case BPF_ALU: 326 | print_alu(inst); 327 | break; 328 | case BPF_JMP: 329 | print_jmp(inst, line); 330 | break; 331 | case BPF_RET: 332 | print_ret(inst); 333 | break; 334 | case BPF_MISC: 335 | print_misc(inst); 336 | break; 337 | } 338 | } 339 | 340 | static void print_instruction(struct bpf_insn *inst) 341 | { 342 | printf("%s ", get_code_name(classes, BPF_CLASS(inst->code))); 343 | switch(BPF_CLASS(inst->code)) 344 | { 345 | case BPF_LD: 346 | case BPF_LDX: 347 | printf("size=%s mode=%s\n", get_code_name(ldx_sizes, BPF_SIZE(inst->code)), get_code_name(ldx_modes, BPF_MODE(inst->code))); 348 | break; 349 | case BPF_ALU: 350 | printf("op=%s src=%s\n", get_code_name(alu_ops, BPF_OP(inst->code)), get_code_name(srcs, BPF_SRC(inst->code))); 351 | break; 352 | case BPF_JMP: 353 | printf("op=%s src=%s\n", get_code_name(jmp_ops, BPF_OP(inst->code)), get_code_name(srcs, BPF_SRC(inst->code))); 354 | break; 355 | case BPF_RET: 356 | printf("rval=%s\n", get_code_name(rvals, BPF_RVAL(inst->code))); 357 | break; 358 | case BPF_MISC: 359 | printf("op=%s\n", get_code_name(misc_ops, BPF_MISCOP(inst->code))); 360 | break; 361 | } 362 | printf(" jt=%u jf=%u k=%u\n", inst->jt, inst->jf, inst->k); 363 | } 364 | 365 | DAQ_SO_PUBLIC void sfbpf_print(struct bpf_program *fp, int verbose) 366 | { 367 | struct bpf_insn *bi; 368 | unsigned int i; 369 | 370 | printf("Printing BPF:\n"); 371 | for (i = 0; i < fp->bf_len; i++) 372 | { 373 | bi = fp->bf_insns + i; 374 | printf("%3d: ", i); 375 | if (verbose) 376 | print_instruction(bi); 377 | else 378 | pretty_print_instruction(bi, i); 379 | } 380 | } 381 | 382 | -------------------------------------------------------------------------------- /sfbpf/sfbpf-int.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * Some portions Copyright (C) 2010-2013 Sourcefire, Inc. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that: (1) source code distributions 10 | * retain the above copyright notice and this paragraph in its entirety, (2) 11 | * distributions including binary code include the above copyright notice and 12 | * this paragraph in its entirety in the documentation or other materials 13 | * provided with the distribution, and (3) all advertising materials mentioning 14 | * features or use of this software display the following acknowledgement: 15 | * ``This product includes software developed by the University of California, 16 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 17 | * the University nor the names of its contributors may be used to endorse 18 | * or promote products derived from this software without specific prior 19 | * written permission. 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 21 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 23 | */ 24 | 25 | /* 26 | * This file mostly consists of code extraced from libpcap as required by the 27 | * BPF library. It originates from multiple files in the original libpcap 28 | * distribution. 29 | */ 30 | 31 | #ifdef HAVE_CONFIG_H 32 | #include "config.h" 33 | #endif 34 | 35 | #include 36 | #ifndef WIN32 37 | #include 38 | #endif 39 | #include 40 | #include 41 | #include 42 | #include "sfbpf-int.h" 43 | #include "namedb.h" 44 | #include "gencode.h" 45 | 46 | /* 47 | * This array is designed for mapping upper and lower case letter 48 | * together for a case independent comparison. The mappings are 49 | * based upon ascii character sequences. 50 | */ 51 | static const u_char charmap[] = { 52 | (u_char) '\000', (u_char) '\001', (u_char) '\002', (u_char) '\003', 53 | (u_char) '\004', (u_char) '\005', (u_char) '\006', (u_char) '\007', 54 | (u_char) '\010', (u_char) '\011', (u_char) '\012', (u_char) '\013', 55 | (u_char) '\014', (u_char) '\015', (u_char) '\016', (u_char) '\017', 56 | (u_char) '\020', (u_char) '\021', (u_char) '\022', (u_char) '\023', 57 | (u_char) '\024', (u_char) '\025', (u_char) '\026', (u_char) '\027', 58 | (u_char) '\030', (u_char) '\031', (u_char) '\032', (u_char) '\033', 59 | (u_char) '\034', (u_char) '\035', (u_char) '\036', (u_char) '\037', 60 | (u_char) '\040', (u_char) '\041', (u_char) '\042', (u_char) '\043', 61 | (u_char) '\044', (u_char) '\045', (u_char) '\046', (u_char) '\047', 62 | (u_char) '\050', (u_char) '\051', (u_char) '\052', (u_char) '\053', 63 | (u_char) '\054', (u_char) '\055', (u_char) '\056', (u_char) '\057', 64 | (u_char) '\060', (u_char) '\061', (u_char) '\062', (u_char) '\063', 65 | (u_char) '\064', (u_char) '\065', (u_char) '\066', (u_char) '\067', 66 | (u_char) '\070', (u_char) '\071', (u_char) '\072', (u_char) '\073', 67 | (u_char) '\074', (u_char) '\075', (u_char) '\076', (u_char) '\077', 68 | (u_char) '\100', (u_char) '\141', (u_char) '\142', (u_char) '\143', 69 | (u_char) '\144', (u_char) '\145', (u_char) '\146', (u_char) '\147', 70 | (u_char) '\150', (u_char) '\151', (u_char) '\152', (u_char) '\153', 71 | (u_char) '\154', (u_char) '\155', (u_char) '\156', (u_char) '\157', 72 | (u_char) '\160', (u_char) '\161', (u_char) '\162', (u_char) '\163', 73 | (u_char) '\164', (u_char) '\165', (u_char) '\166', (u_char) '\167', 74 | (u_char) '\170', (u_char) '\171', (u_char) '\172', (u_char) '\133', 75 | (u_char) '\134', (u_char) '\135', (u_char) '\136', (u_char) '\137', 76 | (u_char) '\140', (u_char) '\141', (u_char) '\142', (u_char) '\143', 77 | (u_char) '\144', (u_char) '\145', (u_char) '\146', (u_char) '\147', 78 | (u_char) '\150', (u_char) '\151', (u_char) '\152', (u_char) '\153', 79 | (u_char) '\154', (u_char) '\155', (u_char) '\156', (u_char) '\157', 80 | (u_char) '\160', (u_char) '\161', (u_char) '\162', (u_char) '\163', 81 | (u_char) '\164', (u_char) '\165', (u_char) '\166', (u_char) '\167', 82 | (u_char) '\170', (u_char) '\171', (u_char) '\172', (u_char) '\173', 83 | (u_char) '\174', (u_char) '\175', (u_char) '\176', (u_char) '\177', 84 | (u_char) '\200', (u_char) '\201', (u_char) '\202', (u_char) '\203', 85 | (u_char) '\204', (u_char) '\205', (u_char) '\206', (u_char) '\207', 86 | (u_char) '\210', (u_char) '\211', (u_char) '\212', (u_char) '\213', 87 | (u_char) '\214', (u_char) '\215', (u_char) '\216', (u_char) '\217', 88 | (u_char) '\220', (u_char) '\221', (u_char) '\222', (u_char) '\223', 89 | (u_char) '\224', (u_char) '\225', (u_char) '\226', (u_char) '\227', 90 | (u_char) '\230', (u_char) '\231', (u_char) '\232', (u_char) '\233', 91 | (u_char) '\234', (u_char) '\235', (u_char) '\236', (u_char) '\237', 92 | (u_char) '\240', (u_char) '\241', (u_char) '\242', (u_char) '\243', 93 | (u_char) '\244', (u_char) '\245', (u_char) '\246', (u_char) '\247', 94 | (u_char) '\250', (u_char) '\251', (u_char) '\252', (u_char) '\253', 95 | (u_char) '\254', (u_char) '\255', (u_char) '\256', (u_char) '\257', 96 | (u_char) '\260', (u_char) '\261', (u_char) '\262', (u_char) '\263', 97 | (u_char) '\264', (u_char) '\265', (u_char) '\266', (u_char) '\267', 98 | (u_char) '\270', (u_char) '\271', (u_char) '\272', (u_char) '\273', 99 | (u_char) '\274', (u_char) '\275', (u_char) '\276', (u_char) '\277', 100 | (u_char) '\300', (u_char) '\341', (u_char) '\342', (u_char) '\343', 101 | (u_char) '\344', (u_char) '\345', (u_char) '\346', (u_char) '\347', 102 | (u_char) '\350', (u_char) '\351', (u_char) '\352', (u_char) '\353', 103 | (u_char) '\354', (u_char) '\355', (u_char) '\356', (u_char) '\357', 104 | (u_char) '\360', (u_char) '\361', (u_char) '\362', (u_char) '\363', 105 | (u_char) '\364', (u_char) '\365', (u_char) '\366', (u_char) '\367', 106 | (u_char) '\370', (u_char) '\371', (u_char) '\372', (u_char) '\333', 107 | (u_char) '\334', (u_char) '\335', (u_char) '\336', (u_char) '\337', 108 | (u_char) '\340', (u_char) '\341', (u_char) '\342', (u_char) '\343', 109 | (u_char) '\344', (u_char) '\345', (u_char) '\346', (u_char) '\347', 110 | (u_char) '\350', (u_char) '\351', (u_char) '\352', (u_char) '\353', 111 | (u_char) '\354', (u_char) '\355', (u_char) '\356', (u_char) '\357', 112 | (u_char) '\360', (u_char) '\361', (u_char) '\362', (u_char) '\363', 113 | (u_char) '\364', (u_char) '\365', (u_char) '\366', (u_char) '\367', 114 | (u_char) '\370', (u_char) '\371', (u_char) '\372', (u_char) '\373', 115 | (u_char) '\374', (u_char) '\375', (u_char) '\376', (u_char) '\377', 116 | }; 117 | 118 | int sfbpf_strcasecmp(const char *s1, const char *s2) 119 | { 120 | register const u_char *cm = charmap, *us1 = (const u_char *) s1, *us2 = (const u_char *) s2; 121 | 122 | while (cm[*us1] == cm[*us2++]) 123 | if (*us1++ == '\0') 124 | return (0); 125 | return (cm[*us1] - cm[*--us2]); 126 | } 127 | 128 | /* Hex digit to integer. */ 129 | static inline int xdtoi(c) 130 | register int c; 131 | { 132 | if (isdigit(c)) 133 | return c - '0'; 134 | else if (islower(c)) 135 | return c - 'a' + 10; 136 | else 137 | return c - 'A' + 10; 138 | } 139 | 140 | static inline int skip_space(f) 141 | FILE *f; 142 | { 143 | int c; 144 | 145 | do 146 | { 147 | c = getc(f); 148 | } while (isspace(c) && c != '\n'); 149 | 150 | return c; 151 | } 152 | 153 | static inline int skip_line(f) 154 | FILE *f; 155 | { 156 | int c; 157 | 158 | do 159 | c = getc(f); 160 | while (c != '\n' && c != EOF); 161 | 162 | return c; 163 | } 164 | 165 | struct pcap_etherent *pcap_next_etherent(FILE * fp) 166 | { 167 | register int c, d, i; 168 | char *bp; 169 | static struct pcap_etherent e; 170 | 171 | memset((char *) &e, 0, sizeof(e)); 172 | do 173 | { 174 | /* Find addr */ 175 | c = skip_space(fp); 176 | if (c == '\n') 177 | continue; 178 | 179 | /* If this is a comment, or first thing on line 180 | cannot be etehrnet address, skip the line. */ 181 | if (!isxdigit(c)) 182 | { 183 | c = skip_line(fp); 184 | continue; 185 | } 186 | 187 | /* must be the start of an address */ 188 | for (i = 0; i < 6; i += 1) 189 | { 190 | d = xdtoi(c); 191 | c = getc(fp); 192 | if (isxdigit(c)) 193 | { 194 | d <<= 4; 195 | d |= xdtoi(c); 196 | c = getc(fp); 197 | } 198 | e.addr[i] = d; 199 | if (c != ':') 200 | break; 201 | c = getc(fp); 202 | } 203 | if (c == EOF) 204 | break; 205 | 206 | /* Must be whitespace */ 207 | if (!isspace(c)) 208 | { 209 | c = skip_line(fp); 210 | continue; 211 | } 212 | c = skip_space(fp); 213 | 214 | /* hit end of line... */ 215 | if (c == '\n') 216 | continue; 217 | 218 | if (c == '#') 219 | { 220 | c = skip_line(fp); 221 | continue; 222 | } 223 | 224 | /* pick up name */ 225 | bp = e.name; 226 | /* Use 'd' to prevent buffer overflow. */ 227 | d = sizeof(e.name) - 1; 228 | do 229 | { 230 | *bp++ = c; 231 | c = getc(fp); 232 | } while (!isspace(c) && c != EOF && --d > 0); 233 | *bp = '\0'; 234 | 235 | /* Eat trailing junk */ 236 | if (c != '\n') 237 | (void) skip_line(fp); 238 | 239 | return &e; 240 | 241 | } while (c != EOF); 242 | 243 | return (NULL); 244 | } 245 | -------------------------------------------------------------------------------- /sfbpf/sfbpf-int.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * Some portions Copyright (C) 2010-2013 Sourcefire, Inc. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that: (1) source code distributions 10 | * retain the above copyright notice and this paragraph in its entirety, (2) 11 | * distributions including binary code include the above copyright notice and 12 | * this paragraph in its entirety in the documentation or other materials 13 | * provided with the distribution, and (3) all advertising materials mentioning 14 | * features or use of this software display the following acknowledgement: 15 | * ``This product includes software developed by the University of California, 16 | * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 17 | * the University nor the names of its contributors may be used to endorse 18 | * or promote products derived from this software without specific prior 19 | * written permission. 20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 21 | * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 23 | */ 24 | 25 | #ifndef _SFBPF_INT_H 26 | #define _SFBPF_INT_H 27 | 28 | #ifdef HAVE_VISIBILITY 29 | # define DAQ_SO_PUBLIC __attribute__ ((visibility("default"))) 30 | # define DAQ_SO_PRIVATE __attribute__ ((visibility("hidden"))) 31 | #else 32 | # define DAQ_SO_PUBLIC 33 | # define DAQ_SO_PRIVATE 34 | #endif 35 | 36 | #include "sfbpf.h" 37 | #include "sf-redefines.h" 38 | 39 | #define PCAP_ERRBUF_SIZE 256 40 | 41 | #ifndef strlcpy 42 | #define strlcpy(x, y, z) \ 43 | (strncpy((x), (y), (z)), \ 44 | ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ 45 | strlen((y))) 46 | #endif 47 | 48 | int yylex(void); 49 | int sfbpf_strcasecmp(const char *s1, const char *s2); 50 | 51 | #define SFBPF_NETMASK_UNKNOWN 0xffffffff 52 | 53 | #endif /* _SFBPF_INT_H */ 54 | -------------------------------------------------------------------------------- /sfbpf/sfbpf.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * Some portions Copyright (C) 2010-2013 Sourcefire, Inc. 7 | * 8 | * This code is derived from the Stanford/CMU enet packet filter, 9 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 10 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 11 | * Berkeley Laboratory. 12 | * 13 | * Redistribution and use in source and binary forms, with or without 14 | * modification, are permitted provided that the following conditions 15 | * are met: 16 | * 1. Redistributions of source code must retain the above copyright 17 | * notice, this list of conditions and the following disclaimer. 18 | * 2. Redistributions in binary form must reproduce the above copyright 19 | * notice, this list of conditions and the following disclaimer in the 20 | * documentation and/or other materials provided with the distribution. 21 | * 3. All advertising materials mentioning features or use of this software 22 | * must display the following acknowledgement: 23 | * This product includes software developed by the University of 24 | * California, Berkeley and its contributors. 25 | * 4. Neither the name of the University nor the names of its contributors 26 | * may be used to endorse or promote products derived from this software 27 | * without specific prior written permission. 28 | * 29 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 30 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 31 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 33 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 35 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 36 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 37 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 38 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 39 | * SUCH DAMAGE. 40 | * 41 | * @(#)bpf.h 7.1 (Berkeley) 5/7/91 42 | * 43 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/sfbpf.h#2 $ (LBL) 44 | */ 45 | 46 | /* 47 | * This is libDAQ's cut-down version of libpcap's cut-down version of bpf.h; 48 | * it includes only the stuff needed for the code generator and the userland 49 | * BPF interpreter, and the libDAQ APIs for setting filters, etc.. 50 | * 51 | * Mostly things have been renamed so as to not conflict with the original 52 | * libpcap BPF headers. 53 | * 54 | * Datalink type definitions have been extracted and placed in sfbpf_dlt.h. 55 | */ 56 | 57 | #ifndef _SFBPF_H 58 | #define _SFBPF_H 59 | 60 | #include 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* BSD style release date */ 67 | #define SFBPF_RELEASE 199606 68 | 69 | typedef int sfbpf_int32; 70 | typedef u_int sfbpf_u_int32; 71 | 72 | /* 73 | * Alignment macros. SFBPF_WORDALIGN rounds up to the next 74 | * even multiple of SFBPF_ALIGNMENT. 75 | */ 76 | #define SFBPF_ALIGNMENT sizeof(sfbpf_int32) 77 | #define SFBPF_WORDALIGN(x) (((x)+(SFBPF_ALIGNMENT-1))&~(SFBPF_ALIGNMENT-1)) 78 | 79 | #define SFBPF_MAXBUFSIZE 0x8000 80 | #define SFBPF_MINBUFSIZE 32 81 | 82 | /* 83 | * Structure for "pcap_compile()", "pcap_setfilter()", etc.. 84 | */ 85 | struct sfbpf_program { 86 | u_int bf_len; 87 | struct sfbpf_insn *bf_insns; 88 | }; 89 | 90 | /* 91 | * Struct return by BIOCVERSION. This represents the version number of 92 | * the filter language described by the instruction encodings below. 93 | * bpf understands a program iff kernel_major == filter_major && 94 | * kernel_minor >= filter_minor, that is, if the value returned by the 95 | * running kernel has the same major number and a minor number equal 96 | * equal to or less than the filter being downloaded. Otherwise, the 97 | * results are undefined, meaning an error may be returned or packets 98 | * may be accepted haphazardly. 99 | * It has nothing to do with the source code version. 100 | */ 101 | struct sfbpf_version { 102 | u_short bv_major; 103 | u_short bv_minor; 104 | }; 105 | /* Current version number of filter architecture. */ 106 | #define SFBPF_MAJOR_VERSION 1 107 | #define SFBPF_MINOR_VERSION 1 108 | 109 | #include 110 | 111 | /* 112 | * The instruction encodings. 113 | */ 114 | /* instruction classes */ 115 | #define SFBPF_CLASS(code) ((code) & 0x07) 116 | #define SFBPF_LD 0x00 117 | #define SFBPF_LDX 0x01 118 | #define SFBPF_ST 0x02 119 | #define SFBPF_STX 0x03 120 | #define SFBPF_ALU 0x04 121 | #define SFBPF_JMP 0x05 122 | #define SFBPF_RET 0x06 123 | #define SFBPF_MISC 0x07 124 | 125 | /* ld/ldx fields */ 126 | #define SFBPF_SIZE(code) ((code) & 0x18) 127 | #define SFBPF_W 0x00 128 | #define SFBPF_H 0x08 129 | #define SFBPF_B 0x10 130 | #define SFBPF_MODE(code) ((code) & 0xe0) 131 | #define SFBPF_IMM 0x00 132 | #define SFBPF_ABS 0x20 133 | #define SFBPF_IND 0x40 134 | #define SFBPF_MEM 0x60 135 | #define SFBPF_LEN 0x80 136 | #define SFBPF_MSH 0xa0 137 | 138 | /* alu/jmp fields */ 139 | #define SFBPF_OP(code) ((code) & 0xf0) 140 | #define SFBPF_ADD 0x00 141 | #define SFBPF_SUB 0x10 142 | #define SFBPF_MUL 0x20 143 | #define SFBPF_DIV 0x30 144 | #define SFBPF_OR 0x40 145 | #define SFBPF_AND 0x50 146 | #define SFBPF_LSH 0x60 147 | #define SFBPF_RSH 0x70 148 | #define SFBPF_NEG 0x80 149 | #define SFBPF_JA 0x00 150 | #define SFBPF_JEQ 0x10 151 | #define SFBPF_JGT 0x20 152 | #define SFBPF_JGE 0x30 153 | #define SFBPF_JSET 0x40 154 | #define SFBPF_SRC(code) ((code) & 0x08) 155 | #define SFBPF_K 0x00 156 | #define SFBPF_X 0x08 157 | 158 | /* ret - SFBPF_K and SFBPF_X also apply */ 159 | #define SFBPF_RVAL(code) ((code) & 0x18) 160 | #define SFBPF_A 0x10 161 | 162 | /* misc */ 163 | #define SFBPF_MISCOP(code) ((code) & 0xf8) 164 | #define SFBPF_TAX 0x00 165 | #define SFBPF_TXA 0x80 166 | 167 | /* 168 | * The instruction data structure. 169 | */ 170 | struct sfbpf_insn { 171 | u_short code; 172 | u_char jt; 173 | u_char jf; 174 | sfbpf_u_int32 k; 175 | }; 176 | 177 | /* 178 | * Macros for insn array initializers. 179 | */ 180 | #define SFBPF_STMT(code, k) { (u_short)(code), 0, 0, k } 181 | #define SFBPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k } 182 | 183 | //#if __STDC__ || defined(__cplusplus) 184 | int sfbpf_compile(int snaplen_arg, int linktype_arg, struct sfbpf_program *program, const char *buf, int optimize, sfbpf_u_int32 mask); 185 | int sfbpf_validate(const struct sfbpf_insn *f, int len); 186 | u_int sfbpf_filter(const struct sfbpf_insn *pc, const u_char *p, u_int wirelen, u_int buflen); 187 | void sfbpf_freecode(struct sfbpf_program *program); 188 | void sfbpf_print(struct sfbpf_program *fp, int verbose); 189 | /* 190 | #else 191 | int sfbpf_compile(); 192 | int sfbpf_validate(); 193 | u_int sfbpf_filter(); 194 | void sfbpf_freecode(); 195 | #endif 196 | */ 197 | /* 198 | * Number of scratch memory words (for SFBPF_LD|SFBPF_MEM and SFBPF_ST). 199 | */ 200 | #define SFBPF_MEMWORDS 16 201 | 202 | #ifdef __cplusplus 203 | } 204 | #endif 205 | 206 | #endif 207 | -------------------------------------------------------------------------------- /sfbpf/sll.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * This code is derived from the Stanford/CMU enet packet filter, 8 | * (net/enet.c) distributed as part of 4.3BSD, and code contributed 9 | * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 10 | * Berkeley Laboratory. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/sll.h#2 $ (LBL) 41 | */ 42 | 43 | /* 44 | * For captures on Linux cooked sockets, we construct a fake header 45 | * that includes: 46 | * 47 | * a 2-byte "packet type" which is one of: 48 | * 49 | * LINUX_SLL_HOST packet was sent to us 50 | * LINUX_SLL_BROADCAST packet was broadcast 51 | * LINUX_SLL_MULTICAST packet was multicast 52 | * LINUX_SLL_OTHERHOST packet was sent to somebody else 53 | * LINUX_SLL_OUTGOING packet was sent *by* us; 54 | * 55 | * a 2-byte Ethernet protocol field; 56 | * 57 | * a 2-byte link-layer type; 58 | * 59 | * a 2-byte link-layer address length; 60 | * 61 | * an 8-byte source link-layer address, whose actual length is 62 | * specified by the previous value. 63 | * 64 | * All fields except for the link-layer address are in network byte order. 65 | * 66 | * DO NOT change the layout of this structure, or change any of the 67 | * LINUX_SLL_ values below. If you must change the link-layer header 68 | * for a "cooked" Linux capture, introduce a new DLT_ type (ask 69 | * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it 70 | * a value that collides with a value already being used), and use the 71 | * new header in captures of that type, so that programs that can 72 | * handle DLT_LINUX_SLL captures will continue to handle them correctly 73 | * without any change, and so that capture files with different headers 74 | * can be told apart and programs that read them can dissect the 75 | * packets in them. 76 | */ 77 | 78 | #ifndef lib_pcap_sll_h 79 | #define lib_pcap_sll_h 80 | 81 | /* 82 | * A DLT_LINUX_SLL fake link-layer header. 83 | */ 84 | #define SLL_HDR_LEN 16 /* total header length */ 85 | #define SLL_ADDRLEN 8 /* length of address field */ 86 | 87 | #if defined (__SVR4) && defined (__sun) 88 | 89 | typedef uint8_t u_int8_t; 90 | typedef uint16_t u_int16_t; 91 | 92 | #endif /* defined (__SVR4) && defined (__sun) */ 93 | 94 | struct sll_header 95 | { 96 | u_int16_t sll_pkttype; /* packet type */ 97 | u_int16_t sll_hatype; /* link-layer address type */ 98 | u_int16_t sll_halen; /* link-layer address length */ 99 | u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ 100 | u_int16_t sll_protocol; /* protocol */ 101 | }; 102 | 103 | /* 104 | * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the 105 | * PACKET_ values on Linux, but are defined here so that they're 106 | * available even on systems other than Linux, and so that they 107 | * don't change even if the PACKET_ values change. 108 | */ 109 | #define LINUX_SLL_HOST 0 110 | #define LINUX_SLL_BROADCAST 1 111 | #define LINUX_SLL_MULTICAST 2 112 | #define LINUX_SLL_OTHERHOST 3 113 | #define LINUX_SLL_OUTGOING 4 114 | 115 | /* 116 | * The LINUX_SLL_ values for "sll_protocol"; these correspond to the 117 | * ETH_P_ values on Linux, but are defined here so that they're 118 | * available even on systems other than Linux. We assume, for now, 119 | * that the ETH_P_ values won't change in Linux; if they do, then: 120 | * 121 | * if we don't translate them in "pcap-linux.c", capture files 122 | * won't necessarily be readable if captured on a system that 123 | * defines ETH_P_ values that don't match these values; 124 | * 125 | * if we do translate them in "pcap-linux.c", that makes life 126 | * unpleasant for the BPF code generator, as the values you test 127 | * for in the kernel aren't the values that you test for when 128 | * reading a capture file, so the fixup code run on BPF programs 129 | * handed to the kernel ends up having to do more work. 130 | * 131 | * Add other values here as necessary, for handling packet types that 132 | * might show up on non-Ethernet, non-802.x networks. (Not all the ones 133 | * in the Linux "if_ether.h" will, I suspect, actually show up in 134 | * captures.) 135 | */ 136 | #define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ 137 | #define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ 138 | 139 | #endif 140 | -------------------------------------------------------------------------------- /sfbpf/sunatmpos.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997 Yen Yen Lim and North Dakota State University 3 | * All rights reserved. 4 | * 5 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 3. All advertising materials mentioning features or use of this software 16 | * must display the following acknowledgement: 17 | * This product includes software developed by Yen Yen Lim and 18 | North Dakota State University 19 | * 4. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 26 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 30 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | * POSSIBILITY OF SUCH DAMAGE. 33 | * 34 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/sunatmpos.h#2 $ (LBL) 35 | */ 36 | 37 | /* SunATM header for ATM packet */ 38 | #define SUNATM_DIR_POS 0 39 | #define SUNATM_VPI_POS 1 40 | #define SUNATM_VCI_POS 2 41 | #define SUNATM_PKT_BEGIN_POS 4 /* Start of ATM packet */ 42 | 43 | /* Protocol type values in the bottom for bits of the byte at SUNATM_DIR_POS. */ 44 | #define PT_LANE 0x01 /* LANE */ 45 | #define PT_LLC 0x02 /* LLC encapsulation */ 46 | #define PT_ILMI 0x05 /* ILMI */ 47 | #define PT_QSAAL 0x06 /* Q.SAAL */ 48 | -------------------------------------------------------------------------------- /sfbpf/win32-stdinc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) 3 | * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) 4 | * All rights reserved. 5 | * 6 | * Some Portions Copyright (C) 2014-2021 Cisco and/or its affiliates. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 3. Neither the name of the Politecnico di Torino nor the names of its 18 | * contributors may be used to endorse or promote products derived from 19 | * this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * @(#) $Header: //depot/firepower/daq-opensource/DAQ_2_0_7/sfbpf/win32-stdinc.h#2 $ (LBL) 34 | */ 35 | #ifndef win32_stdinc_h 36 | #define win32_stdinc_h 37 | 38 | #define SIZEOF_CHAR 1 39 | #define SIZEOF_SHORT 2 40 | #define SIZEOF_INT 4 41 | #ifndef _MSC_EXTENSIONS 42 | #define SIZEOF_LONG_LONG 8 43 | #endif 44 | 45 | /* 46 | * Avoids a compiler warning in case this was already defined 47 | * (someone defined _WINSOCKAPI_ when including 'windows.h', in order 48 | * to prevent it from including 'winsock.h') 49 | */ 50 | #ifdef _WINSOCKAPI_ 51 | #undef _WINSOCKAPI_ 52 | #endif 53 | #include 54 | 55 | #include 56 | 57 | #include "bittypes.h" 58 | #include 59 | #include 60 | 61 | #ifndef __MINGW32__ 62 | #include "IP6_misc.h" 63 | #endif 64 | 65 | #define caddr_t char* 66 | 67 | #if _MSC_VER < 1500 68 | #define snprintf _snprintf 69 | #define vsnprintf _vsnprintf 70 | #define strdup _strdup 71 | #endif 72 | 73 | #define inline __inline 74 | 75 | #ifdef __MINGW32__ 76 | #include 77 | #else /*__MINGW32__*/ 78 | /* MSVC compiler */ 79 | #ifndef _UINTPTR_T_DEFINED 80 | #ifdef _WIN64 81 | typedef unsigned __int64 uintptr_t; 82 | #else 83 | typedef _W64 unsigned int uintptr_t; 84 | #endif 85 | #define _UINTPTR_T_DEFINED 86 | #endif 87 | 88 | #ifndef _INTPTR_T_DEFINED 89 | #ifdef _WIN64 90 | typedef __int64 intptr_t; 91 | #else 92 | typedef _W64 int intptr_t; 93 | #endif 94 | #define _INTPTR_T_DEFINED 95 | #endif 96 | 97 | #endif /*__MINGW32__*/ 98 | #endif /* win32_stdinc_h */ 99 | --------------------------------------------------------------------------------