* lcp.c - PPP Link Control Protocol.
* Copyright (c) 1989 Carnegie Mellon University.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by Carnegie Mellon University. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char rcsid
[] = "$Id: lcp.c,v 1.2 1994/03/30 09:31:31 jkh Exp $";
fsm lcp_fsm
[_NPPP
]; /* LCP fsm structure (global)*/
lcp_options lcp_wantoptions
[_NPPP
]; /* Options that we want to request */
lcp_options lcp_gotoptions
[_NPPP
]; /* Options that peer ack'd */
lcp_options lcp_allowoptions
[_NPPP
]; /* Options we allow peer to request */
lcp_options lcp_hisoptions
[_NPPP
]; /* Options that we ack'd */
* Callbacks for fsm code. (CI = Configuration Information)
static void lcp_resetci
__ARGS((fsm
*)); /* Reset our CI */
static int lcp_cilen
__ARGS((fsm
*)); /* Return length of our CI */
static void lcp_addci
__ARGS((fsm
*, u_char
*, int *)); /* Add our CI to pkt */
static int lcp_ackci
__ARGS((fsm
*, u_char
*, int)); /* Peer ack'd our CI */
static int lcp_nakci
__ARGS((fsm
*, u_char
*, int)); /* Peer nak'd our CI */
static int lcp_rejci
__ARGS((fsm
*, u_char
*, int)); /* Peer rej'd our CI */
static int lcp_reqci
__ARGS((fsm
*, u_char
*, int *, int)); /* Rcv peer CI */
static void lcp_up
__ARGS((fsm
*)); /* We're UP */
static void lcp_down
__ARGS((fsm
*)); /* We're DOWN */
static void lcp_starting
__ARGS((fsm
*)); /* We need lower layer up */
static void lcp_finished
__ARGS((fsm
*)); /* We need lower layer down */
static int lcp_extcode
__ARGS((fsm
*, int, int, u_char
*, int));
static void lcp_rprotrej
__ARGS((fsm
*, u_char
*, int));
static fsm_callbacks lcp_callbacks
= { /* LCP callback routines */
lcp_resetci
, /* Reset our Configuration Information */
lcp_cilen
, /* Length of our Configuration Information */
lcp_addci
, /* Add our Configuration Information */
lcp_ackci
, /* ACK our Configuration Information */
lcp_nakci
, /* NAK our Configuration Information */
lcp_rejci
, /* Reject our Configuration Information */
lcp_reqci
, /* Request peer's Configuration Information */
lcp_up
, /* Called when fsm reaches OPENED state */
lcp_down
, /* Called when fsm leaves OPENED state */
lcp_starting
, /* Called when we want the lower layer up */
lcp_finished
, /* Called when we want the lower layer down */
NULL
, /* Called when Protocol-Reject received */
NULL
, /* Retransmission is necessary */
lcp_extcode
, /* Called to handle LCP-specific codes */
"LCP" /* String name of protocol */
int lcp_warnloops
= DEFWARNLOOPS
; /* Warn about a loopback this often */
* Length of each type of configuration option (in octets)
#define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */
#define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */
#define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */
#define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */
#define CODENAME(x) ((x) == CONFACK ? "ACK" : \
(x) == CONFNAK ? "NAK" : "REJ")
* lcp_init - Initialize LCP.
lcp_options
*wo
= &lcp_wantoptions
[unit
];
lcp_options
*ao
= &lcp_allowoptions
[unit
];
f
->callbacks
= &lcp_callbacks
;
wo
->restart
= 0; /* Set to 1 in kernels or multi-line
wo
->neg_chap
= 0; /* Set to 1 on server */
wo
->neg_upap
= 0; /* Set to 1 on server */
wo
->chap_mdtype
= CHAP_DIGEST_MD5
;
wo
->neg_pcompression
= 1;
wo
->neg_accompression
= 1;
wo
->neg_lqr
= 0; /* no LQR implementation yet */
ao
->chap_mdtype
= CHAP_DIGEST_MD5
;
ao
->neg_pcompression
= 1;
ao
->neg_accompression
= 1;
ao
->neg_lqr
= 0; /* no LQR implementation yet */
* lcp_open - LCP is allowed to come up.
lcp_options
*wo
= &lcp_wantoptions
[unit
];
* lcp_close - Take LCP down.
fsm_close(&lcp_fsm
[unit
]);
* lcp_lowerup - The lower layer is up.
ppp_send_config(unit
, MTU
, 0xffffffff, 0, 0);
ppp_recv_config(unit
, MTU
, 0, 0, 0);
fsm_lowerup(&lcp_fsm
[unit
]);
* lcp_lowerdown - The lower layer is down.
fsm_lowerdown(&lcp_fsm
[unit
]);
* lcp_input - Input LCP packet.
fsm_input(&lcp_fsm
[unit
], p
, len
);
* lcp_extcode - Handle a LCP-specific code.
lcp_extcode(f
, code
, id
, inp
, len
)
lcp_rprotrej(f
, inp
, len
);
LCPDEBUG((LOG_INFO
, "lcp: Echo-Request, Rcvd id %d", id
));
fsm_sdata(f
, ECHOREP
, id
, inp
, len
);
* lcp_rprotrej - Receive an Protocol-Reject.
* Figure out which protocol is rejected and inform it.
lcp_rprotrej(f
, inp
, len
)
LCPDEBUG((LOG_INFO
, "lcp_rprotrej."));
if (len
< sizeof (u_short
)) {
"lcp_rprotrej: Rcvd short Protocol-Reject packet!"));
"lcp_rprotrej: Rcvd Protocol-Reject packet for %x!",
* Protocol-Reject packets received in any state other than the LCP
* OPENED state SHOULD be silently discarded.
if( f
->state
!= OPENED
){
LCPDEBUG((LOG_INFO
, "Protocol-Reject discarded: LCP in state %d",
DEMUXPROTREJ(f
->unit
, prot
); /* Inform protocol */
* lcp_protrej - A Protocol-Reject was received.
"lcp_protrej: Received Protocol-Reject for LCP!"));
fsm_protreject(&lcp_fsm
[unit
]);
* lcp_sprotrej - Send a Protocol-Reject for some protocol.
lcp_sprotrej(unit
, p
, len
)
* Send back the protocol and the information field of the
* rejected packet. We only get here if LCP is in the OPENED state.
fsm_sdata(&lcp_fsm
[unit
], PROTREJ
, ++lcp_fsm
[unit
].id
,
* lcp_resetci - Reset our CI.
lcp_wantoptions
[f
->unit
].magicnumber
= magic();
lcp_wantoptions
[f
->unit
].numloops
= 0;
lcp_gotoptions
[f
->unit
] = lcp_wantoptions
[f
->unit
];
* lcp_cilen - Return length of our CI.
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
#define LENCIVOID(neg) (neg ? CILEN_VOID : 0)
#define LENCICHAP(neg) (neg ? CILEN_CHAP : 0)
#define LENCISHORT(neg) (neg ? CILEN_SHORT : 0)
#define LENCILONG(neg) (neg ? CILEN_LONG : 0)
#define LENCILQR(neg) (neg ? CILEN_LQR: 0)
* NB: we only ask for one of CHAP and UPAP, even if we will
return (LENCISHORT(go
->neg_mru
) +
LENCILONG(go
->neg_asyncmap
) +
LENCICHAP(go
->neg_chap
) +
LENCISHORT(!go
->neg_chap
&& go
->neg_upap
) +
LENCILONG(go
->neg_magicnumber
) +
LENCIVOID(go
->neg_pcompression
) +
LENCIVOID(go
->neg_accompression
));
* lcp_addci - Add our desired CIs to a packet.
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
#define ADDCIVOID(opt, neg) \
PUTCHAR(CILEN_VOID, ucp); \
#define ADDCISHORT(opt, neg, val) \
PUTCHAR(CILEN_SHORT, ucp); \
#define ADDCICHAP(opt, neg, val, digest) \
PUTCHAR(CILEN_CHAP, ucp); \
#define ADDCILONG(opt, neg, val) \
PUTCHAR(CILEN_LONG, ucp); \
#define ADDCILQR(opt, neg, val) \
PUTCHAR(CILEN_LQR, ucp); \
ADDCISHORT(CI_MRU
, go
->neg_mru
, go
->mru
);
ADDCILONG(CI_ASYNCMAP
, go
->neg_asyncmap
, go
->asyncmap
);
ADDCICHAP(CI_AUTHTYPE
, go
->neg_chap
, CHAP
, go
->chap_mdtype
);
ADDCISHORT(CI_AUTHTYPE
, !go
->neg_chap
&& go
->neg_upap
, UPAP
);
ADDCILQR(CI_QUALITY
, go
->neg_lqr
, go
->lqr_period
);
ADDCILONG(CI_MAGICNUMBER
, go
->neg_magicnumber
, go
->magicnumber
);
ADDCIVOID(CI_PCOMPRESSION
, go
->neg_pcompression
);
ADDCIVOID(CI_ACCOMPRESSION
, go
->neg_accompression
);
if (ucp
- start_ucp
!= *lenp
) {
/* this should never happen, because peer_mtu should be 1500 */
syslog(LOG_ERR
, "Bug in lcp_addci: wrong length");
* lcp_ackci - Ack our CIs.
* This should not modify any state if the Ack is bad.
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
u_char cilen
, citype
, cichar
;
* CIs must be in exactly the same order that we sent.
* Check packet length and CI length at each step.
* If we find any deviations, then this packet is bad.
#define ACKCIVOID(opt, neg) \
if ((len -= CILEN_VOID) < 0) \
if (cilen != CILEN_VOID || \
#define ACKCISHORT(opt, neg, val) \
if ((len -= CILEN_SHORT) < 0) \
if (cilen != CILEN_SHORT || \
#define ACKCICHAP(opt, neg, val, digest) \
if ((len -= CILEN_CHAP) < 0) \
if (cilen != CILEN_CHAP || \
#define ACKCILONG(opt, neg, val) \
if ((len -= CILEN_LONG) < 0) \
if (cilen != CILEN_LONG || \
#define ACKCILQR(opt, neg, val) \
if ((len -= CILEN_LQR) < 0) \
if (cilen != CILEN_LQR || \
ACKCISHORT(CI_MRU
, go
->neg_mru
, go
->mru
);
ACKCILONG(CI_ASYNCMAP
, go
->neg_asyncmap
, go
->asyncmap
);
ACKCICHAP(CI_AUTHTYPE
, go
->neg_chap
, CHAP
, go
->chap_mdtype
);
ACKCISHORT(CI_AUTHTYPE
, !go
->neg_chap
&& go
->neg_upap
, UPAP
);
ACKCILQR(CI_QUALITY
, go
->neg_lqr
, go
->lqr_period
);
ACKCILONG(CI_MAGICNUMBER
, go
->neg_magicnumber
, go
->magicnumber
);
ACKCIVOID(CI_PCOMPRESSION
, go
->neg_pcompression
);
ACKCIVOID(CI_ACCOMPRESSION
, go
->neg_accompression
);
* If there are any remaining CIs, then this packet is bad.
LCPDEBUG((LOG_WARNING
, "lcp_acki: received bad Ack!"));
* lcp_nakci - Peer has sent a NAK for some of our CIs.
* This should not modify any state if the Nak is bad
* or if LCP is in the OPENED state.
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
lcp_options
*wo
= &lcp_wantoptions
[f
->unit
];
u_char cilen
, citype
, cichar
, *next
;
lcp_options no
; /* options we've seen Naks for */
lcp_options
try; /* options to request next time */
* Any Nak'd CIs must be in exactly the same order that we sent.
* Check packet length and CI length at each step.
* If we find any deviations, then this packet is bad.
#define NAKCIVOID(opt, neg, code) \
#define NAKCICHAP(opt, neg, code) \
#define NAKCISHORT(opt, neg, code) \
#define NAKCILONG(opt, neg, code) \
#define NAKCILQR(opt, neg, code) \
* We don't care if they want to send us smaller packets than
* we want. Therefore, accept any MRU less than what we asked for,
* but then ignore the new value when setting the MRU in the kernel.
* If they send us a bigger MRU than what we asked, accept it, up to
* the limit of the default MRU we'd get if we didn't negotiate.
NAKCISHORT(CI_MRU
, neg_mru
,
if (cishort
<= wo
->mru
|| cishort
< DEFMRU
)
* Add any characters they want to our (receive-side) asyncmap.
NAKCILONG(CI_ASYNCMAP
, neg_asyncmap
,
try.asyncmap
= go
->asyncmap
| cilong
;
* If they can't cope with our CHAP hash algorithm, we'll have
* to stop asking for CHAP. We haven't got any other algorithm.
NAKCICHAP(CI_AUTHTYPE
, neg_chap
,
* Peer shouldn't send Nak for UPAP, protocol compression or
* address/control compression requests; they should send
* a Reject instead. If they send a Nak, treat it as a Reject.
NAKCISHORT(CI_AUTHTYPE
, neg_upap
,
* If they can't cope with our link quality protocol, we'll have
* to stop asking for LQR. We haven't got any other protocol.
* If they Nak the reporting period, take their value XXX ?
NAKCILONG(CI_QUALITY
, neg_lqr
,
* Check for a looped-back line.
NAKCILONG(CI_MAGICNUMBER
, neg_magicnumber
,
try.magicnumber
= magic();
NAKCIVOID(CI_PCOMPRESSION
, neg_pcompression
,
try.neg_pcompression
= 0;
NAKCIVOID(CI_ACCOMPRESSION
, neg_accompression
,
try.neg_accompression
= 0;
* There may be remaining CIs, if the peer is requesting negotiation
* on an option that we didn't include in our request packet.
* If we see an option that we requested, or one we've already seen
* in this packet, then this packet is bad.
* If we wanted to respond by starting to negotiate on the requested
* option(s), we could, but we don't, because except for the
* authentication type and quality protocol, if we are not negotiating
* an option, it is because we were told not to.
* For the authentication type, the Nak from the peer means
* `let me authenticate myself with you' which is a bit pointless.
* For the quality protocol, the Nak means `ask me to send you quality
* reports', but if we didn't ask for them, we don't want them.
while (len
> CILEN_VOID
) {
if (go
->neg_mru
|| no
.neg_mru
|| cilen
!= CILEN_SHORT
)
if (go
->neg_asyncmap
|| no
.neg_asyncmap
|| cilen
!= CILEN_LONG
)
if (go
->neg_chap
|| no
.neg_chap
|| go
->neg_upap
|| no
.neg_upap
)
if (go
->neg_magicnumber
|| no
.neg_magicnumber
||
if (go
->neg_pcompression
|| no
.neg_pcompression
if (go
->neg_accompression
|| no
.neg_accompression
if (go
->neg_lqr
|| no
.neg_lqr
|| cilen
!= CILEN_LQR
)
/* If there is still anything left, this packet is bad. */
* OK, the Nak is good. Now we can update state.
if (f
->state
!= OPENED
) {
if (looped_back
&& try.numloops
% lcp_warnloops
== 0)
LCPDEBUG((LOG_INFO
, "The line appears to be looped back."));
LCPDEBUG((LOG_WARNING
, "lcp_nakci: received bad Nak!"));
* lcp_rejci - Peer has Rejected some of our CIs.
* This should not modify any state if the Reject is bad
* or if LCP is in the OPENED state.
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
lcp_options
try; /* options to request next time */
* Any Rejected CIs must be in exactly the same order that we sent.
* Check packet length and CI length at each step.
* If we find any deviations, then this packet is bad.
#define REJCIVOID(opt, neg) \
LCPDEBUG((LOG_INFO, "lcp_rejci rejected void opt %d", opt)); \
#define REJCISHORT(opt, neg, val) \
/* Check rejected value. */ \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected short opt %d", opt)); \
#define REJCICHAP(opt, neg, val, digest) \
/* Check rejected value. */ \
if (cishort != val || cichar != digest) \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected chap opt %d", opt)); \
#define REJCILONG(opt, neg, val) \
/* Check rejected value. */ \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected long opt %d", opt)); \
#define REJCILQR(opt, neg, val) \
/* Check rejected value. */ \
if (cishort != LQR || cichar != val) \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected LQR opt %d", opt)); \
REJCISHORT(CI_MRU
, neg_mru
, go
->mru
);
REJCILONG(CI_ASYNCMAP
, neg_asyncmap
, go
->asyncmap
);
REJCICHAP(CI_AUTHTYPE
, neg_chap
, CHAP
, go
->chap_mdtype
);
REJCISHORT(CI_AUTHTYPE
, neg_upap
, UPAP
);
REJCILQR(CI_QUALITY
, neg_lqr
, go
->lqr_period
);
REJCILONG(CI_MAGICNUMBER
, neg_magicnumber
, go
->magicnumber
);
REJCIVOID(CI_PCOMPRESSION
, neg_pcompression
);
REJCIVOID(CI_ACCOMPRESSION
, neg_accompression
);
* If there are any remaining CIs, then this packet is bad.
* Now we can update state.
LCPDEBUG((LOG_WARNING
, "lcp_rejci: received bad Reject!"));
LCPDEBUG((LOG_WARNING
, "lcp_rejci: plen %d len %d off %d",
* lcp_reqci - Check the peer's requested CIs and send appropriate response.
* Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
* appropriately. If reject_if_disagree is non-zero, doesn't return
* CONFNAK; returns CONFREJ if it can't return CONFACK.
lcp_reqci(f
, inp
, lenp
, reject_if_disagree
)
u_char
*inp
; /* Requested CIs */
int *lenp
; /* Length of requested CIs */
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
lcp_options
*ho
= &lcp_hisoptions
[f
->unit
];
lcp_options
*ao
= &lcp_allowoptions
[f
->unit
];
u_char
*cip
, *next
; /* Pointer to current and next CIs */
u_char cilen
, citype
, cichar
;/* Parsed len, type, char value */
u_short cishort
; /* Parsed short value */
u_long cilong
; /* Parse long value */
int rc
= CONFACK
; /* Final packet return code */
int orc
; /* Individual option return code */
u_char
*p
; /* Pointer to next char to parse */
u_char
*ucp
= inp
; /* Pointer to current output char */
int l
= *lenp
; /* Length left */
* Process all his options.
orc
= CONFACK
; /* Assume success */
cip
= p
= next
; /* Remember begining of CI */
if (l
< 2 || /* Not enough data for CI header or */
p
[1] < 2 || /* CI length too small or */
p
[1] > l
) { /* CI length too big? */
LCPDEBUG((LOG_WARNING
, "lcp_reqci: bad CI length!"));
orc
= CONFREJ
; /* Reject bad CI */
cilen
= l
; /* Reject till end of packet */
l
= 0; /* Don't loop again */
GETCHAR(citype
, p
); /* Parse CI type */
GETCHAR(cilen
, p
); /* Parse CI length */
l
-= cilen
; /* Adjust remaining length */
next
+= cilen
; /* Step to next CI */
switch (citype
) { /* Check CI type */
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd MRU"));
if (!ao
->neg_mru
|| /* Allow option? */
cilen
!= CILEN_SHORT
) { /* Check CI length */
orc
= CONFREJ
; /* Reject CI */
GETSHORT(cishort
, p
); /* Parse MRU */
LCPDEBUG((LOG_INFO
, "(%d)", cishort
));
* He must be able to receive at least our minimum.
* No need to check a maximum. If he sends a large number,
orc
= CONFNAK
; /* Nak CI */
if( !reject_if_disagree
){
DECPTR(sizeof (short), p
); /* Backup */
PUTSHORT(MINMRU
, p
); /* Give him a hint */
ho
->neg_mru
= 1; /* Remember he sent MRU */
ho
->mru
= cishort
; /* And remember value */
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd ASYNCMAP"));
LCPDEBUG((LOG_INFO
, "(%lx)", cilong
));
* Asyncmap must have set at least the bits
* which are set in lcp_allowoptions[unit].asyncmap.
if ((ao
->asyncmap
& ~cilong
) != 0) {
if( !reject_if_disagree
){
DECPTR(sizeof (long), p
);
PUTLONG(ao
->asyncmap
| cilong
, p
);
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd AUTHTYPE"));
if (cilen
< CILEN_SHORT
||
!(ao
->neg_upap
|| ao
->neg_chap
)) {
LCPDEBUG((LOG_INFO
, "(%x)", cishort
));
* Authtype must be UPAP or CHAP.
* Note: if both ao->neg_upap and ao->neg_chap are set,
* and the peer sends a Configure-Request with two
* authenticate-protocol requests, one for CHAP and one
* for UPAP, then we will reject the second request.
* Whether we end up doing CHAP or UPAP depends then on
* the ordering of the CIs in the peer's Configure-Request.
if (!ao
->neg_upap
|| /* we don't want to do PAP */
ho
->neg_chap
|| /* or we've already accepted CHAP */
"lcp_reqci: rcvd AUTHTYPE PAP, rejecting..."));
if (!ao
->neg_chap
|| /* we don't want to do CHAP */
ho
->neg_upap
|| /* or we've already accepted UPAP */
"lcp_reqci: rcvd AUTHTYPE CHAP, rejecting..."));
GETCHAR(cichar
, p
); /* get digest type*/
if (cichar
!= ao
->chap_mdtype
) {
if( !reject_if_disagree
){
DECPTR(sizeof (u_char
), p
);
PUTCHAR(ao
->chap_mdtype
, p
);
ho
->chap_mdtype
= cichar
; /* save md type */
* We don't recognize the protocol they're asking for.
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd QUALITY"));
LCPDEBUG((LOG_INFO
, "(%x %lx)", cishort
, cilong
));
* Check the reporting period.
* XXX When should we Nak this, and what with?
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd MAGICNUMBER"));
if (!(ao
->neg_magicnumber
|| go
->neg_magicnumber
) ||
LCPDEBUG((LOG_INFO
, "(%lx)", cilong
));
* He must have a different magic number.
if (go
->neg_magicnumber
&&
cilong
== go
->magicnumber
) {
DECPTR(sizeof (long), p
);
cilong
= magic(); /* Don't put magic() inside macro! */
ho
->magicnumber
= cilong
;
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd PCOMPRESSION"));
if (!ao
->neg_pcompression
||
ho
->neg_pcompression
= 1;
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd ACCOMPRESSION"));
if (!ao
->neg_accompression
||
ho
->neg_accompression
= 1;
LCPDEBUG((LOG_INFO
, "lcp_reqci: rcvd unknown option %d",
LCPDEBUG((LOG_INFO
, " (%s)", CODENAME(orc
)));
if (orc
== CONFACK
&& /* Good CI */
rc
!= CONFACK
) /* but prior CI wasnt? */
continue; /* Don't send this one */
if (orc
== CONFNAK
) { /* Nak this CI? */
if (reject_if_disagree
) /* Getting fed up with sending NAKs? */
orc
= CONFREJ
; /* Get tough if so */
if (rc
== CONFREJ
) /* Rejecting prior CI? */
continue; /* Don't send this one */
if (rc
== CONFACK
) { /* Ack'd all prior CIs? */
rc
= CONFNAK
; /* Not anymore... */
if (orc
== CONFREJ
&& /* Reject this CI */
rc
!= CONFREJ
) { /* but no prior ones? */
if (ucp
!= cip
) /* Need to move CI? */
BCOPY(cip
, ucp
, cilen
); /* Move it */
INCPTR(cilen
, ucp
); /* Update output pointer */
* If we wanted to send additional NAKs (for unsent CIs), the
* code would go here. This must be done with care since it might
* require a longer packet than we received. At present there
* are no cases where we want to ask the peer to negotiate an option.
*lenp
= ucp
- inp
; /* Compute output length */
LCPDEBUG((LOG_INFO
, "lcp_reqci: returning CONF%s.", CODENAME(rc
)));
return (rc
); /* Return final code */
* lcp_up - LCP has come UP.
lcp_options
*wo
= &lcp_wantoptions
[f
->unit
];
lcp_options
*ho
= &lcp_hisoptions
[f
->unit
];
lcp_options
*go
= &lcp_gotoptions
[f
->unit
];
lcp_options
*ao
= &lcp_allowoptions
[f
->unit
];
* Set our MTU to the smaller of the MTU we wanted and
* the MRU our peer wanted. If we negotiated an MRU,
* set our MRU to the larger of value we wanted and
* the value we got in the negotiation.
ppp_send_config(f
->unit
, (ho
->neg_mru
? MIN(ao
->mru
, ho
->mru
): MTU
),
(ho
->neg_asyncmap
? ho
->asyncmap
: 0xffffffff),
ho
->neg_pcompression
, ho
->neg_accompression
);
ppp_recv_config(f
->unit
, (go
->neg_mru
? MAX(wo
->mru
, go
->mru
): MTU
),
(go
->neg_asyncmap
? go
->asyncmap
: 0xffffffff),
go
->neg_pcompression
, go
->neg_accompression
);
peer_mru
[f
->unit
] = ho
->mru
;
ChapLowerUp(f
->unit
); /* Enable CHAP */
upap_lowerup(f
->unit
); /* Enable UPAP */
ipcp_lowerup(f
->unit
); /* Enable IPCP */
link_established(f
->unit
);
* lcp_down - LCP has gone DOWN.
ppp_send_config(f
->unit
, MTU
, 0xffffffff, 0, 0);
ppp_recv_config(f
->unit
, MTU
, 0, 0, 0);
syslog(LOG_NOTICE
, "Connection terminated.");
* lcp_starting - LCP needs the lower layer up.
* lcp_finished - LCP has finished with the lower layer.
link_terminated(f
->unit
);