Magellan Linux

Annotation of /trunk/ppp/patches/ppp-2.4.5-pppd-usepeerwins.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1107 - (hide annotations) (download)
Fri Aug 20 10:59:46 2010 UTC (13 years, 8 months ago) by niro
File size: 8070 byte(s)
-reworked patch to apply with ppp-2.4.5

1 niro 1107 diff -Naur ppp-2.4.5/pppd/ipcp.c ppp-2.4.5-magellan/pppd/ipcp.c
2     --- ppp-2.4.5/pppd/ipcp.c 2009-11-16 23:26:07.000000000 +0100
3     +++ ppp-2.4.5-magellan/pppd/ipcp.c 2010-08-20 13:03:52.000000000 +0200
4     @@ -91,6 +91,7 @@
5     static int default_route_set[NUM_PPP]; /* Have set up a default route */
6     static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */
7     static bool usepeerdns; /* Ask peer for DNS addrs */
8     +static bool usepeerwins; /* Ask peer for WINS addrs */
9     static int ipcp_is_up; /* have called np_up() */
10     static int ipcp_is_open; /* haven't called np_finished() */
11     static bool ask_for_local; /* request our address from peer */
12     @@ -210,6 +211,9 @@
13     { "usepeerdns", o_bool, &usepeerdns,
14     "Ask peer for DNS address(es)", 1 },
15    
16     + { "usepeerwins", o_bool, &usepeerwins,
17     + "Ask peer for WINS address(es)", 1 },
18     +
19     { "netmask", o_special, (void *)setnetmask,
20     "set netmask", OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, netmask_str },
21    
22     @@ -703,6 +707,8 @@
23     wo->accept_remote = 1;
24     wo->req_dns1 = usepeerdns; /* Request DNS addresses from the peer */
25     wo->req_dns2 = usepeerdns;
26     + wo->req_wins1 = usepeerwins; /* Request WINS addresses from the peer */
27     + wo->req_wins2 = usepeerwins;
28     *go = *wo;
29     if (!ask_for_local)
30     go->ouraddr = 0;
31     @@ -755,8 +761,8 @@
32     LENCIADDR(go->neg_addr) +
33     LENCIDNS(go->req_dns1) +
34     LENCIDNS(go->req_dns2) +
35     - LENCIWINS(go->winsaddr[0]) +
36     - LENCIWINS(go->winsaddr[1])) ;
37     + LENCIWINS(go->req_wins1) +
38     + LENCIWINS(go->req_wins2)) ;
39     }
40    
41    
42     @@ -830,8 +836,8 @@
43     neg = 0; \
44     }
45    
46     -#define ADDCIWINS(opt, addr) \
47     - if (addr) { \
48     +#define ADDCIWINS(opt, neg, addr) \
49     + if (neg) { \
50     if (len >= CILEN_ADDR) { \
51     u_int32_t l; \
52     PUTCHAR(opt, ucp); \
53     @@ -840,7 +846,7 @@
54     PUTLONG(l, ucp); \
55     len -= CILEN_ADDR; \
56     } else \
57     - addr = 0; \
58     + neg = 0; \
59     }
60    
61     ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
62     @@ -855,9 +861,9 @@
63    
64     ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
65    
66     - ADDCIWINS(CI_MS_WINS1, go->winsaddr[0]);
67     + ADDCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
68    
69     - ADDCIWINS(CI_MS_WINS2, go->winsaddr[1]);
70     + ADDCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
71    
72     *lenp -= len;
73     }
74     @@ -962,6 +968,21 @@
75     goto bad; \
76     }
77    
78     +#define ACKCIWINS(opt, neg, addr) \
79     + if (neg) { \
80     + u_int32_t l; \
81     + if ((len -= CILEN_ADDR) < 0) \
82     + goto bad; \
83     + GETCHAR(citype, p); \
84     + GETCHAR(cilen, p); \
85     + if (cilen != CILEN_ADDR || citype != opt) \
86     + goto bad; \
87     + GETLONG(l, p); \
88     + cilong = htonl(l); \
89     + if (addr != cilong) \
90     + goto bad; \
91     + }
92     +
93     ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
94     go->hisaddr);
95    
96     @@ -974,6 +995,10 @@
97    
98     ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
99    
100     + ACKCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
101     +
102     + ACKCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
103     +
104     /*
105     * If there are any remaining CIs, then this packet is bad.
106     */
107     @@ -1007,7 +1032,7 @@
108     u_char cimaxslotindex, cicflag;
109     u_char citype, cilen, *next;
110     u_short cishort;
111     - u_int32_t ciaddr1, ciaddr2, l, cidnsaddr;
112     + u_int32_t ciaddr1, ciaddr2, l, cidnsaddr, ciwinsaddr;
113     ipcp_options no; /* options we've seen Naks for */
114     ipcp_options try; /* options to request next time */
115    
116     @@ -1072,6 +1097,19 @@
117     code \
118     }
119    
120     +#define NAKCIWINS(opt, neg, code) \
121     + if (go->neg && \
122     + ((cilen = p[1]) == CILEN_ADDR) && \
123     + len >= cilen && \
124     + p[0] == opt) { \
125     + len -= cilen; \
126     + INCPTR(2, p); \
127     + GETLONG(l, p); \
128     + ciwinsaddr = htonl(l); \
129     + no.neg = 1; \
130     + code \
131     + }
132     +
133     /*
134     * Accept the peer's idea of {our,his} address, if different
135     * from our idea, only if the accept_{local,remote} flag is set.
136     @@ -1148,6 +1186,22 @@
137     }
138     );
139    
140     + NAKCIWINS(CI_MS_WINS1, req_wins1,
141     + if (treat_as_reject) {
142     + try.req_wins1 = 0;
143     + } else {
144     + try.winsaddr[0] = ciwinsaddr;
145     + }
146     + );
147     +
148     + NAKCIWINS(CI_MS_WINS2, req_wins2,
149     + if (treat_as_reject) {
150     + try.req_wins2 = 0;
151     + } else {
152     + try.winsaddr[1] = ciwinsaddr;
153     + }
154     + );
155     +
156     /*
157     * There may be remaining CIs, if the peer is requesting negotiation
158     * on an option that we didn't include in our request packet.
159     @@ -1338,8 +1392,8 @@
160     try.neg = 0; \
161     }
162    
163     -#define REJCIWINS(opt, addr) \
164     - if (addr && \
165     +#define REJCIWINS(opt, neg, addr) \
166     + if (go->neg && \
167     ((cilen = p[1]) == CILEN_ADDR) && \
168     len >= cilen && \
169     p[0] == opt) { \
170     @@ -1351,7 +1405,7 @@
171     /* Check rejected value. */ \
172     if (cilong != addr) \
173     goto bad; \
174     - try.winsaddr[opt == CI_MS_WINS2] = 0; \
175     + try.neg = 0; \
176     }
177    
178     REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
179     @@ -1366,9 +1420,9 @@
180    
181     REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]);
182    
183     - REJCIWINS(CI_MS_WINS1, go->winsaddr[0]);
184     + REJCIWINS(CI_MS_WINS1, req_wins1, go->winsaddr[0]);
185    
186     - REJCIWINS(CI_MS_WINS2, go->winsaddr[1]);
187     + REJCIWINS(CI_MS_WINS2, req_wins2, go->winsaddr[1]);
188    
189     /*
190     * If there are any remaining CIs, then this packet is bad.
191     @@ -1542,7 +1596,7 @@
192     /* Microsoft primary or secondary DNS request */
193     d = citype == CI_MS_DNS2;
194    
195     - /* If we do not have a DNS address then we cannot send it */
196     + /* If we do not have a WINS address then we cannot send it */
197     if (ao->dnsaddr[d] == 0 ||
198     cilen != CILEN_ADDR) { /* Check CI length */
199     orc = CONFREJ; /* Reject CI */
200     @@ -1811,6 +1865,13 @@
201     create_resolv(go->dnsaddr[0], go->dnsaddr[1]);
202     }
203    
204     + if (go->winsaddr[0])
205     + script_setenv("WINS1", ip_ntoa(go->winsaddr[0]), 0);
206     + if (go->winsaddr[1])
207     + script_setenv("WINS2", ip_ntoa(go->winsaddr[1]), 0);
208     + if (usepeerwins && (go->winsaddr[0] || go->winsaddr[1]))
209     + script_setenv("USEPEERWINS", "1", 0);
210     +
211     /*
212     * Check that the peer is allowed to use the IP address it wants.
213     */
214     diff -Naur ppp-2.4.5/pppd/ipcp.h ppp-2.4.5-magellan/pppd/ipcp.h
215     --- ppp-2.4.5/pppd/ipcp.h 2009-11-16 23:26:07.000000000 +0100
216     +++ ppp-2.4.5-magellan/pppd/ipcp.h 2010-08-20 13:04:28.000000000 +0200
217     @@ -77,6 +77,8 @@
218     bool accept_remote; /* accept peer's value for hisaddr */
219     bool req_dns1; /* Ask peer to send primary DNS address? */
220     bool req_dns2; /* Ask peer to send secondary DNS address? */
221     + bool req_wins1; /* Ask peer to send primary WINS address? */
222     + bool req_wins2; /* Ask peer to send secondary WINS address? */
223     int vj_protocol; /* protocol value to use in VJ option */
224     int maxslotindex; /* values for RFC1332 VJ compression neg. */
225     bool cflag;
226     diff -Naur ppp-2.4.5/pppd/pppd.8 ppp-2.4.5-magellan/pppd/pppd.8
227     --- ppp-2.4.5/pppd/pppd.8 2009-11-16 23:26:07.000000000 +0100
228     +++ ppp-2.4.5-magellan/pppd/pppd.8 2010-08-20 13:05:38.000000000 +0200
229     @@ -1070,6 +1070,16 @@
230     /etc/ppp/resolv.conf file containing one or two nameserver lines with
231     the address(es) supplied by the peer.
232     .TP
233     +.B usepeerwins
234     +Ask the peer for up to 2 WINS server addresses. The addresses supplied
235     +by the peer (if any) are passed to the /etc/ppp/ip\-up script in the
236     +environment variables WINS1 and WINS2, and the environment variable
237     +USEPEERWINS will be set to 1.
238     +.LP
239     +Please note that some modems (like the Huawei E220) requires this option in
240     +order to avoid a race condition that results in the incorrect DNS servers
241     +being assigned.
242     +.TP
243     .B user \fIname
244     Sets the name used for authenticating the local system to the peer to
245     \fIname\fR.
246     @@ -1616,6 +1626,15 @@
247     .B DNS2
248     If the peer supplies DNS server addresses, this variable is set to the
249     second DNS server address supplied.
250     +.TP
251     +.B WINS1
252     +If the peer supplies WINS server addresses, this variable is set to the
253     +first WINS server address supplied.
254     +.TP
255     +.B WINS2
256     +If the peer supplies WINS server addresses, this variable is set to the
257     +second WINS server address supplied.
258     +.P
259     .P
260     Pppd invokes the following scripts, if they exist. It is not an error
261     if they don't exist.