1 diff -Naur ppp-2.4.4.orig/pppd/demand.c ppp-2.4.4/pppd/demand.c
2 --- ppp-2.4.4.orig/pppd/demand.c 2005-08-25 08:14:18.000000000 -0400
3 +++ ppp-2.4.4/pppd/demand.c 2009-05-07 16:16:20.000000000 -0400
10 #include <sys/param.h>
11 #include <sys/types.h>
14 #include <sys/resource.h>
16 #include <sys/socket.h>
17 +#include <netinet/in.h>
18 +#include <arpa/inet.h>
27 +/* check for synchronous connection... */
29 + if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
30 + rv = loop_frame(p,n);
37 @@ -299,17 +311,102 @@
38 * loopback, now that the real serial link is up.
42 +demand_rexmit(proto, newip)
46 struct packet *pkt, *prev, *nextpkt;
47 + unsigned short checksum;
48 + unsigned short pkt_checksum = 0;
59 + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
60 for (; pkt != NULL; pkt = nextpkt) {
62 if (PPP_PROTOCOL(pkt->data) == proto) {
63 + if ( (proto == PPP_IP) && newip ) {
64 + /* Get old checksum */
66 + iphdr = (pkt->data[4] & 15) << 2;
67 + checksum = *((unsigned short *) (pkt->data+14));
68 + if (checksum == 0xFFFF) {
73 + if (pkt->data[13] == 17) {
74 + pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
77 + if (pkt_checksum == 0xFFFF) {
86 + if (pkt->data[13] == 6) {
87 + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
89 + if (pkt_checksum == 0xFFFF) {
94 + /* Delete old Source-IP-Address */
95 + checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
96 + checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
98 + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
99 + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
101 + /* Change Source-IP-Address */
102 + * ((u_int32_t *) (pkt->data + 16)) = newip;
104 + /* Add new Source-IP-Address */
105 + checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
106 + checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
108 + pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
109 + pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
111 + /* Write new checksum */
115 + *((unsigned short *) (pkt->data+14)) = checksum;
116 + if (pkt->data[13] == 6) {
117 + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
119 + if (cv && (pkt->data[13] == 17) ) {
120 + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
124 + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
125 + if (pkt->data[13] == 1) {
126 + syslog(LOG_INFO,"Open ICMP %s -> %s\n",
128 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
130 + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
131 + pkt->data[13] == 6 ? "TCP" : "UDP",
133 + ntohs(*( (short *) (pkt->data+iphdr+4))),
134 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
135 + ntohs(*( (short *) (pkt->data+iphdr+6))));
138 output(0, pkt->data, pkt->length);
141 diff -Naur ppp-2.4.4.orig/pppd/ipcp.c ppp-2.4.4/pppd/ipcp.c
142 --- ppp-2.4.4.orig/pppd/ipcp.c 2009-05-07 15:49:34.000000000 -0400
143 +++ ppp-2.4.4/pppd/ipcp.c 2009-05-07 16:16:20.000000000 -0400
144 @@ -1776,7 +1776,7 @@
145 proxy_arp_set[f->unit] = 1;
148 - demand_rexmit(PPP_IP);
149 + demand_rexmit(PPP_IP,go->ouraddr);
150 sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
153 diff -Naur ppp-2.4.4.orig/pppd/ipv6cp.c ppp-2.4.4/pppd/ipv6cp.c
154 --- ppp-2.4.4.orig/pppd/ipv6cp.c 2005-08-25 19:59:34.000000000 -0400
155 +++ ppp-2.4.4/pppd/ipv6cp.c 2009-05-07 16:16:20.000000000 -0400
156 @@ -1232,7 +1232,7 @@
160 - demand_rexmit(PPP_IPV6);
161 + demand_rexmit(PPP_IPV6,0);
162 sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
165 diff -Naur ppp-2.4.4.orig/pppd/pppd.h ppp-2.4.4/pppd/pppd.h
166 --- ppp-2.4.4.orig/pppd/pppd.h 2009-05-07 15:49:34.000000000 -0400
167 +++ ppp-2.4.4/pppd/pppd.h 2009-05-07 16:16:20.000000000 -0400
169 void demand_block __P((void)); /* set all NPs to queue up packets */
170 void demand_unblock __P((void)); /* set all NPs to pass packets */
171 void demand_discard __P((void)); /* set all NPs to discard packets */
172 -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
173 +void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
174 int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
175 int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
177 diff -Naur ppp-2.4.4.orig/pppd/demand.c ppp-2.4.4/pppd/demand.c
178 --- ppp-2.4.4.orig/pppd/demand.c 2005-08-25 08:14:18.000000000 -0400
179 +++ ppp-2.4.4/pppd/demand.c 2009-05-07 16:16:20.000000000 -0400
186 #include <sys/param.h>
187 #include <sys/types.h>
188 #include <sys/wait.h>
190 #include <sys/resource.h>
191 #include <sys/stat.h>
192 #include <sys/socket.h>
193 +#include <netinet/in.h>
194 +#include <arpa/inet.h>
196 #include <pcap-bpf.h>
203 +/* check for synchronous connection... */
205 + if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
206 + rv = loop_frame(p,n);
213 @@ -299,17 +311,102 @@
214 * loopback, now that the real serial link is up.
217 -demand_rexmit(proto)
218 +demand_rexmit(proto, newip)
222 struct packet *pkt, *prev, *nextpkt;
223 + unsigned short checksum;
224 + unsigned short pkt_checksum = 0;
235 + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
236 for (; pkt != NULL; pkt = nextpkt) {
238 if (PPP_PROTOCOL(pkt->data) == proto) {
239 + if ( (proto == PPP_IP) && newip ) {
240 + /* Get old checksum */
242 + iphdr = (pkt->data[4] & 15) << 2;
243 + checksum = *((unsigned short *) (pkt->data+14));
244 + if (checksum == 0xFFFF) {
249 + if (pkt->data[13] == 17) {
250 + pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
251 + if (pkt_checksum) {
253 + if (pkt_checksum == 0xFFFF) {
262 + if (pkt->data[13] == 6) {
263 + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
265 + if (pkt_checksum == 0xFFFF) {
270 + /* Delete old Source-IP-Address */
271 + checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
272 + checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
274 + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
275 + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
277 + /* Change Source-IP-Address */
278 + * ((u_int32_t *) (pkt->data + 16)) = newip;
280 + /* Add new Source-IP-Address */
281 + checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
282 + checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
284 + pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
285 + pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
287 + /* Write new checksum */
291 + *((unsigned short *) (pkt->data+14)) = checksum;
292 + if (pkt->data[13] == 6) {
293 + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
295 + if (cv && (pkt->data[13] == 17) ) {
296 + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
300 + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
301 + if (pkt->data[13] == 1) {
302 + syslog(LOG_INFO,"Open ICMP %s -> %s\n",
304 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
306 + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
307 + pkt->data[13] == 6 ? "TCP" : "UDP",
309 + ntohs(*( (short *) (pkt->data+iphdr+4))),
310 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
311 + ntohs(*( (short *) (pkt->data+iphdr+6))));
314 output(0, pkt->data, pkt->length);
317 diff -Naur ppp-2.4.4.orig/pppd/ipcp.c ppp-2.4.4/pppd/ipcp.c
318 --- ppp-2.4.4.orig/pppd/ipcp.c 2009-05-07 15:49:34.000000000 -0400
319 +++ ppp-2.4.4/pppd/ipcp.c 2009-05-07 16:16:20.000000000 -0400
320 @@ -1776,7 +1776,7 @@
321 proxy_arp_set[f->unit] = 1;
324 - demand_rexmit(PPP_IP);
325 + demand_rexmit(PPP_IP,go->ouraddr);
326 sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
329 diff -Naur ppp-2.4.4.orig/pppd/ipv6cp.c ppp-2.4.4/pppd/ipv6cp.c
330 --- ppp-2.4.4.orig/pppd/ipv6cp.c 2005-08-25 19:59:34.000000000 -0400
331 +++ ppp-2.4.4/pppd/ipv6cp.c 2009-05-07 16:16:20.000000000 -0400
332 @@ -1232,7 +1232,7 @@
336 - demand_rexmit(PPP_IPV6);
337 + demand_rexmit(PPP_IPV6,0);
338 sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
341 diff -Naur ppp-2.4.4.orig/pppd/pppd.h ppp-2.4.4/pppd/pppd.h
342 --- ppp-2.4.4.orig/pppd/pppd.h 2009-05-07 15:49:34.000000000 -0400
343 +++ ppp-2.4.4/pppd/pppd.h 2009-05-07 16:16:20.000000000 -0400
345 void demand_block __P((void)); /* set all NPs to queue up packets */
346 void demand_unblock __P((void)); /* set all NPs to pass packets */
347 void demand_discard __P((void)); /* set all NPs to discard packets */
348 -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
349 +void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
350 int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
351 int loop_frame __P((unsigned char *, int)); /* should we bring link up? */