Changeset 5cdb37d for libpacketdump
- Timestamp:
- 02/13/19 10:32:17 (2 years ago)
- Branches:
- develop
- Children:
- 33c9a91, fc85f33
- Parents:
- 1c3f8d2 (diff), 4e5a51f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Shane Alcock <salcock@…> (02/13/19 10:32:17)
- git-committer:
- GitHub <noreply@…> (02/13/19 10:32:17)
- Location:
- libpacketdump
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libpacketdump/Makefile.am
r055a2c9 rd0f25d4 61 61 TXT_PROTOCOLS+=link_17.protocol 62 62 63 #22: ERF META 64 BIN_PROTOCOLS+=link_21.la 65 63 66 # 22: ETSI LI 64 67 if HAVE_WANDDER 65 68 BIN_PROTOCOLS+=link_22.la 66 69 endif 70 71 #23: PCAPNG 72 BIN_PROTOCOLS+=link_23.la 67 73 68 74 # Decoders for various ethertypes (in decimal) … … 140 146 link_11_la_LDFLAGS=$(modflags) 141 147 link_15_la_LDFLAGS=$(modflags) 148 link_21_la_LDFLAGS=$(modflags) 142 149 if HAVE_WANDDER 143 150 link_22_la_LDFLAGS=$(modflags) 144 151 endif 152 link_23_la_LDFLAGS=$(modflags) 145 153 eth_0_la_LDFLAGS=$(modflags) 146 154 eth_2048_la_LDFLAGS=$(modflags) -
libpacketdump/libpacketdump.cc
r8b49230 r23741ec5 41 41 #ifdef HAVE_NETINET_IF_ETHER_H 42 42 # include <netinet/if_ether.h> 43 #endif 43 #endif 44 44 #include <dlfcn.h> 45 45 #include <map> … … 57 57 58 58 typedef void (*decode_norm_t)(uint16_t type,const char *packet,int len); 59 typedef void (*decode_norm_meta)(uint16_t type,const char *packet,int len,libtrace_packet_t *p); 59 60 typedef void (*decode_parser_t)(uint16_t type,const char *packet,int len, element_t* el); 61 62 libtrace_packet_t *p; 60 63 61 64 typedef union decode_funcs { 62 65 decode_norm_t decode_n; 66 decode_norm_meta decode_meta; 63 67 decode_parser_t decode_p; 64 68 } decode_funcs_t; … … 130 134 (int)trace_get_wire_length(packet), 131 135 (int)trace_get_direction(packet)); 132 133 136 134 137 formatted_hexdump(pkt_ptr, (int)length); … … 138 141 void trace_dump_packet(struct libtrace_packet_t *packet) 139 142 { 143 p = packet; 144 140 145 time_t sec = (time_t)trace_get_seconds(packet); 141 146 libtrace_linktype_t linktype; 142 147 uint32_t length; 143 148 const char *link=(char *)trace_get_packet_buffer(packet,&linktype,NULL); 144 149 145 150 length = trace_get_capture_length(packet); 146 147 151 printf("\n%s",ctime(&sec)); 148 152 printf(" Capture: Packet Length: %i/%i Direction Value: %i\n", … … 150 154 (int)trace_get_wire_length(packet), 151 155 (int)trace_get_direction(packet)); 156 152 157 if (!link) 153 158 printf(" [No link layer available]\n"); 154 159 else 155 decode_next(link,length, "link", 156 linktype); 160 decode_next(link,length, "link", linktype); 157 161 } 158 162 … … 223 227 hdl = open_so_decoder(sname.c_str(),type); 224 228 if (hdl) { 225 void *s=dlsym(hdl,"decode"); 229 230 /* PCAPNG format requires the libtrace_packet_t structure in order 231 * to determine the byte ordering */ 232 void *s; 233 if (type == TRACE_TYPE_PCAPNG_META || type == TRACE_TYPE_ERF_META) { 234 s=dlsym(hdl,"decode_meta"); 235 if (s) { func->decode_meta = (decode_norm_meta)s; } 236 } else { 237 s=dlsym(hdl,"decode"); 238 if (s) { func->decode_n = (decode_norm_t)s; } 239 } 240 226 241 if (s) { 227 // use the shared library228 func->decode_n = (decode_norm_t)s;229 242 dec.style = DECODE_NORMAL; 230 243 dec.el = NULL; … … 294 307 { 295 308 case DECODE_NORMAL: 296 decoders[sname][type].func->decode_n(type,packet,len); 309 /* If this is a pcapng packet call the correct function and pass the 310 * libtrace_packet_t structure. We need this to determine the byte ordering */ 311 if (type == TRACE_TYPE_PCAPNG_META || type == TRACE_TYPE_ERF_META) { 312 decoders[sname][type].func->decode_meta(type,packet,len,p); 313 } else { 314 decoders[sname][type].func->decode_n(type,packet,len); 315 } 297 316 break; 298 317 -
libpacketdump/libpacketdump.h
r6654714 rd0f25d4 55 55 56 56 void decode(int link_type, const char *pkt, unsigned len); 57 void decode_meta(int link_type, const char *pkt, unsigned len, libtrace_packet_t *p); 57 58 58 59 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.