Annotation of /trunk/ppp/patches/ppp-2.4.4-mpls.patch
Parent Directory | Revision Log
Revision 797 -
(hide annotations)
(download)
Mon May 11 09:46:04 2009 UTC (15 years, 4 months ago) by niro
File size: 10466 byte(s)
Mon May 11 09:46:04 2009 UTC (15 years, 4 months ago) by niro
File size: 10466 byte(s)
-added patches from gentoo
1 | niro | 797 | diff -Nru ppp-2.4.4.orig/pppd/main.c ppp-2.4.4/pppd/main.c |
2 | --- ppp-2.4.4.orig/pppd/main.c 2006-06-04 06:52:50.000000000 +0300 | ||
3 | +++ ppp-2.4.4/pppd/main.c 2006-08-22 07:36:08.882124000 +0300 | ||
4 | @@ -96,6 +96,9 @@ | ||
5 | #include "fsm.h" | ||
6 | #include "lcp.h" | ||
7 | #include "ipcp.h" | ||
8 | + | ||
9 | +#include "mplscp.h" | ||
10 | + | ||
11 | #ifdef INET6 | ||
12 | #include "ipv6cp.h" | ||
13 | #endif | ||
14 | @@ -282,6 +285,7 @@ | ||
15 | &cbcp_protent, | ||
16 | #endif | ||
17 | &ipcp_protent, | ||
18 | + &mplscp_protent, | ||
19 | #ifdef INET6 | ||
20 | &ipv6cp_protent, | ||
21 | #endif | ||
22 | diff -Nru ppp-2.4.4.orig/pppd/Makefile.linux ppp-2.4.4/pppd/Makefile.linux | ||
23 | --- ppp-2.4.4.orig/pppd/Makefile.linux 2006-08-22 07:25:23.981820250 +0300 | ||
24 | +++ ppp-2.4.4/pppd/Makefile.linux 2006-08-22 07:36:08.882124000 +0300 | ||
25 | @@ -13,16 +13,16 @@ | ||
26 | |||
27 | PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \ | ||
28 | ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \ | ||
29 | - demand.c utils.c tty.c eap.c chap-md5.c | ||
30 | + demand.c utils.c tty.c eap.c chap-md5.c mplscp.c | ||
31 | |||
32 | HEADERS = ccp.h chap-new.h ecp.h fsm.h ipcp.h \ | ||
33 | ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \ | ||
34 | - upap.h eap.h | ||
35 | + upap.h eap.h mplscp.h | ||
36 | |||
37 | MANPAGES = pppd.8 | ||
38 | PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \ | ||
39 | ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \ | ||
40 | - eap.o chap-md5.o | ||
41 | + eap.o chap-md5.o mplscp.o | ||
42 | |||
43 | # | ||
44 | # include dependencies if present | ||
45 | diff -Nru ppp-2.4.4.orig/pppd/mplscp.c ppp-2.4.4/pppd/mplscp.c | ||
46 | --- ppp-2.4.4.orig/pppd/mplscp.c 1970-01-01 02:00:00.000000000 +0200 | ||
47 | +++ ppp-2.4.4/pppd/mplscp.c 2006-08-22 07:36:08.882124000 +0300 | ||
48 | @@ -0,0 +1,371 @@ | ||
49 | + | ||
50 | +/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */ | ||
51 | + | ||
52 | +#include <stdio.h> | ||
53 | +#include <string.h> | ||
54 | +#include <netdb.h> | ||
55 | +#include <sys/param.h> | ||
56 | +#include <sys/types.h> | ||
57 | +#include <sys/socket.h> | ||
58 | +#include <netinet/in.h> | ||
59 | +#include <arpa/inet.h> | ||
60 | + | ||
61 | +#include "pppd.h" | ||
62 | +#include "fsm.h" | ||
63 | +#include "mplscp.h" | ||
64 | + | ||
65 | + | ||
66 | +/* local vars */ | ||
67 | +/* static int mplscp_is_up; */ /* have called np_up() */ | ||
68 | + | ||
69 | +/* | ||
70 | + * Callbacks for fsm code. (CI = Configuration Information) | ||
71 | + */ | ||
72 | +static void mplscp_resetci __P((fsm *)); /* Reset our CI */ | ||
73 | +static int mplscp_cilen __P((fsm *)); /* Return length of our CI */ | ||
74 | +static void mplscp_addci __P((fsm *, u_char *, int *)); /* Add our CI */ | ||
75 | +static int mplscp_ackci __P((fsm *, u_char *, int)); /* Peer ack'd our CI */ | ||
76 | +static int mplscp_nakci __P((fsm *, u_char *, int)); /* Peer nak'd our CI */ | ||
77 | +static int mplscp_rejci __P((fsm *, u_char *, int)); /* Peer rej'd our CI */ | ||
78 | +static int mplscp_reqci __P((fsm *, u_char *, int *, int)); /* Rcv CI */ | ||
79 | +static void mplscp_up __P((fsm *)); /* We're UP */ | ||
80 | +static void mplscp_down __P((fsm *)); /* We're DOWN */ | ||
81 | +static void mplscp_finished __P((fsm *)); /* Don't need lower layer */ | ||
82 | + | ||
83 | +fsm mplscp_fsm[NUM_PPP]; /* MPLSCP fsm structure */ | ||
84 | + | ||
85 | +static fsm_callbacks mplscp_callbacks = { /* MPLSCP callback routines */ | ||
86 | + mplscp_resetci, /* Reset our Configuration Information */ | ||
87 | + mplscp_cilen, /* Length of our Configuration Information */ | ||
88 | + mplscp_addci, /* Add our Configuration Information */ | ||
89 | + mplscp_ackci, /* ACK our Configuration Information */ | ||
90 | + mplscp_nakci, /* NAK our Configuration Information */ | ||
91 | + mplscp_rejci, /* Reject our Configuration Information */ | ||
92 | + mplscp_reqci, /* Request peer's Configuration Information */ | ||
93 | + mplscp_up, /* Called when fsm reaches OPENED state */ | ||
94 | + mplscp_down, /* Called when fsm leaves OPENED state */ | ||
95 | + NULL, /* Called when we want the lower layer up */ | ||
96 | + mplscp_finished, /* Called when we want the lower layer down */ | ||
97 | + NULL, /* Called when Protocol-Reject received */ | ||
98 | + NULL, /* Retransmission is necessary */ | ||
99 | + NULL, /* Called to handle protocol-specific codes */ | ||
100 | + "MPLSCP" /* String name of protocol */ | ||
101 | +}; | ||
102 | + | ||
103 | +static option_t mplscp_option_list[] = { | ||
104 | + { "mpls", o_bool, &mplscp_protent.enabled_flag, | ||
105 | + "Enable MPLSCP (and MPLS)", 1 }, | ||
106 | + { NULL } }; | ||
107 | + | ||
108 | +/* | ||
109 | + * Protocol entry points from main code. | ||
110 | + */ | ||
111 | + | ||
112 | +static void mplscp_init __P((int)); | ||
113 | +static void mplscp_open __P((int)); | ||
114 | +static void mplscp_close __P((int, char *)); | ||
115 | +static void mplscp_lowerup __P((int)); | ||
116 | +static void mplscp_lowerdown __P((int)); | ||
117 | +static void mplscp_input __P((int, u_char *, int)); | ||
118 | +static void mplscp_protrej __P((int)); | ||
119 | +static int mplscp_printpkt __P((u_char *, int, | ||
120 | + void (*) __P((void *, char *, ...)), void *)); | ||
121 | + | ||
122 | +struct protent mplscp_protent = { | ||
123 | + PPP_MPLSCP, | ||
124 | + mplscp_init, | ||
125 | + mplscp_input, | ||
126 | + mplscp_protrej, | ||
127 | + mplscp_lowerup, | ||
128 | + mplscp_lowerdown, | ||
129 | + mplscp_open, | ||
130 | + mplscp_close, | ||
131 | + mplscp_printpkt, | ||
132 | + NULL, | ||
133 | + 0, /* MPLS not enabled by default */ | ||
134 | + "MPLSCP", | ||
135 | + "MPLS", | ||
136 | + mplscp_option_list, | ||
137 | + NULL, | ||
138 | + NULL, | ||
139 | + NULL | ||
140 | +}; | ||
141 | + | ||
142 | +/* | ||
143 | + * mplscp_init - Initialize MPLSCP. | ||
144 | + */ | ||
145 | +static void | ||
146 | +mplscp_init(int unit) { | ||
147 | + | ||
148 | + fsm *f = &mplscp_fsm[unit]; | ||
149 | + | ||
150 | + f->unit = unit; | ||
151 | + f->protocol = PPP_MPLSCP; | ||
152 | + f->callbacks = &mplscp_callbacks; | ||
153 | + fsm_init(&mplscp_fsm[unit]); | ||
154 | + | ||
155 | +} | ||
156 | + | ||
157 | +/* | ||
158 | + * mplscp_open - MPLSCP is allowed to come up. | ||
159 | + */ | ||
160 | +static void | ||
161 | +mplscp_open(int unit) { | ||
162 | + | ||
163 | + fsm_open(&mplscp_fsm[unit]); | ||
164 | + | ||
165 | +} | ||
166 | + | ||
167 | +/* | ||
168 | + * mplscp_close - Take MPLSCP down. | ||
169 | + */ | ||
170 | +static void | ||
171 | +mplscp_close(int unit, char *reason) { | ||
172 | + | ||
173 | + fsm_close(&mplscp_fsm[unit], reason); | ||
174 | + | ||
175 | +} | ||
176 | + | ||
177 | +/* | ||
178 | + * mplscp_lowerup - The lower layer is up. | ||
179 | + */ | ||
180 | +static void | ||
181 | +mplscp_lowerup(int unit) { | ||
182 | + | ||
183 | + fsm_lowerup(&mplscp_fsm[unit]); | ||
184 | +} | ||
185 | + | ||
186 | +/* | ||
187 | + * mplscp_lowerdown - The lower layer is down. | ||
188 | + */ | ||
189 | +static void | ||
190 | +mplscp_lowerdown(int unit) { | ||
191 | + | ||
192 | + fsm_lowerdown(&mplscp_fsm[unit]); | ||
193 | +} | ||
194 | + | ||
195 | +/* | ||
196 | + * mplscp_input - Input MPLSCP packet. | ||
197 | + */ | ||
198 | +static void | ||
199 | +mplscp_input(int unit, u_char *p, int len) { | ||
200 | + | ||
201 | + fsm_input(&mplscp_fsm[unit], p, len); | ||
202 | +} | ||
203 | + | ||
204 | +/* | ||
205 | + * mplscp_protrej - A Protocol-Reject was received for MPLSCP. | ||
206 | + * Pretend the lower layer went down, so we shut up. | ||
207 | + */ | ||
208 | +static void | ||
209 | +mplscp_protrej(int unit) { | ||
210 | + | ||
211 | + fsm_lowerdown(&mplscp_fsm[unit]); | ||
212 | +} | ||
213 | + | ||
214 | +/* | ||
215 | + * mplscp_resetci - Reset our CI. | ||
216 | + * Called by fsm_sconfreq, Send Configure Request. | ||
217 | + */ | ||
218 | +static void | ||
219 | +mplscp_resetci(fsm *f) { | ||
220 | + | ||
221 | + return; | ||
222 | +} | ||
223 | + | ||
224 | +/* | ||
225 | + * mplscp_cilen - Return length of our CI. | ||
226 | + * Called by fsm_sconfreq, Send Configure Request. | ||
227 | + */ | ||
228 | +static int | ||
229 | +mplscp_cilen(fsm *f) { | ||
230 | + | ||
231 | + return 0; | ||
232 | +} | ||
233 | + | ||
234 | +/* | ||
235 | + * mplscp_addci - Add our desired CIs to a packet. | ||
236 | + * Called by fsm_sconfreq, Send Configure Request. | ||
237 | + */ | ||
238 | +static void | ||
239 | +mplscp_addci(fsm *f, u_char *ucp, int *lenp) { | ||
240 | + | ||
241 | +} | ||
242 | + | ||
243 | +/* | ||
244 | + * ipcp_ackci - Ack our CIs. | ||
245 | + * Called by fsm_rconfack, Receive Configure ACK. | ||
246 | + * | ||
247 | + * Returns: | ||
248 | + * 0 - Ack was bad. | ||
249 | + * 1 - Ack was good. | ||
250 | + */ | ||
251 | +static int | ||
252 | +mplscp_ackci(fsm *f, u_char *p, int len) { | ||
253 | + | ||
254 | + return 1; | ||
255 | + | ||
256 | +} | ||
257 | + | ||
258 | +/* | ||
259 | + * mplscp_nakci - Peer has sent a NAK for some of our CIs. | ||
260 | + * This should not modify any state if the Nak is bad | ||
261 | + * or if MPLSCP is in the OPENED state. | ||
262 | + * Calback from fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. | ||
263 | + * | ||
264 | + * Returns: | ||
265 | + * 0 - Nak was bad. | ||
266 | + * 1 - Nak was good. | ||
267 | + */ | ||
268 | +static int | ||
269 | +mplscp_nakci(fsm *f, u_char *p, int len) { | ||
270 | + | ||
271 | + return 1; | ||
272 | +} | ||
273 | + | ||
274 | +/* | ||
275 | + * MPLSVP_rejci - Reject some of our CIs. | ||
276 | + * Callback from fsm_rconfnakrej. | ||
277 | + */ | ||
278 | +static int | ||
279 | +mplscp_rejci(fsm *f, u_char *p, int len) { | ||
280 | + | ||
281 | + return 1; | ||
282 | + | ||
283 | +} | ||
284 | + | ||
285 | +/* | ||
286 | + * mplscp_reqci - Check the peer's requested CIs and send appropriate response. | ||
287 | + * Callback from fsm_rconfreq, Receive Configure Request | ||
288 | + * | ||
289 | + * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified | ||
290 | + * appropriately. If reject_if_disagree is non-zero, doesn't return | ||
291 | + * CONFNAK; returns CONFREJ if it can't return CONFACK. | ||
292 | + */ | ||
293 | +static int | ||
294 | +mplscp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { | ||
295 | + | ||
296 | + | ||
297 | + int rc = CONFACK; /* Final packet return code */ | ||
298 | + | ||
299 | + PUTCHAR(CONFACK,inp); | ||
300 | + | ||
301 | + return rc; | ||
302 | + | ||
303 | +} | ||
304 | + | ||
305 | +static void | ||
306 | +mplscp_up(fsm *f) { | ||
307 | + | ||
308 | + sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_PASS); | ||
309 | + /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_PASS);*/ | ||
310 | + | ||
311 | + np_up(f->unit, PPP_MPLS_UC); | ||
312 | + /* np_up(f->unit, PPP_MPLS_MC);*/ | ||
313 | + /* ipcp_is_up = 1;*/ | ||
314 | + | ||
315 | + | ||
316 | +#if 1 | ||
317 | + printf("MPLSCP is OPENED\n"); | ||
318 | +#endif | ||
319 | + | ||
320 | +} | ||
321 | + | ||
322 | +static void | ||
323 | +mplscp_down(fsm *f) { | ||
324 | + | ||
325 | + sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_DROP); | ||
326 | + /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_DROP);*/ | ||
327 | + | ||
328 | + sifdown(f->unit); | ||
329 | + | ||
330 | +#if 1 | ||
331 | + printf("MPLSCP is CLOSED\n"); | ||
332 | +#endif | ||
333 | + | ||
334 | + | ||
335 | +} | ||
336 | + | ||
337 | +static void | ||
338 | +mplscp_finished(fsm *f) { | ||
339 | + | ||
340 | + np_finished(f->unit, PPP_MPLS_UC); | ||
341 | + /* np_finished(f->unit, PPP_MPLS_MC);*/ | ||
342 | + | ||
343 | +} | ||
344 | + | ||
345 | +/* | ||
346 | + * mpls_printpkt - print the contents of an MPLSCP packet. | ||
347 | + */ | ||
348 | +static char *mplscp_codenames[] = { | ||
349 | + "ConfReq", "ConfAck", "ConfNak", "ConfRej", | ||
350 | + "TermReq", "TermAck", "CodeRej" | ||
351 | +}; | ||
352 | + | ||
353 | +static int | ||
354 | +mplscp_printpkt(u_char *p, int plen, | ||
355 | + void (*printer) __P((void *, char *, ...)), | ||
356 | + void *arg) { | ||
357 | + | ||
358 | + int code, id, len, olen; | ||
359 | + u_char *pstart, *optend; | ||
360 | + | ||
361 | + if (plen < HEADERLEN) | ||
362 | + return 0; | ||
363 | + pstart = p; | ||
364 | + GETCHAR(code, p); | ||
365 | + GETCHAR(id, p); | ||
366 | + GETSHORT(len, p); | ||
367 | + if (len < HEADERLEN || len > plen) | ||
368 | + return 0; | ||
369 | + | ||
370 | + if (code >= 1 && code <= sizeof(mplscp_codenames) / sizeof(char *)) | ||
371 | + printer(arg, " %s", mplscp_codenames[code-1]); | ||
372 | + else | ||
373 | + printer(arg, " code=0x%x", code); | ||
374 | + printer(arg, " id=0x%x", id); | ||
375 | + len -= HEADERLEN; | ||
376 | + switch (code) { | ||
377 | + case CONFREQ: | ||
378 | + case CONFACK: | ||
379 | + case CONFNAK: | ||
380 | + case CONFREJ: | ||
381 | + /* print option list */ | ||
382 | + while (len >= 2) { | ||
383 | + GETCHAR(code, p); | ||
384 | + GETCHAR(olen, p); | ||
385 | + p -= 2; | ||
386 | + if (olen < 2 || olen > len) { | ||
387 | + break; | ||
388 | + } | ||
389 | + printer(arg, " <"); | ||
390 | + len -= olen; | ||
391 | + optend = p + olen; | ||
392 | + while (p < optend) { | ||
393 | + GETCHAR(code, p); | ||
394 | + printer(arg, " %.2x", code); | ||
395 | + } | ||
396 | + printer(arg, ">"); | ||
397 | + } | ||
398 | + break; | ||
399 | + | ||
400 | + case TERMACK: | ||
401 | + case TERMREQ: | ||
402 | + if (len > 0 && *p >= ' ' && *p < 0x7f) { | ||
403 | + printer(arg, " "); | ||
404 | + print_string((char *)p, len, printer, arg); | ||
405 | + p += len; | ||
406 | + len = 0; | ||
407 | + } | ||
408 | + break; | ||
409 | + } | ||
410 | + | ||
411 | + /* print the rest of the bytes in the packet */ | ||
412 | + for (; len > 0; --len) { | ||
413 | + GETCHAR(code, p); | ||
414 | + printer(arg, " %.2x", code); | ||
415 | + } | ||
416 | + | ||
417 | + return p - pstart; | ||
418 | + | ||
419 | +} | ||
420 | diff -Nru ppp-2.4.4.orig/pppd/mplscp.h ppp-2.4.4/pppd/mplscp.h | ||
421 | --- ppp-2.4.4.orig/pppd/mplscp.h 1970-01-01 02:00:00.000000000 +0200 | ||
422 | +++ ppp-2.4.4/pppd/mplscp.h 2006-08-22 07:36:08.898125000 +0300 | ||
423 | @@ -0,0 +1,8 @@ | ||
424 | + | ||
425 | +/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */ | ||
426 | + | ||
427 | +#define PPP_MPLSCP 0x8281 | ||
428 | +#define PPP_MPLS_UC 0x0281 | ||
429 | +#define PPP_MPLS_MC 0x0283 | ||
430 | + | ||
431 | +extern struct protent mplscp_protent; |