Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 797 - (hide annotations) (download)
Mon May 11 09:46:04 2009 UTC (15 years ago) by niro
File size: 8473 byte(s)
-added patches from gentoo

1 niro 797 diff -ru ppp-2.4.4.orig/pppd/ipcp.c ppp-2.4.4/pppd/ipcp.c
2     --- ppp-2.4.4.orig/pppd/ipcp.c 2005-08-26 01:59:34.000000000 +0200
3     +++ ppp-2.4.4/pppd/ipcp.c 2008-08-17 21:02:36.000000000 +0200
4     @@ -90,6 +90,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     @@ -209,6 +210,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     @@ -687,6 +691,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     @@ -714,8 +720,9 @@
32    
33     #define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0)
34     #define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0)
35     -#define LENCIADDR(neg) (neg ? CILEN_ADDR : 0)
36     -#define LENCIDNS(neg) (neg ? (CILEN_ADDR) : 0)
37     +#define LENCIADDR(neg) ((neg) ? CILEN_ADDR : 0)
38     +#define LENCIDNS(neg) LENCIADDR(neg)
39     +#define LENCIWINS(neg) LENCIADDR(neg)
40    
41     /*
42     * First see if we want to change our options to the old
43     @@ -737,7 +744,9 @@
44     LENCIVJ(go->neg_vj, go->old_vj) +
45     LENCIADDR(go->neg_addr) +
46     LENCIDNS(go->req_dns1) +
47     - LENCIDNS(go->req_dns2)) ;
48     + LENCIDNS(go->req_dns2) +
49     + LENCIWINS(go->req_wins1) +
50     + LENCIWINS(go->req_wins2));
51     }
52    
53    
54     @@ -810,6 +819,19 @@
55     } else \
56     neg = 0; \
57     }
58     +
59     +#define ADDCIWINS(opt, neg, addr) \
60     + if (neg) { \
61     + if (len >= CILEN_ADDR) { \
62     + u_int32_t l; \
63     + PUTCHAR(opt, ucp); \
64     + PUTCHAR(CILEN_ADDR, ucp); \
65     + l = ntohl(addr); \
66     + PUTLONG(l, ucp); \
67     + len -= CILEN_ADDR; \
68     + } else \
69     + neg = 0; \
70     + }
71    
72     ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
73     go->hisaddr);
74     @@ -823,6 +845,10 @@
75    
76     ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
77    
78     + ADDCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
79     +
80     + ADDCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
81     +
82     *lenp -= len;
83     }
84    
85     @@ -926,6 +952,21 @@
86     goto bad; \
87     }
88    
89     +#define ACKCIWINS(opt, neg, addr) \
90     + if (neg) { \
91     + u_int32_t l; \
92     + if ((len -= CILEN_ADDR) < 0) \
93     + goto bad; \
94     + GETCHAR(citype, p); \
95     + GETCHAR(cilen, p); \
96     + if (cilen != CILEN_ADDR || citype != opt) \
97     + goto bad; \
98     + GETLONG(l, p); \
99     + cilong = htonl(l); \
100     + if (addr != cilong) \
101     + goto bad; \
102     + }
103     +
104     ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
105     go->hisaddr);
106    
107     @@ -938,6 +979,10 @@
108    
109     ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
110    
111     + ACKCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
112     +
113     + ACKCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
114     +
115     /*
116     * If there are any remaining CIs, then this packet is bad.
117     */
118     @@ -971,7 +1016,7 @@
119     u_char cimaxslotindex, cicflag;
120     u_char citype, cilen, *next;
121     u_short cishort;
122     - u_int32_t ciaddr1, ciaddr2, l, cidnsaddr;
123     + u_int32_t ciaddr1, ciaddr2, l, cidnsaddr, ciwinsaddr;
124     ipcp_options no; /* options we've seen Naks for */
125     ipcp_options try; /* options to request next time */
126    
127     @@ -1036,6 +1081,19 @@
128     code \
129     }
130    
131     +#define NAKCIWINS(opt, neg, code) \
132     + if (go->neg && \
133     + ((cilen = p[1]) == CILEN_ADDR) && \
134     + len >= cilen && \
135     + p[0] == opt) { \
136     + len -= cilen; \
137     + INCPTR(2, p); \
138     + GETLONG(l, p); \
139     + ciwinsaddr = htonl(l); \
140     + no.neg = 1; \
141     + code \
142     + }
143     +
144     /*
145     * Accept the peer's idea of {our,his} address, if different
146     * from our idea, only if the accept_{local,remote} flag is set.
147     @@ -1112,6 +1170,22 @@
148     }
149     );
150    
151     + NAKCIWINS(CI_MS_WINS1, req_wins1,
152     + if (treat_as_reject) {
153     + try.req_wins1 = 0;
154     + } else {
155     + try.winsaddr[0] = ciwinsaddr;
156     + }
157     + );
158     +
159     + NAKCIWINS(CI_MS_WINS2, req_wins2,
160     + if (treat_as_reject) {
161     + try.req_wins2 = 0;
162     + } else {
163     + try.winsaddr[1] = ciwinsaddr;
164     + }
165     + );
166     +
167     /*
168     * There may be remaining CIs, if the peer is requesting negotiation
169     * on an option that we didn't include in our request packet.
170     @@ -1275,6 +1349,21 @@
171     try.neg = 0; \
172     }
173    
174     +#define REJCIWINS(opt, neg, addr) \
175     + if (go->neg && \
176     + ((cilen = p[1]) == CILEN_ADDR) && \
177     + len >= cilen && \
178     + p[0] == opt) { \
179     + u_int32_t l; \
180     + len -= cilen; \
181     + INCPTR(2, p); \
182     + GETLONG(l, p); \
183     + cilong = htonl(l); \
184     + /* Check rejected value. */ \
185     + if (cilong != addr) \
186     + goto bad; \
187     + try.neg = 0; \
188     + }
189    
190     REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
191     go->ouraddr, go->hisaddr);
192     @@ -1288,6 +1377,10 @@
193    
194     REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]);
195    
196     + REJCIWINS(CI_MS_WINS1, req_wins1, go->winsaddr[0]);
197     +
198     + REJCIWINS(CI_MS_WINS2, req_wins2, go->winsaddr[1]);
199     +
200     /*
201     * If there are any remaining CIs, then this packet is bad.
202     */
203     @@ -1480,7 +1573,7 @@
204     /* Microsoft primary or secondary WINS request */
205     d = citype == CI_MS_WINS2;
206    
207     - /* If we do not have a DNS address then we cannot send it */
208     + /* If we do not have a WINS address then we cannot send it */
209     if (ao->winsaddr[d] == 0 ||
210     cilen != CILEN_ADDR) { /* Check CI length */
211     orc = CONFREJ; /* Reject CI */
212     @@ -1723,6 +1816,13 @@
213     create_resolv(go->dnsaddr[0], go->dnsaddr[1]);
214     }
215    
216     + if (go->winsaddr[0])
217     + script_setenv("WINS1", ip_ntoa(go->winsaddr[0]), 0);
218     + if (go->winsaddr[1])
219     + script_setenv("WINS2", ip_ntoa(go->winsaddr[1]), 0);
220     + if (usepeerwins && (go->winsaddr[0] || go->winsaddr[1]))
221     + script_setenv("USEPEERWINS", "1", 0);
222     +
223     /*
224     * Check that the peer is allowed to use the IP address it wants.
225     */
226     diff -ru ppp-2.4.4.orig/pppd/ipcp.h ppp-2.4.4/pppd/ipcp.h
227     --- ppp-2.4.4.orig/pppd/ipcp.h 2002-12-05 01:03:32.000000000 +0200
228     +++ ppp-2.4.4/pppd/ipcp.h 2008-08-17 21:01:55.000000000 +0200
229     @@ -77,6 +77,8 @@
230     bool accept_remote; /* accept peer's value for hisaddr */
231     bool req_dns1; /* Ask peer to send primary DNS address? */
232     bool req_dns2; /* Ask peer to send secondary DNS address? */
233     + bool req_wins1; /* Ask peer to send primary WINS address? */
234     + bool req_wins2; /* Ask peer to send secondary WINS address? */
235     int vj_protocol; /* protocol value to use in VJ option */
236     int maxslotindex; /* values for RFC1332 VJ compression neg. */
237     bool cflag;
238     diff -ru ppp-2.4.4.orig/pppd/pppd.8 ppp-2.4.4/pppd/pppd.8
239     --- ppp-2.4.4.orig/pppd/pppd.8 2008-08-17 21:01:30.000000000 +0200
240     +++ ppp-2.4.4/pppd/pppd.8 2008-08-17 21:05:38.000000000 +0200
241     @@ -1052,6 +1052,16 @@
242     /etc/ppp/resolv.conf file containing one or two nameserver lines with
243     the address(es) supplied by the peer.
244     .TP
245     +.B usepeerwins
246     +Ask the peer for up to 2 WINS server addresses. The addresses supplied
247     +by the peer (if any) are passed to the /etc/ppp/ip\-up script in the
248     +environment variables WINS1 and WINS2, and the environment variable
249     +USEPEERWINS will be set to 1.
250     +.LP
251     +Please note that some modems (like the Huawei E220) requires this option in
252     +order to avoid a race condition that results in the incorrect DNS servers
253     +being assigned.
254     +.TP
255     .B user \fIname
256     Sets the name used for authenticating the local system to the peer to
257     \fIname\fR.
258     @@ -1603,6 +1613,15 @@
259     .B DNS2
260     If the peer supplies DNS server addresses, this variable is set to the
261     second DNS server address supplied.
262     +.TP
263     +.B WINS1
264     +If the peer supplies WINS server addresses, this variable is set to the
265     +first WINS server address supplied.
266     +.TP
267     +.B WINS2
268     +If the peer supplies WINS server addresses, this variable is set to the
269     +second WINS server address supplied.
270     +.P
271     .P
272     Pppd invokes the following scripts, if they exist. It is not an error
273     if they don't exist.