Ignore:
Timestamp:
05/11/06 11:40:21 (16 years ago)
Author:
Shane Alcock <salcock@…>
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:
83445f0
Parents:
3fcb8b4
Message:

Fixed segmentation faults when trace_destroy is called on a trace that wasn't successfully created
libdl is now checked for and only linked against if available (BSD's don't have a libdl)
Fixed the libpacketdump .so's to use libtrace's generic protocol headers as well as trace_ether_ntoa
Added missing check for strlcpy
Added a couple of #defines to various tools that needed them under FreeBSD
Removed some needless #includes from the libpacketdump .so's

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/eth_2048.cc

    r010fafb r4e65f42  
    1 #include <netinet/ether.h>
    21#include <netinet/in.h>
    32#include <stdio.h>
    43#include <inttypes.h>
    54#include <dlfcn.h>
    6 #include <map>
    75#include "libpacketdump.h"
    86#include <sys/socket.h>
     7#ifndef WIN32
     8        #include <netinet/in_systm.h>
     9#endif
    910#include <netinet/in.h>
    1011#include <netinet/ip.h>
     
    2627void decode(int link_type,char *packet,int len)
    2728{
    28         struct iphdr *ip = (struct iphdr*)packet;
     29        libtrace_ip_t *ip = (libtrace_ip_t*)packet;
    2930        if (len>=1) {
    30                 printf(" IP: Header Len %i",ip->ihl*4);
    31                 printf(" Ver %i",ip->version);
     31                printf(" IP: Header Len %i",ip->ip_hl*4);
     32                printf(" Ver %i",ip->ip_v);
    3233        }
    33         DISPLAY(tos," TOS %02x")
    34         DISPLAYS(tot_len," Total Length %i")
     34        DISPLAY(ip_tos," TOS %02x")
     35        DISPLAYS(ip_len," Total Length %i")
    3536        printf("\n IP:");
    36         DISPLAY(id," Id %i");
    37         DISPLAY(frag_off," Fragoff %i");
     37        DISPLAY(ip_id," Id %i");
     38       
     39        if ((unsigned int)len >= ((char *)&ip->ip_ttl - (char *)ip - 2)) {
     40                printf(" \n Fragoff %i", ip->ip_off);
     41                if (ip->ip_mf) printf(" MORE_FRAG");
     42                if (ip->ip_df) printf(" DONT_FRAG");
     43                if (ip->ip_rf) printf(" RESV_FRAG");
     44        }
    3845        //printf("\n IP:");
    39         DISPLAY(ttl," TTL %i");
    40         if ((unsigned int)len>=((char*)&ip->protocol-(char*)ip+sizeof(ip->protocol))) {
    41                 struct protoent *ent=getprotobynumber(ip->protocol);
     46        DISPLAY(ip_ttl,"\n TTL %i");
     47        if ((unsigned int)len>=((char*)&ip->ip_p-(char*)ip+sizeof(ip->ip_p))) {
     48                struct protoent *ent=getprotobynumber(ip->ip_p);
    4249                if (ent) {
    43                         printf(" Proto %i (%s)",ip->protocol,ent->p_name);
     50                        printf(" Proto %i (%s)",ip->ip_p,ent->p_name);
    4451                }
    4552                else {
    46                         printf(" Proto %i",ip->protocol);
     53                        printf(" Proto %i",ip->ip_p);
    4754                }
    4855        } else {
     
    5057                return;
    5158        }
    52         DISPLAYS(check," Checksum %i\n");
    53         DISPLAYIP(saddr," IP: Source %s ");
    54         DISPLAYIP(daddr,"Destination %s\n");
    55         decode_next(packet+sizeof(*ip),len-sizeof(*ip),"ip",ip->protocol);
     59        DISPLAYS(ip_sum," Checksum %i\n");
     60        DISPLAYIP(ip_src," IP: Source %s ");
     61        DISPLAYIP(ip_dst,"Destination %s\n");
     62        decode_next(packet+sizeof(*ip),len-sizeof(*ip),"ip",ip->ip_p);
    5663        return;
    5764}
Note: See TracChangeset for help on using the changeset viewer.