Changeset d5e1796
- Timestamp:
- 10/25/06 15:42:38 (14 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:
- c9f6ee5
- Parents:
- 16da8f3
- Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_pcap.c
r103cc3b rd5e1796 310 310 { 311 311 struct pcap_pkthdr pcap_pkt_hdr; 312 313 /* If this packet cannot be converted to a pcap linktype then 314 * pop off the top header until it can be converted 315 */ 316 while (libtrace_to_pcap_dlt(trace_get_link_type(packet))==~0) { 317 if (!demote_packet(packet)) { 318 trace_set_err_out(libtrace, 319 TRACE_ERR_NO_CONVERSION, 320 "pcap does not support this format"); 321 return -1; 322 } 323 } 312 324 313 325 if (!OUTPUT.trace.pcap) { -
lib/libtrace.h.in
r16da8f3 rd5e1796 170 170 #define LIBTRACE_PACKET_BUFSIZE 65536 171 171 172 /** The libtrace packet structure, applications shouldn't be173 * meddling around in here174 */175 typedef struct libtrace_packet_t {176 struct libtrace_t *trace; /**< pointer to the trace */177 void *header; /**< pointer to the framing header */178 void *payload; /**< pointer to the link layer */179 void *buffer; /**< allocated buffer */180 uint32_t type; /**< rt protocol type for the packet */181 buf_control_t buf_control; /**< who owns the memory */182 } libtrace_packet_t;183 184 172 /** libtrace error information */ 185 173 typedef struct trace_err_t{ … … 216 204 TRACE_DLT_LINUX_SLL = 113, 217 205 TRACE_DLT_PFLOG = 117, 218 206 TRACE_DLT_IEEE802_11_RADIO = 127 /**< Radiotap */ 219 207 } libtrace_dlt_t ; 220 208 … … 235 223 TRACE_TYPE_80211_PRISM = 12, 236 224 TRACE_TYPE_AAL5 = 13, 237 TRACE_TYPE_DUCK = 14, /**< Pseudo link layer for DUCK packets */ 238 TRACE_TYPE_80211_RADIO = 15 /**< Radiotap + 802.11 */ 239 } libtrace_linktype_t; 225 TRACE_TYPE_DUCK = 14, /**< Pseudo link layer for DUCK packets */ 226 TRACE_TYPE_80211_RADIO = 15, /**< Radiotap + 802.11 */ 227 TRACE_TYPE_LLCSNAP = 16, /**< Raw LLC/SNAP */ 228 229 } libtrace_linktype_t; 230 231 typedef enum { 232 TRACE_RT_DLT_ATM_RFC1483 = 2000+TRACE_DLT_ATM_RFC1483, 233 TRACE_RT_LAST = (2<<31) 234 } libtrace_rt_types_t; 235 236 /** The libtrace packet structure, applications shouldn't be 237 * meddling around in here 238 */ 239 typedef struct libtrace_packet_t { 240 struct libtrace_t *trace; /**< pointer to the trace */ 241 void *header; /**< pointer to the framing header */ 242 void *payload; /**< pointer to the link layer */ 243 void *buffer; /**< allocated buffer */ 244 libtrace_rt_types_t type; /**< rt protocol type for the packet */ 245 buf_control_t buf_control; /**< who owns the memory */ 246 } libtrace_packet_t; 247 240 248 241 249 /** Trace directions -
lib/linktypes.c
r1ab9849 rd5e1796 37 37 case TRACE_DLT_NULL: return TRACE_TYPE_NONE; 38 38 case TRACE_DLT_EN10MB: return TRACE_TYPE_ETH; 39 case TRACE_DLT_ATM_RFC1483: return TRACE_TYPE_ATM;40 39 case TRACE_DLT_IEEE802_11: return TRACE_TYPE_80211; 41 40 case TRACE_DLT_LINUX_SLL: return TRACE_TYPE_LINUX_SLL; 42 case TRACE_DLT_PFLOG: 43 return TRACE_TYPE_PFLOG; 44 case TRACE_DLT_IEEE802_11_RADIO: 45 return TRACE_TYPE_80211_RADIO; 46 } 47 return ~0; 48 } 41 case TRACE_DLT_PFLOG: return TRACE_TYPE_PFLOG; 42 case TRACE_DLT_IEEE802_11_RADIO: return TRACE_TYPE_80211_RADIO; 43 case TRACE_DLT_ATM_RFC1483: return TRACE_TYPE_LLCSNAP; 44 45 } 46 return ~0; 47 } 48 49 49 50 50 libtrace_dlt_t libtrace_to_pcap_dlt(libtrace_linktype_t type) 51 51 { 52 /* If pcap doesn't have a DLT, you can either ask pcap to register 53 * you a DLT, (and perhaps write a tcpdump decoder for it), or you 54 * can add it to demote_packet 55 */ 52 56 switch(type) { 53 57 case TRACE_TYPE_NONE: return TRACE_DLT_NULL; 54 58 case TRACE_TYPE_ETH: return TRACE_DLT_EN10MB; 55 case TRACE_TYPE_ATM: return TRACE_DLT_ATM_RFC1483;56 59 case TRACE_TYPE_80211: return TRACE_DLT_IEEE802_11; 57 60 case TRACE_TYPE_LINUX_SLL: return TRACE_DLT_LINUX_SLL; 58 61 case TRACE_TYPE_PFLOG: return TRACE_DLT_PFLOG; 59 case TRACE_TYPE_80211_RADIO: return TRACE_DLT_IEEE802_11_RADIO; 62 case TRACE_TYPE_80211_RADIO: return TRACE_DLT_IEEE802_11_RADIO; 63 case TRACE_TYPE_ATM: 64 /* Dispite hints to the contrary, there is no DLT 65 * for 'raw atm packets that happen to be missing 66 * the HEC' or even 'raw atm packets that have a hec'. 67 * 68 * The closest are DLT_ATM_RFC1483 but that doesn't 69 * include the ATM header, only the LLCSNAP header. 70 */ 71 return ~0; 72 case TRACE_TYPE_LLCSNAP: return TRACE_DLT_ATM_RFC1483; 60 73 } 61 74 return ~0; … … 196 209 bool demote_packet(libtrace_packet_t *packet) 197 210 { 211 uint8_t type; 212 uint32_t remaining; 213 char *tmp; 214 struct timeval tv; 215 static libtrace_t *trace = NULL; 198 216 switch(trace_get_link_type(packet)) { 217 case TRACE_TYPE_ATM: 218 remaining=trace_get_capture_length(packet); 219 packet->payload=trace_get_payload_from_atm( 220 packet->payload,&type,&remaining); 221 222 tmp=malloc( 223 trace_get_capture_length(packet) 224 +sizeof(libtrace_pcapfile_pkt_hdr_t) 225 ); 226 227 tv=trace_get_timeval(packet); 228 ((libtrace_pcapfile_pkt_hdr_t*)tmp)->ts_sec=tv.tv_sec; 229 ((libtrace_pcapfile_pkt_hdr_t*)tmp)->ts_usec=tv.tv_usec; 230 ((libtrace_pcapfile_pkt_hdr_t*)tmp)->caplen 231 = remaining; 232 ((libtrace_pcapfile_pkt_hdr_t*)tmp)->wirelen 233 = trace_get_capture_length(packet)-remaining; 234 235 memcpy(tmp+sizeof(libtrace_pcapfile_pkt_hdr_t), 236 packet->payload, 237 remaining); 238 if (packet->buf_control == TRACE_CTRL_EXTERNAL) { 239 packet->buf_control=TRACE_CTRL_PACKET; 240 } 241 else { 242 free(packet->buffer); 243 } 244 packet->buffer=tmp; 245 packet->header=tmp; 246 packet->payload=tmp+sizeof(libtrace_pcapfile_pkt_hdr_t); 247 packet->type=pcap_dlt_to_rt(TRACE_DLT_ATM_RFC1483); 248 249 if (trace == NULL) { 250 trace = trace_create_dead("pcap:-"); 251 } 252 253 packet->trace=trace; 254 255 return true; 256 199 257 case TRACE_TYPE_LINUX_SLL: 200 258 switch(ntohs(((libtrace_sll_header_t*)packet->payload) -
lib/protocols.c
r16da8f3 rd5e1796 174 174 } 175 175 176 static void *trace_get_payload_from_atm(void *link, 176 DLLEXPORT 177 void *trace_get_payload_from_atm(void *link, 177 178 uint8_t *type, uint32_t *remaining) 178 179 {
Note: See TracChangeset
for help on using the changeset viewer.