Messages in this thread |  | | Subject | linux headers and tcpdump programs | Date | Wed, 10 Jul 1996 14:50:41 PDT | From | "Marty Leisner" <> |
| |
I'm trying to port tcpdump 3.2.1a1 to linux
The major problem is the elements of structures are called something else from the tcpdump/bsd implementatoin....
I think the way things are managed in headers files is somewhat backwards...
For example, <net/udp.h> does: #include <linux/udp.h>
#define UDP_NO_CHECK 0
extern struct proto udp_prot;
extern void udp_err(int type, int code, unsigned char *header, __u32 daddr, __u32 saddr, struct inet_protocol *protocol); extern void udp_send_check(struct udphdr *uh, __u32 saddr, __u32 daddr, int len, struct sock *sk); extern int udp_recvfrom(struct sock *sk, unsigned char *to, int len, int noblock, unsigned flags, struct sockaddr_in *sin, int *addr_len); extern int udp_read(struct sock *sk, unsigned char *buff, int len, int noblock, unsigned flags); extern int udp_connect(struct sock *sk, struct sockaddr_in *usin, int addr_len);
and linux/udp.h #ifndef _LINUX_UDP_H #define _LINUX_UDP_H
struct udphdr { unsigned short source; unsigned short dest; unsigned short len; unsigned short check; };
The BSD udphdr structure is: ifndef _NETINET_UDP_H_ #define _NETINET_UDP_H_
/* * Udp protocol header. * Per RFC 768, September, 1981. */ struct udphdr { u_short uh_sport; /* source port */ u_short uh_dport; /* destination port */ short uh_ulen; /* udp length */ u_short uh_sum; /* udp checksum */ };
#endif
I would imagine net/udp.h to have something like:
#ifdef BSD_COMPAT struct udphdr { unsigned short uh_sport; unsigned short uh_dport; unsigned short uh_ulen; unsigned short uh_sum; }; #else struct udphdr { unsigned short source; unsigned short dest; unsigned short len; unsigned short check; }; #endif
#ifdef __KERNEL__ #include <linux/udp.h> #endif
Where linux/*.h contains linux/kernel dependcies...udphdr is pretty generic udp stuff...(so I don't see why its in linux/udp.h instead of net/udp.h)
I want to see tools like tcpdump compile relatively cleanly.
Comments? If this is a step in the right direction, I'll start making the changes.
marty leisner@sdsp.mc.xerox.com Member of the League for Programming Freedom (http://www.lpf.org) Any sufficiently advanced technology is indistinguishable from magic Arthur C. Clarke, The Lost Worlds of 2001
|  |