NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Utility to redirect UDP packets
Hello,
In the past people have asked how to receive UDP packets and
relay them to another IP address while keeping track of
replies. Basically a utility that does what rinetd does for tcp
connections. I found a utility that does just that called udp_redirect:
http://brokestream.com/udp_redirect.html.
It required very minimal changes to compile under NetBSD. Mainly I
had to include a local version of netinet/ip.h that lacked the
"struct ip_timestamp {" section. I must have had to do this for
another project because I already had the modified ip.h file. Without
the local ip.h the error is:
Highlander:~/udp_redirect# cc -o udp_redirect udp_redirect.c
In file included from udp_redirect.c:44:
/usr/include/netinet/ip.h:149: error: expected specifier-qualifier-list
before 'n_time'
I'm including the diff below. I think this would be a good tool to
include in pkgsrc. I'm using it to query a router via SNMP (for mrtg).
Jason Mitchell
jmitchel%bigjar.com@localhost
PTI:~/customcode/udp_redirect#diff udp_redirect.c
udp_redirect_minimal_changes.c
33a34
> #include "ip.h"
35a37,39
> struct sockaddr_in a, sa, da;
> int os;
>
42c46
< int os=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
---
> os=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP);
44d47
< struct sockaddr_in a;
53,54c56
< struct sockaddr_in sa;
< struct sockaddr_in da; da.sin_addr.s_addr=0;
---
> da.sin_addr.s_addr=0;
And here's the section I commented out in ip.h
// struct ip_timestamp {
// u_int8_t ipt_code; /* IPOPT_TS */
// u_int8_t ipt_len; /* size of structure (variable) */
// u_int8_t ipt_ptr; /* index of current entry */
//#if BYTE_ORDER == LITTLE_ENDIAN
// u_int8_t ipt_flg:4, /* flags, see below */
// ipt_oflw:4; /* overflow counter */
//#endif
//#if BYTE_ORDER == BIG_ENDIAN
// u_int8_t ipt_oflw:4, /* overflow counter */
// ipt_flg:4; /* flags, see below */
//#endif
// union ipt_timestamp {
// n_time ipt_time[1];
// struct ipt_ta {
// struct in_addr ipt_addr;
// n_time ipt_time;
// } ipt_ta[1] __attribute__((__packed__));
// } ipt_timestamp __attribute__((__packed__));
// __attribute__((__packed__));
Home |
Main Index |
Thread Index |
Old Index