Changeset 66ad025 for libpacketdump
- Timestamp:
- 07/15/10 16:45:16 (11 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 7af80ba
- Parents:
- 148338c
- Location:
- libpacketdump
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libpacketdump/Makefile.am
rac7037b r66ad025 105 105 link_2_la_LDFLAGS=-module 106 106 link_4_la_LDFLAGS=-module 107 link_6_la_LDFLAGS=-module 107 link_6_la_LDFLAGS=-module 108 108 link_9_la_LDFLAGS=-module 109 109 link_10_la_LDFLAGS=-module -
libpacketdump/eth_2048.c
rc7062df r66ad025 58 58 DISPLAYIP(ip_src," IP: Source %s "); 59 59 DISPLAYIP(ip_dst,"Destination %s\n"); 60 decode_next(packet+ sizeof(*ip),len-sizeof(*ip),"ip",ip->ip_p);60 decode_next(packet+ip->ip_hl*4,len-ip->ip_hl*4,"ip",ip->ip_p); 61 61 return; 62 62 } -
libpacketdump/libpacketdump.cc
rf01e6a8 r66ad025 79 79 #endif 80 80 81 static void formatted_hexdump(const char *packet, int len) { 82 int i; 83 84 for(i=0;i<len; /* Nothing */ ) { 85 int j; 86 printf("\n "); 87 for(j=0;j<WIDTH;j++) { 88 if (i+j<len) 89 printf(" %02x",(unsigned char)packet[i+j]); 90 else 91 printf(" "); 92 } 93 printf(" "); 94 for(j=0;j<WIDTH;j++) { 95 if (i+j<len) 96 if (isprint((unsigned char)packet[i+j])) 97 printf("%c",(unsigned char)packet[i+j]); 98 else 99 printf("."); 100 else 101 printf(" "); 102 } 103 if (i+WIDTH>len) 104 break; 105 else 106 i+=WIDTH; 107 } 108 printf("\n"); 109 } 110 111 void trace_hexdump_packet(struct libtrace_packet_t *packet) { 112 113 libtrace_linktype_t linktype; 114 uint32_t length; 115 const char *pkt_ptr = (char *)trace_get_packet_buffer(packet, &linktype, NULL); 116 117 time_t sec = (time_t)trace_get_seconds(packet); 118 119 length = trace_get_capture_length(packet); 120 121 if (pkt_ptr == NULL || length == 0) { 122 printf(" [No packet payload]\n"); 123 return; 124 } 125 126 printf("\n%s",ctime(&sec)); 127 printf(" Capture: Packet Length: %i/%i Direction Value: %i\n", 128 (int)length, 129 (int)trace_get_wire_length(packet), 130 (int)trace_get_direction(packet)); 131 132 133 formatted_hexdump(pkt_ptr, (int)length); 134 return; 135 } 136 81 137 void trace_dump_packet(struct libtrace_packet_t *packet) 82 138 { … … 84 140 libtrace_linktype_t linktype; 85 141 uint32_t length; 86 const char *link=(char *)trace_get_packet_buffer(packet,&linktype,&length); 142 const char *link=(char *)trace_get_packet_buffer(packet,&linktype,NULL); 143 144 length = trace_get_capture_length(packet); 87 145 88 146 printf("\n%s",ctime(&sec)); … … 99 157 100 158 static void generic_decode(uint16_t type,const char *packet, int len) { 101 int i;102 159 printf(" Unknown Protocol: %i",type); 103 for(i=0;i<len; /* Nothing */ ) { 104 int j; 105 printf("\n "); 106 for(j=0;j<WIDTH;j++) { 107 if (i+j<len) 108 printf(" %02x",(unsigned char)packet[i+j]); 109 else 110 printf(" "); 111 } 112 printf(" "); 113 for(j=0;j<WIDTH;j++) { 114 if (i+j<len) 115 if (isprint((unsigned char)packet[i+j])) 116 printf("%c",(unsigned char)packet[i+j]); 117 else 118 printf("."); 119 else 120 printf(" "); 121 } 122 if (i+WIDTH>len) 123 break; 124 else 125 i+=WIDTH; 126 } 127 printf("\n"); 160 161 formatted_hexdump(packet, len); 128 162 } 129 163 -
libpacketdump/libpacketdump.h
r11a7f9c r66ad025 7 7 #endif 8 8 9 void trace_hexdump_packet(libtrace_packet_t *packet); 9 10 void trace_dump_packet(libtrace_packet_t *packet); 10 11 void decode_next(const char *packet,int len,const char *proto_name,int type);
Note: See TracChangeset
for help on using the changeset viewer.