Changeset 1841
- Timestamp:
- 04/25/07 20:43:14 (21 months ago)
- Location:
- trunk/src/tcpedit
- Files:
-
- 21 modified
-
plugins/dlt_en10mb/en10mb.c (modified) (4 diffs)
-
plugins/dlt_en10mb/en10mb.h (modified) (2 diffs)
-
plugins/dlt_hdlc/hdlc.c (modified) (3 diffs)
-
plugins/dlt_hdlc/hdlc.h (modified) (2 diffs)
-
plugins/dlt_ieee80211/ieee80211.c (modified) (4 diffs)
-
plugins/dlt_ieee80211/ieee80211.h (modified) (1 diff)
-
plugins/dlt_linuxsll/linuxsll.c (modified) (3 diffs)
-
plugins/dlt_linuxsll/linuxsll.h (modified) (2 diffs)
-
plugins/dlt_loop/loop.c (modified) (3 diffs)
-
plugins/dlt_null/null.c (modified) (2 diffs)
-
plugins/dlt_null/null.h (modified) (2 diffs)
-
plugins/dlt_plugins-int.h (modified) (3 diffs)
-
plugins/dlt_plugins.h (modified) (2 diffs)
-
plugins/dlt_raw/raw.c (modified) (3 diffs)
-
plugins/dlt_raw/raw.h (modified) (2 diffs)
-
plugins/dlt_template/plugin.c (modified) (4 diffs)
-
plugins/dlt_template/plugin.h (modified) (2 diffs)
-
plugins/dlt_user/user.c (modified) (3 diffs)
-
plugins/dlt_user/user.h (modified) (2 diffs)
-
tcpedit.c (modified) (3 diffs)
-
tcpedit.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tcpedit/plugins/dlt_en10mb/en10mb.c
r1829 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 91 91 plugin->plugin_get_layer3 = dlt_en10mb_get_layer3; 92 92 plugin->plugin_merge_layer3 = dlt_en10mb_merge_layer3; 93 93 plugin->plugin_get_mac = dlt_en10mb_get_mac; 94 94 95 /* add it to the available plugin list */ 95 96 return tcpedit_dlt_addplugin(ctx, plugin); … … 342 343 343 344 int newl2len; 344 u_char tmpbuff[MAXPACKET];345 345 346 346 assert(ctx); … … 567 567 } 568 568 569 /* 570 * return a static pointer to the source/destination MAC address 571 * return NULL on error/address doesn't exist 572 */ 573 u_char * 574 dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 575 { 576 assert(ctx); 577 assert(packet); 578 assert(pktlen); 579 580 /* FIXME: return a ptr to the source or dest mac address. */ 581 switch(mac) { 582 case SRC_MAC: 583 memcpy(ctx->srcmac, &packet[6], ETHER_ADDR_LEN); 584 return(ctx->srcmac); 585 break; 586 587 case DST_MAC: 588 memcpy(ctx->dstmac, packet, ETHER_ADDR_LEN); 589 return(ctx->dstmac); 590 break; 591 592 default: 593 errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); 594 } 595 return(NULL); 596 } 597 569 598 /* 570 599 * return the length of the L2 header of the current packet -
trunk/src/tcpedit/plugins/dlt_en10mb/en10mb.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 47 47 u_char *dlt_en10mb_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); 48 48 int dlt_en10mb_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 49 49 u_char *dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 50 51 51 tcpeditdlt_l2addr_type_t dlt_en10mb_l2addr_type(void); -
trunk/src/tcpedit/plugins/dlt_hdlc/hdlc.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 89 89 plugin->plugin_get_layer3 = dlt_hdlc_get_layer3; 90 90 plugin->plugin_merge_layer3 = dlt_hdlc_merge_layer3; 91 91 plugin->plugin_get_mac = dlt_hdlc_get_mac; 92 92 93 /* add it to the available plugin list */ 93 94 return tcpedit_dlt_addplugin(ctx, plugin); … … 354 355 } 355 356 357 /* 358 * return a static pointer to the source/destination MAC address 359 * return NULL on error/address doesn't exist 360 */ 361 u_char * 362 dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 363 { 364 assert(ctx); 365 assert(packet); 366 assert(pktlen); 367 368 /* FIXME: return a ptr to the source or dest mac address. */ 369 switch(mac) { 370 case SRC_MAC: 371 return(NULL); 372 break; 373 374 case DST_MAC: 375 memcpy(ctx->dstmac, packet, 2); 376 return(ctx->dstmac); 377 break; 378 379 default: 380 errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); 381 } 382 return(NULL); 383 } 356 384 357 385 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_hdlc/hdlc.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_hdlc_l2addr_type(void); 49 49 int dlt_hdlc_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* 52 * FIXME:structure to hold any data parsed from the packet by the decoder.53 * structure to hold any data parsed from the packet by the decoder. 53 54 * Example: Ethernet VLAN tag info 54 55 */ -
trunk/src/tcpedit/plugins/dlt_ieee80211/ieee80211.c
r1840 r1841 48 48 */ 49 49 static char dlt_name[] = "ieee80211"; 50 static char dlt_prefix[] = "ieee802_11";50 __attribute__((unused)) static char dlt_prefix[] = "ieee802_11"; 51 51 static u_int16_t dlt_value = DLT_IEEE802_11; 52 52 … … 95 95 plugin->plugin_get_layer3 = dlt_ieee80211_get_layer3; 96 96 plugin->plugin_merge_layer3 = dlt_ieee80211_merge_layer3; 97 plugin->plugin_get_mac = dlt_ieee80211_get_mac; 97 98 98 99 /* add it to the available plugin list */ … … 220 221 */ 221 222 int 222 dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t dir)223 dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__((unused)) tcpr_dir_t dir) 223 224 { 224 225 u_char *packet; 225 226 assert(ctx); 226 227 assert(packet_ex); 228 assert(pktlen); 227 229 228 230 packet = *packet_ex; … … 341 343 } 342 344 345 /* 346 * return a static pointer to the source/destination MAC address 347 * return NULL on error/address doesn't exist 348 */ 349 u_char * 350 dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 351 { 352 assert(ctx); 353 assert(packet); 354 assert(pktlen); 355 char *macaddr; 356 357 switch(mac) { 358 case SRC_MAC: 359 macaddr = ieee80211_get_src(packet); 360 memcpy(ctx->srcmac, macaddr, ETHER_ADDR_LEN); 361 return(ctx->srcmac); 362 break; 363 364 case DST_MAC: 365 macaddr = ieee80211_get_dst(packet); 366 memcpy(ctx->dstmac, macaddr, ETHER_ADDR_LEN); 367 return(ctx->dstmac); 368 break; 369 370 default: 371 errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); 372 } 373 return(NULL); 374 } 375 343 376 344 377 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_ieee80211/ieee80211.h
r1838 r1841 48 48 tcpeditdlt_l2addr_type_t dlt_ieee80211_l2addr_type(void); 49 49 int dlt_ieee80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* 802.11 packet header w/ 3 addresses (non-WDS) */ -
trunk/src/tcpedit/plugins/dlt_linuxsll/linuxsll.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 90 90 plugin->plugin_get_layer3 = dlt_linuxsll_get_layer3; 91 91 plugin->plugin_merge_layer3 = dlt_linuxsll_merge_layer3; 92 92 plugin->plugin_get_mac = dlt_linuxsll_get_mac; 93 93 94 /* add it to the available plugin list */ 94 95 return tcpedit_dlt_addplugin(ctx, plugin); … … 291 292 } 292 293 294 /* 295 * return a static pointer to the source/destination MAC address 296 * return NULL on error/address doesn't exist 297 */ 298 u_char * 299 dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 300 { 301 assert(ctx); 302 assert(packet); 303 assert(pktlen); 304 305 /* FIXME: return a ptr to the source or dest mac address. */ 306 switch(mac) { 307 case SRC_MAC: 308 memcpy(ctx->srcmac, &packet[6], 8); /* linuxssl defines the src mac field to be 8 bytes, not 6 */ 309 return(ctx->srcmac); 310 break; 311 312 case DST_MAC: 313 return(NULL); 314 break; 315 316 default: 317 errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); 318 } 319 return(NULL); 320 } 293 321 294 322 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_linuxsll/linuxsll.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_linuxsll_l2addr_type(void); 49 49 int dlt_linuxsll_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* 52 * FIXME:structure to hold any data parsed from the packet by the decoder.53 * structure to hold any data parsed from the packet by the decoder. 53 54 * Example: Ethernet VLAN tag info 54 55 */ -
trunk/src/tcpedit/plugins/dlt_loop/loop.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 73 73 plugin = tcpedit_dlt_newplugin(); 74 74 75 /* FIXME:set what we provide & require */75 /* set what we provide & require */ 76 76 plugin->provides += PLUGIN_MASK_PROTO; 77 77 plugin->requires += 0; … … 94 94 plugin->plugin_get_layer3 = dlt_null_get_layer3; 95 95 plugin->plugin_merge_layer3 = dlt_null_merge_layer3; 96 96 plugin->plugin_get_mac = dlt_null_get_mac; 97 97 98 /* add it to the available plugin list */ 98 99 return tcpedit_dlt_addplugin(ctx, plugin); -
trunk/src/tcpedit/plugins/dlt_null/null.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 313 313 } 314 314 315 /* 316 * return a static pointer to the source/destination MAC address 317 * return NULL on error/address doesn't exist 318 */ 319 u_char * 320 dlt_null_get_mac(tcpeditdlt_t *ctx, __attribute__((unused)) tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 321 { 322 assert(ctx); 323 assert(packet); 324 assert(pktlen); 325 326 return(NULL); 327 328 } 315 329 316 330 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_null/null.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_null_l2addr_type(void); 49 49 int dlt_null_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_null_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* 52 * FIXME:structure to hold any data parsed from the packet by the decoder.53 * structure to hold any data parsed from the packet by the decoder. 53 54 * Example: Ethernet VLAN tag info 54 55 */ -
trunk/src/tcpedit/plugins/dlt_plugins-int.h
r1802 r1841 75 75 typedef enum tcpeditdlt_l2addr_type_e tcpeditdlt_l2addr_type_t; 76 76 77 /* src or dst mac */ 78 enum tcpeditdlt_mac_type_e { 79 SRC_MAC, 80 DST_MAC 81 }; 82 typedef enum tcpeditdlt_mac_type_e tcpeditdlt_mac_type_t; 83 84 /* MAC address buffer length */ 85 #define MAX_MAC_LEN 10 86 77 87 /* 78 88 * Each plugin must fill this out so that we know what function … … 92 102 int (*plugin_proto)(tcpeditdlt_t *, const u_char *, const int); 93 103 int (*plugin_l2len)(tcpeditdlt_t *, const u_char *, const int); 94 u_char *(*plugin_get_layer3)(tcpeditdlt_t *, u_char *, const int);104 u_char *(*plugin_get_layer3)(tcpeditdlt_t *, u_char *, const int); 95 105 u_char *(*plugin_merge_layer3)(tcpeditdlt_t *, u_char *, const int, u_char *); 96 106 tcpeditdlt_l2addr_type_t (*plugin_l2addr_type)(void); 107 u_char *(*plugin_get_mac)(tcpeditdlt_t *, tcpeditdlt_mac_type_t, const u_char *, const int); 97 108 void *config; /* user configuration data for the encoder */ 98 109 … … 132 143 u_int16_t proto; /* layer 3 proto type?? */ 133 144 void *decoded_extra; /* any extra L2 data from decoder like VLAN tags */ 145 u_char srcmac[MAX_MAC_LEN]; /* buffers to store the src & dst MAC */ 146 u_char dstmac[MAX_MAC_LEN]; 134 147 }; 135 148 -
trunk/src/tcpedit/plugins/dlt_plugins.h
r1757 r1841 60 60 * process the given packet, by calling decode & encode 61 61 */ 62 int tcpedit_dlt_process(tcpeditdlt_t *ctx, u_char *packet, 63 int pktlen, tcpr_dir_t direction); 62 int tcpedit_dlt_process(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t direction); 64 63 65 64 /* … … 79 78 80 79 81 82 80 int tcpedit_dlt_src(tcpeditdlt_t *ctx); 83 81 int tcpedit_dlt_dst(tcpeditdlt_t *ctx); -
trunk/src/tcpedit/plugins/dlt_raw/raw.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 93 93 plugin->plugin_get_layer3 = dlt_raw_get_layer3; 94 94 plugin->plugin_merge_layer3 = dlt_raw_merge_layer3; 95 95 plugin->plugin_get_mac = dlt_raw_get_mac; 96 96 97 /* add it to the available plugin list */ 97 98 return tcpedit_dlt_addplugin(ctx, plugin); … … 293 294 } 294 295 296 /* 297 * return a static pointer to the source/destination MAC address 298 * return NULL on error/address doesn't exist 299 */ 300 u_char * 301 dlt_raw_get_mac(tcpeditdlt_t *ctx, __attribute__((unused)) tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 302 { 303 assert(ctx); 304 assert(packet); 305 assert(pktlen); 306 307 return(NULL); 308 } 295 309 296 310 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_raw/raw.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_raw_l2addr_type(void); 49 49 int dlt_raw_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_raw_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* 52 * FIXME:structure to hold any data parsed from the packet by the decoder.53 * structure to hold any data parsed from the packet by the decoder. 53 54 * Example: Ethernet VLAN tag info 54 55 */ -
trunk/src/tcpedit/plugins/dlt_template/plugin.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 74 74 plugin->dlt = dlt_value; 75 75 76 /* offset to src/dst mac's. must be >= 0 for a valid value or -1 for non-existent */ 77 plugin->srcmac_offset = -1; 78 plugin->dstmac_offset = -1; 79 80 76 81 /* set the prefix name of our plugin. This is also used as the prefix for our options */ 77 82 plugin->name = safe_strdup(dlt_name); … … 91 96 plugin->plugin_get_layer3 = dlt_%{plugin}_get_layer3; 92 97 plugin->plugin_merge_layer3 = dlt_%{plugin}_merge_layer3; 98 plugin->plugin_get_mac = dlt_%{plugin}_get_mac; 93 99 94 100 /* add it to the available plugin list */ … … 277 283 } 278 284 285 /* 286 * return a static pointer to the source/destination MAC address 287 * return NULL on error/address doesn't exist 288 */ 289 u_char * 290 dlt_%{plugin}_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 291 { 292 assert(ctx); 293 assert(packet); 294 assert(pktlen); 295 296 /* FIXME: return a ptr to the source or dest mac address. */ 297 switch(mac) { 298 case SRC_MAC: 299 memcpy(ctx->srcmac, packet, length); 300 return(ctx->srcmac); 301 break; 302 303 case DST_MAC: 304 memcpy(ctx->dstmac, packet, length); 305 return(ctx->dstmac); 306 break; 307 308 default: 309 errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); 310 } 311 } 312 313 279 314 /* 280 315 * return the length of the L2 header of the current packet -
trunk/src/tcpedit/plugins/dlt_template/plugin.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_%{plugin}_l2addr_type(void); 49 49 int dlt_%{plugin}_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_%{plugin}_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* -
trunk/src/tcpedit/plugins/dlt_user/user.c
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 89 89 plugin->plugin_get_layer3 = dlt_user_get_layer3; 90 90 plugin->plugin_merge_layer3 = dlt_user_merge_layer3; 91 91 plugin->plugin_get_mac = dlt_user_get_mac; 92 92 93 /* add it to the available plugin list */ 93 94 return tcpedit_dlt_addplugin(ctx, plugin); … … 340 341 } 341 342 343 /* 344 * return a static pointer to the source/destination MAC address 345 * return NULL on error/address doesn't exist 346 */ 347 u_char * 348 dlt_user_get_mac(tcpeditdlt_t *ctx, __attribute__((unused)) tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) 349 { 350 assert(ctx); 351 assert(packet); 352 assert(pktlen); 353 354 /* we don't know the format of USER DLT, hence always return NULL */ 355 return(NULL); 356 } 342 357 343 358 tcpeditdlt_l2addr_type_t -
trunk/src/tcpedit/plugins/dlt_user/user.h
r1830 r1841 1 /* $Id :$ */1 /* $Id$ */ 2 2 3 3 /* … … 48 48 tcpeditdlt_l2addr_type_t dlt_user_l2addr_type(void); 49 49 int dlt_user_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); 50 u_char *dlt_user_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); 50 51 51 52 /* extra function called directly by tcpedit_dlt_output_dlt() */ -
trunk/src/tcpedit/tcpedit.c
r1836 r1841 396 396 397 397 398 u_char *398 const u_char * 399 399 tcpedit_l3data(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) 400 400 { … … 409 409 410 410 int 411 tcpedit_l2len(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) 412 { 413 int result = 0; 414 if (code == BEFORE_PROCESS) { 415 result = tcpedit_dlt_l2len(tcpedit->dlt_ctx, tcpedit->dlt_ctx->decoder->dlt, packet, pktlen); 416 } else { 417 result = tcpedit_dlt_l2len(tcpedit->dlt_ctx, tcpedit->dlt_ctx->encoder->dlt, packet, pktlen); 418 } 419 return result; 420 } 421 422 int 411 423 tcpedit_l3proto(tcpedit_t *tcpedit, tcpedit_coder_t code, const u_char *packet, const int pktlen) 412 424 { … … 420 432 } 421 433
