Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: Re: [ethereal-dev] Re: Ethereal Contribution + patches

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: gram@xxxxxxxxxxxxxxxxxxx (Gilbert Ramirez Jr.)
Date: Mon, 31 Aug 1998 16:54:55 -0500 (CDT)
As Gerald Combs - Unicom Communications said:
> 
>   A while ago, Gilbert added pntohs() and pntohl() macros to packet.h. 
> You pass them a byte pointer, and they return the short and long ints at
> that pointer.  I expanded them this weekend to fix some Solaris alignment
> issues.  They may be able to help you with your Alpha effort as long as I
> didn't break them. 

I don't think you messed them up; I think I might have put them in
incorrectly. The following program shows that the big-endian/little-endian
test in packet.h is backwards.

#include <pcap.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include "packet.h"

int main(void) {

    unsigned short int  ishort;

    ishort = htons(7777);

    printf("pntohs shows %d, ntohs shows %d\n",
        pntohs((guint8*)&ishort), ntohs(ishort));

    return 0;
}  

--gilbert
-- 
Gilbert Ramirez                Voice:  +1 210 358 4032
Technical Services             Fax:    +1 210 358 1122
University Health System       San Antonio, Texas, USA