fix potential rootfs owner/group mismatch (tgz root only, patch from #4562)
[openwrt.git] / package / ppp / patches / 109-debian_demand.patch
1 Index: ppp-2.4.3/pppd/demand.c
2 ===================================================================
3 --- ppp-2.4.3.orig/pppd/demand.c 2007-06-04 13:22:08.217606016 +0200
4 +++ ppp-2.4.3/pppd/demand.c 2007-06-04 13:22:11.613089824 +0200
5 @@ -36,6 +36,8 @@
6 #include <errno.h>
7 #include <fcntl.h>
8 #include <netdb.h>
9 +#include <unistd.h>
10 +#include <syslog.h>
11 #include <sys/param.h>
12 #include <sys/types.h>
13 #include <sys/wait.h>
14 @@ -43,6 +45,8 @@
15 #include <sys/resource.h>
16 #include <sys/stat.h>
17 #include <sys/socket.h>
18 +#include <netinet/in.h>
19 +#include <arpa/inet.h>
20 #ifdef PPP_FILTER
21 #include <pcap-bpf.h>
22 #endif
23 @@ -221,6 +225,14 @@
24 int c, rv;
25
26 rv = 0;
27 +
28 +/* check for synchronous connection... */
29 +
30 + if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
31 + rv = loop_frame(p,n);
32 + return rv;
33 + }
34 +
35 for (; n > 0; --n) {
36 c = *p++;
37 if (c == PPP_FLAG) {
38 @@ -299,17 +311,102 @@
39 * loopback, now that the real serial link is up.
40 */
41 void
42 -demand_rexmit(proto)
43 +demand_rexmit(proto, newip)
44 int proto;
45 + u_int32_t newip;
46 {
47 struct packet *pkt, *prev, *nextpkt;
48 + unsigned short checksum;
49 + unsigned short pkt_checksum = 0;
50 + unsigned iphdr;
51 + struct timeval tv;
52 + char cv = 0;
53 + char ipstr[16];
54
55 prev = NULL;
56 pkt = pend_q;
57 pend_q = NULL;
58 + tv.tv_sec = 1;
59 + tv.tv_usec = 0;
60 + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
61 for (; pkt != NULL; pkt = nextpkt) {
62 nextpkt = pkt->next;
63 if (PPP_PROTOCOL(pkt->data) == proto) {
64 + if ( (proto == PPP_IP) && newip ) {
65 + /* Get old checksum */
66 +
67 + iphdr = (pkt->data[4] & 15) << 2;
68 + checksum = *((unsigned short *) (pkt->data+14));
69 + if (checksum == 0xFFFF) {
70 + checksum = 0;
71 + }
72 +
73 +
74 + if (pkt->data[13] == 17) {
75 + pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
76 + if (pkt_checksum) {
77 + cv = 1;
78 + if (pkt_checksum == 0xFFFF) {
79 + pkt_checksum = 0;
80 + }
81 + }
82 + else {
83 + cv = 0;
84 + }
85 + }
86 +
87 + if (pkt->data[13] == 6) {
88 + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
89 + cv = 1;
90 + if (pkt_checksum == 0xFFFF) {
91 + pkt_checksum = 0;
92 + }
93 + }
94 +
95 + /* Delete old Source-IP-Address */
96 + checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
97 + checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
98 +
99 + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
100 + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
101 +
102 + /* Change Source-IP-Address */
103 + * ((u_int32_t *) (pkt->data + 16)) = newip;
104 +
105 + /* Add new Source-IP-Address */
106 + checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
107 + checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
108 +
109 + pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
110 + pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
111 +
112 + /* Write new checksum */
113 + if (!checksum) {
114 + checksum = 0xFFFF;
115 + }
116 + *((unsigned short *) (pkt->data+14)) = checksum;
117 + if (pkt->data[13] == 6) {
118 + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
119 + }
120 + if (cv && (pkt->data[13] == 17) ) {
121 + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
122 + }
123 +
124 + /* Log Packet */
125 + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
126 + if (pkt->data[13] == 1) {
127 + syslog(LOG_INFO,"Open ICMP %s -> %s\n",
128 + ipstr,
129 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
130 + } else {
131 + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
132 + pkt->data[13] == 6 ? "TCP" : "UDP",
133 + ipstr,
134 + ntohs(*( (short *) (pkt->data+iphdr+4))),
135 + inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
136 + ntohs(*( (short *) (pkt->data+iphdr+6))));
137 + }
138 + }
139 output(0, pkt->data, pkt->length);
140 free(pkt);
141 } else {
142 Index: ppp-2.4.3/pppd/ipcp.c
143 ===================================================================
144 --- ppp-2.4.3.orig/pppd/ipcp.c 2007-06-04 13:22:11.387124176 +0200
145 +++ ppp-2.4.3/pppd/ipcp.c 2007-06-04 13:22:11.614089672 +0200
146 @@ -1796,7 +1796,7 @@
147 proxy_arp_set[f->unit] = 1;
148
149 }
150 - demand_rexmit(PPP_IP);
151 + demand_rexmit(PPP_IP,go->ouraddr);
152 sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
153
154 } else {
155 Index: ppp-2.4.3/pppd/ipv6cp.c
156 ===================================================================
157 --- ppp-2.4.3.orig/pppd/ipv6cp.c 2007-06-04 13:22:08.229604192 +0200
158 +++ ppp-2.4.3/pppd/ipv6cp.c 2007-06-04 13:22:11.614089672 +0200
159 @@ -1232,7 +1232,7 @@
160 }
161
162 }
163 - demand_rexmit(PPP_IPV6);
164 + demand_rexmit(PPP_IPV6,0);
165 sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
166
167 } else {
168 Index: ppp-2.4.3/pppd/pppd.h
169 ===================================================================
170 --- ppp-2.4.3.orig/pppd/pppd.h 2007-06-04 13:22:11.388124024 +0200
171 +++ ppp-2.4.3/pppd/pppd.h 2007-06-04 13:22:11.615089520 +0200
172 @@ -563,7 +563,7 @@
173 void demand_block __P((void)); /* set all NPs to queue up packets */
174 void demand_unblock __P((void)); /* set all NPs to pass packets */
175 void demand_discard __P((void)); /* set all NPs to discard packets */
176 -void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
177 +void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
178 int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
179 int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
180
This page took 0.048593 seconds and 5 git commands to generate.