1 *** tproxy.c.orig Fri Dec 20 10:53:24 1996
2 --- tproxy.c Sun Jan 3 11:33:55 1999
6 #include <netinet/in.h>
7 #include <sys/signal.h>
11 + #include <sys/ioctl.h>
19 #define bzero(buf,size) memset(buf, '\0', size);
22 + #include "ip_compat.h"
27 /* socket to audio server */
37 + struct sockaddr_in laddr, faddr;
38 + struct natlookup natlookup;
41 + bzero((char *)&laddr, sizeof(laddr));
42 + bzero((char *)&faddr, sizeof(faddr));
43 + slen = sizeof(laddr);
44 + if (getsockname(0, (struct sockaddr *)&laddr, &slen) < 0)
46 + slen = sizeof(faddr);
47 + if (getpeername(0, (struct sockaddr *)&faddr, &slen) < 0)
49 + natlookup.nl_inport = laddr.sin_port;
50 + natlookup.nl_outport = faddr.sin_port;
51 + natlookup.nl_inip = laddr.sin_addr;
52 + natlookup.nl_outip = faddr.sin_addr;
53 + natlookup.nl_flags = IPN_TCP;
54 + if ((natfd = open(IPL_NAT, O_RDONLY)) < 0)
56 + if (ioctl(natfd, SIOCGNATL, &natlookup) == -1) {
57 + syslog(LOG_ERR, "SIOCGNATL failed: %m\n");
62 + strcpy(hostname, inet_ntoa(natlookup.nl_realip));
63 + serverport = ntohs(natlookup.nl_realport);
65 + * End of IP-Filter block
68 /* setup a timeout in case dialog doesn't finish */
69 signal(SIGALRM, timeout);
73 * and modify the call to (and subroutine) serverconnect() as
77 strcpy(hostname, "randomhostname");
80 /* Can we connect to the server */
81 if ( (serverfd = serverconnect(hostname, serverport)) < 0 ) {
82 /* errno may still be set from previous call */