1 diff -uNr --exclude=.p4config --exclude=redhat ppp/pppd/main.c ppp-mpls/pppd/main.c
2 --- ppp/pppd/main.c 2006-06-03 22:52:50.000000000 -0500
3 +++ ppp-mpls/pppd/main.c 2007-08-10 00:05:21.000000000 -0500
22 diff -uNr --exclude=.p4config --exclude=redhat ppp/pppd/Makefile.linux ppp-mpls/pppd/Makefile.linux
23 --- ppp/pppd/Makefile.linux 2007-08-28 00:35:23.000000000 -0500
24 +++ ppp-mpls/pppd/Makefile.linux 2007-08-10 00:05:19.000000000 -0500
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
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 \
35 + upap.h eap.h mplscp.h
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 \
41 + eap.o chap-md5.o mplscp.o
44 # include dependencies if present
45 diff -uNr --exclude=.p4config --exclude=redhat ppp/pppd/mplscp.c ppp-mpls/pppd/mplscp.c
46 --- ppp/pppd/mplscp.c 1969-12-31 18:00:00.000000000 -0600
47 +++ ppp-mpls/pppd/mplscp.c 2006-08-09 22:05:35.000000000 -0500
50 +/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */
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>
67 +/* static int mplscp_is_up; */ /* have called np_up() */
70 + * Callbacks for fsm code. (CI = Configuration Information)
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 */
83 +fsm mplscp_fsm[NUM_PPP]; /* MPLSCP fsm structure */
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 */
103 +static option_t mplscp_option_list[] = {
104 + { "mpls", o_bool, &mplscp_protent.enabled_flag,
105 + "Enable MPLSCP (and MPLS)", 1 },
109 + * Protocol entry points from main code.
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 *));
122 +struct protent mplscp_protent = {
133 + 0, /* MPLS not enabled by default */
136 + mplscp_option_list,
143 + * mplscp_init - Initialize MPLSCP.
146 +mplscp_init(int unit) {
148 + fsm *f = &mplscp_fsm[unit];
151 + f->protocol = PPP_MPLSCP;
152 + f->callbacks = &mplscp_callbacks;
153 + fsm_init(&mplscp_fsm[unit]);
158 + * mplscp_open - MPLSCP is allowed to come up.
161 +mplscp_open(int unit) {
163 + fsm_open(&mplscp_fsm[unit]);
168 + * mplscp_close - Take MPLSCP down.
171 +mplscp_close(int unit, char *reason) {
173 + fsm_close(&mplscp_fsm[unit], reason);
178 + * mplscp_lowerup - The lower layer is up.
181 +mplscp_lowerup(int unit) {
183 + fsm_lowerup(&mplscp_fsm[unit]);
187 + * mplscp_lowerdown - The lower layer is down.
190 +mplscp_lowerdown(int unit) {
192 + fsm_lowerdown(&mplscp_fsm[unit]);
196 + * mplscp_input - Input MPLSCP packet.
199 +mplscp_input(int unit, u_char *p, int len) {
201 + fsm_input(&mplscp_fsm[unit], p, len);
205 + * mplscp_protrej - A Protocol-Reject was received for MPLSCP.
206 + * Pretend the lower layer went down, so we shut up.
209 +mplscp_protrej(int unit) {
211 + fsm_lowerdown(&mplscp_fsm[unit]);
215 + * mplscp_resetci - Reset our CI.
216 + * Called by fsm_sconfreq, Send Configure Request.
219 +mplscp_resetci(fsm *f) {
225 + * mplscp_cilen - Return length of our CI.
226 + * Called by fsm_sconfreq, Send Configure Request.
229 +mplscp_cilen(fsm *f) {
235 + * mplscp_addci - Add our desired CIs to a packet.
236 + * Called by fsm_sconfreq, Send Configure Request.
239 +mplscp_addci(fsm *f, u_char *ucp, int *lenp) {
244 + * ipcp_ackci - Ack our CIs.
245 + * Called by fsm_rconfack, Receive Configure ACK.
249 + * 1 - Ack was good.
252 +mplscp_ackci(fsm *f, u_char *p, int len) {
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.
266 + * 1 - Nak was good.
269 +mplscp_nakci(fsm *f, u_char *p, int len) {
275 + * MPLSVP_rejci - Reject some of our CIs.
276 + * Callback from fsm_rconfnakrej.
279 +mplscp_rejci(fsm *f, u_char *p, int len) {
286 + * mplscp_reqci - Check the peer's requested CIs and send appropriate response.
287 + * Callback from fsm_rconfreq, Receive Configure Request
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.
294 +mplscp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
297 + int rc = CONFACK; /* Final packet return code */
299 + PUTCHAR(CONFACK,inp);
308 + sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_PASS);
309 + /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_PASS);*/
311 + np_up(f->unit, PPP_MPLS_UC);
312 + /* np_up(f->unit, PPP_MPLS_MC);*/
313 + /* ipcp_is_up = 1;*/
317 + printf("MPLSCP is OPENED\n");
323 +mplscp_down(fsm *f) {
325 + sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_DROP);
326 + /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_DROP);*/
331 + printf("MPLSCP is CLOSED\n");
338 +mplscp_finished(fsm *f) {
340 + np_finished(f->unit, PPP_MPLS_UC);
341 + /* np_finished(f->unit, PPP_MPLS_MC);*/
346 + * mpls_printpkt - print the contents of an MPLSCP packet.
348 +static char *mplscp_codenames[] = {
349 + "ConfReq", "ConfAck", "ConfNak", "ConfRej",
350 + "TermReq", "TermAck", "CodeRej"
354 +mplscp_printpkt(u_char *p, int plen,
355 + void (*printer) __P((void *, char *, ...)),
358 + int code, id, len, olen;
359 + u_char *pstart, *optend;
361 + if (plen < HEADERLEN)
367 + if (len < HEADERLEN || len > plen)
370 + if (code >= 1 && code <= sizeof(mplscp_codenames) / sizeof(char *))
371 + printer(arg, " %s", mplscp_codenames[code-1]);
373 + printer(arg, " code=0x%x", code);
374 + printer(arg, " id=0x%x", id);
381 + /* print option list */
386 + if (olen < 2 || olen > len) {
389 + printer(arg, " <");
392 + while (p < optend) {
394 + printer(arg, " %.2x", code);
402 + if (len > 0 && *p >= ' ' && *p < 0x7f) {
404 + print_string((char *)p, len, printer, arg);
411 + /* print the rest of the bytes in the packet */
412 + for (; len > 0; --len) {
414 + printer(arg, " %.2x", code);
420 diff -uNr --exclude=.p4config --exclude=redhat ppp/pppd/mplscp.h ppp-mpls/pppd/mplscp.h
421 --- ppp/pppd/mplscp.h 1969-12-31 18:00:00.000000000 -0600
422 +++ ppp-mpls/pppd/mplscp.h 2006-08-09 22:05:20.000000000 -0500
425 +/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */
427 +#define PPP_MPLSCP 0x8281
428 +#define PPP_MPLS_UC 0x0281
429 +#define PPP_MPLS_MC 0x0283
431 +extern struct protent mplscp_protent;