10 #include <sys/types.h>
13 #include <sys/resource.h>
15 #include <sys/socket.h>
16 +#include <netinet/in.h>
17 +#include <arpa/inet.h>
21 @@ -221,6 +225,14 @@ loop_chars(p, n)
26 +/* check for synchronous connection... */
28 + if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
29 + rv = loop_frame(p,n);
36 @@ -299,17 +311,102 @@ loop_frame(frame, len)
37 * loopback, now that the real serial link is up.
41 +demand_rexmit(proto, newip)
45 struct packet *pkt, *prev, *nextpkt;
46 + unsigned short checksum;
47 + unsigned short pkt_checksum = 0;
58 + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
59 for (; pkt != NULL; pkt = nextpkt) {
61 if (PPP_PROTOCOL(pkt->data) == proto) {
62 + if ( (proto == PPP_IP) && newip ) {
63 + /* Get old checksum */
65 + iphdr = (pkt->data[4] & 15) << 2;
66 + checksum = *((unsigned short *) (pkt->data+14));
67 + if (checksum == 0xFFFF) {
72 + if (pkt->data[13] == 17) {
73 + pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
76 + if (pkt_checksum == 0xFFFF) {
85 + if (pkt->data[13] == 6) {
86 + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
88 + if (pkt_checksum == 0xFFFF) {
93 + /* Delete old Source-IP-Address */
94 + checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
95 + checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
97 + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
98 + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
100 + /* Change Source-IP-Address */
101 + * ((u_int32_t *) (pkt->data + 16)) = newip;
103 + /* Add new Source-IP-Address */
104 + checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
105 + checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
107 + pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
108 + pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
110 + /* Write new checksum */
114 + *((unsigned short *) (pkt->data+14)) = checksum;
115 + if (pkt->data[13] == 6) {
116 + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
118 + if (cv && (pkt->data[13] == 17) ) {
119 + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
123 + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
124 + if (pkt->data[13] == 1) {
125 + syslog(LOG_INFO,"Open ICMP %s -> %s\n",
127 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
129 + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
130 + pkt->data[13] == 6 ? "TCP" : "UDP",
132 + ntohs(*( (short *) (pkt->data+iphdr+4))),
133 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
134 + ntohs(*( (short *) (pkt->data+iphdr+6))));
137 output(0, pkt->data, pkt->length);
142 @@ -1776,7 +1776,7 @@ ipcp_up(f)
143 proxy_arp_set[f->unit] = 1;
146 - demand_rexmit(PPP_IP);
147 + demand_rexmit(PPP_IP,go->ouraddr);
148 sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
153 @@ -1232,7 +1232,7 @@ ipv6cp_up(f)
157 - demand_rexmit(PPP_IPV6);
158 + demand_rexmit(PPP_IPV6,0);
159 sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
164 @@ -565,7 +565,7 @@ void demand_conf __P((void)); /* config
165 void demand_block __P((void)); /* set all NPs to queue up packets */
166 void demand_unblock __P((void)); /* set all NPs to pass packets */
167 void demand_discard __P((void)); /* set all NPs to discard packets */
168 -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
169 +void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
170 int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
171 int loop_frame __P((unsigned char *, int)); /* should we bring link up? */