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/ip_6.cc

    r950d54a r010fafb  
    77#include <netinet/in.h>
    88#include <assert.h>
     9#include <netdb.h>
    910
    1011#define SAFE(x) \
     
    5354        struct tcphdr *tcp = (struct tcphdr*)packet;
    5455        printf(" TCP:");
    55         DISPLAYS(source," Source %i")
    56         DISPLAYS(dest," Dest %i")
     56        if (SAFE(source)) {
     57                struct servent *ent=getservbyport(tcp->source,"tcp");
     58                if(ent) {
     59                        printf(" Source %i (%s)",htons(tcp->source),ent->s_name);
     60                } else {
     61                        printf(" Source %i",htons(tcp->source));
     62                }
     63        }
     64        else {
     65                printf("\n");
     66                return;
     67        }
     68        if (SAFE(dest)) {
     69                struct servent *ent=getservbyport(tcp->dest,"tcp");
     70                if(ent) {
     71                        printf(" Dest %i (%s)",htons(tcp->dest),ent->s_name);
     72                } else {
     73                        printf(" Dest %i",htons(tcp->dest));
     74                }
     75        }
     76        else {
     77                printf("\n");
     78                return;
     79        }
    5780        printf("\n TCP:");
    5881        DISPLAYL(seq," Seq %u");
Note: See TracChangeset for help on using the changeset viewer.