Ignore:
Timestamp:
10/31/05 15:46:09 (16 years ago)
Author:
Perry Lorier <perry@…>
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:
1851624
Parents:
950d54a
Message:

use netdb to lookup ports/protocols

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpacketdump/eth_2048.cc

    r950d54a r010fafb  
    1010#include <netinet/ip.h>
    1111#include <arpa/inet.h>
     12#include <netdb.h>
    1213
    1314#define DISPLAY_EXP(x,fmt,exp) \
     
    3738        //printf("\n IP:");
    3839        DISPLAY(ttl," TTL %i");
    39         DISPLAY(protocol," Proto %i");
     40        if ((unsigned int)len>=((char*)&ip->protocol-(char*)ip+sizeof(ip->protocol))) {
     41                struct protoent *ent=getprotobynumber(ip->protocol);
     42                if (ent) {
     43                        printf(" Proto %i (%s)",ip->protocol,ent->p_name);
     44                }
     45                else {
     46                        printf(" Proto %i",ip->protocol);
     47                }
     48        } else {
     49                printf("\n");
     50                return;
     51        }
    4052        DISPLAYS(check," Checksum %i\n");
    4153        DISPLAYIP(saddr," IP: Source %s ");
Note: See TracChangeset for help on using the changeset viewer.