Fix gcc 3.4 build.
[dragonfly.git] / contrib / ipfilter / FWTK / tproxy.diff
1 *** tproxy.c.orig       Fri Dec 20 10:53:24 1996
2 --- tproxy.c    Sun Jan  3 11:33:55 1999
3 ***************
4 *** 135,140 ****
5 --- 135,144 ----
6   #include      <netinet/in.h>
7   #include      <sys/signal.h>
8   #include      <syslog.h>
9 + #include      <unistd.h>
10 + #include      <fcntl.h>
11 + #include      <sys/ioctl.h>
12 + #include      <net/if.h>
13   #include      "tproxy.h"
14   
15   #ifdef AIX
16 ***************
17 *** 147,152 ****
18 --- 151,159 ----
19   #define bzero(buf,size) memset(buf, '\0', size);
20   #endif /* SYSV */
21   
22 + #include "ip_compat.h"
23 + #include "ip_fil.h"
24 + #include "ip_nat.h"
25   
26   
27   /* socket to audio server */
28 ***************
29 *** 324,329 ****
30 --- 331,369 ----
31         char localbuf[2048];   
32         void timeout();
33         extern int errno;
34 +       /*
35 +        * IP-Filter block
36 +        */
37 +       struct sockaddr_in laddr, faddr;
38 +       struct natlookup natlookup;
39 +       int slen, natfd;
40
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)
45 +               return -1;
46 +       slen = sizeof(faddr);
47 +       if (getpeername(0, (struct sockaddr *)&faddr, &slen) < 0)
48 +               return -1;
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)
55 +               return -1;
56 +       if (ioctl(natfd, SIOCGNATL, &natlookup) == -1) {
57 +               syslog(LOG_ERR, "SIOCGNATL failed: %m\n");
58 +               close(natfd);
59 +               return -1;
60 +       }
61 +       close(natfd);
62 +       strcpy(hostname, inet_ntoa(natlookup.nl_realip));
63 +       serverport = ntohs(natlookup.nl_realport);
64 +       /*
65 +        * End of IP-Filter block
66 +        */
67   
68         /* setup a timeout in case dialog doesn't finish */
69         signal(SIGALRM, timeout);
70 ***************
71 *** 337,344 ****
72 --- 377,386 ----
73          * and modify the call to (and subroutine) serverconnect() as 
74          * appropriate.
75          */
76 + #if 0
77         strcpy(hostname, "randomhostname");
78         serverport = 7070;
79 + #endif
80         /* Can we connect to the server */
81         if ( (serverfd = serverconnect(hostname, serverport)) < 0 ) {
82                 /* errno may still be set from previous call */