auth.c functions now use ppp_pcb* as first argument

This commit is contained in:
Sylvain Rochet 2012-06-14 00:08:56 +02:00
parent 81a0fd782f
commit 51bfac71b0
8 changed files with 113 additions and 168 deletions

View File

@ -139,8 +139,10 @@
#define ISWILD(word) (word[0] == '*' && word[1] == 0) #define ISWILD(word) (word[0] == '*' && word[1] == 0)
#endif /* UNUSED */ #endif /* UNUSED */
#if PPP_SERVER
/* The name by which the peer authenticated itself to us. */ /* The name by which the peer authenticated itself to us. */
char peer_authname[MAXNAMELEN]; char peer_authname[MAXNAMELEN];
#endif /* PPP_SERVER */
/* Records which authentication operations haven't completed yet. */ /* Records which authentication operations haven't completed yet. */
static int auth_pending[NUM_PPP]; static int auth_pending[NUM_PPP];
@ -251,9 +253,9 @@ extern char *crypt (const char *, const char *);
#endif /* UNUSED */ #endif /* UNUSED */
/* Prototypes for procedures local to this file. */ /* Prototypes for procedures local to this file. */
static void network_phase (int); static void network_phase(ppp_pcb *pcb);
static void check_idle (void *); static void check_idle(void *arg);
static void connect_time_expired (void *); static void connect_time_expired(void *arg);
#if 0 /* UNUSED */ #if 0 /* UNUSED */
static int null_login (int); static int null_login (int);
/* static int get_pap_passwd (char *); */ /* static int get_pap_passwd (char *); */
@ -556,10 +558,7 @@ set_permitted_number(argv)
/* /*
* An Open on LCP has requested a change from Dead to Establish phase. * An Open on LCP has requested a change from Dead to Establish phase.
*/ */
void void link_required(ppp_pcb *pcb) {
link_required(unit)
int unit;
{
} }
#if 0 #if 0
@ -630,11 +629,7 @@ void start_link(unit)
* LCP has terminated the link; go to the Dead phase and take the * LCP has terminated the link; go to the Dead phase and take the
* physical layer down. * physical layer down.
*/ */
void void link_terminated(ppp_pcb *pcb) {
link_terminated(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
if (pcb->phase == PHASE_DEAD || pcb->phase == PHASE_MASTER) if (pcb->phase == PHASE_DEAD || pcb->phase == PHASE_MASTER)
return; return;
new_phase(pcb, PHASE_DISCONNECT); new_phase(pcb, PHASE_DISCONNECT);
@ -709,17 +704,13 @@ link_terminated(unit)
/* /*
* LCP has gone down; it will either die or try to re-establish. * LCP has gone down; it will either die or try to re-establish.
*/ */
void void link_down(ppp_pcb *pcb) {
link_down(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
#if PPP_NOTIFY #if PPP_NOTIFY
notify(link_down_notifier, 0); notify(link_down_notifier, 0);
#endif /* #if PPP_NOTIFY */ #endif /* #if PPP_NOTIFY */
if (!doing_multilink) { if (!doing_multilink) {
upper_layers_down(unit); upper_layers_down(pcb);
if (pcb->phase != PHASE_DEAD && pcb->phase != PHASE_MASTER) if (pcb->phase != PHASE_DEAD && pcb->phase != PHASE_MASTER)
new_phase(pcb, PHASE_ESTABLISH); new_phase(pcb, PHASE_ESTABLISH);
} }
@ -729,8 +720,7 @@ link_down(unit)
ppp_link_down(pcb); ppp_link_down(pcb);
} }
void upper_layers_down(int unit) void upper_layers_down(ppp_pcb *pcb) {
{
int i; int i;
struct protent *protp; struct protent *protp;
@ -738,9 +728,9 @@ void upper_layers_down(int unit)
if (!protp->enabled_flag) if (!protp->enabled_flag)
continue; continue;
if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
(*protp->lowerdown)(unit); (*protp->lowerdown)(pcb->unit);
if (protp->protocol < 0xC000 && protp->close != NULL) if (protp->protocol < 0xC000 && protp->close != NULL)
(*protp->close)(unit, "LCP down"); (*protp->close)(pcb->unit, "LCP down");
} }
num_np_open = 0; num_np_open = 0;
num_np_up = 0; num_np_up = 0;
@ -750,19 +740,15 @@ void upper_layers_down(int unit)
* The link is established. * The link is established.
* Proceed to the Dead, Authenticate or Network phase as appropriate. * Proceed to the Dead, Authenticate or Network phase as appropriate.
*/ */
void void link_established(ppp_pcb *pcb) {
link_established(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
int auth; int auth;
#if 0 /* UNUSED */ #if 0 /* UNUSED */
lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *wo = &lcp_wantoptions[pcb->unit];
#endif /* UNUSED */ #endif /* UNUSED */
#if PPP_SERVER #if PPP_SERVER
lcp_options *go = &lcp_gotoptions[unit]; lcp_options *go = &lcp_gotoptions[pcb->unit];
#endif /* #if PPP_SERVER */ #endif /* #if PPP_SERVER */
lcp_options *ho = &lcp_hisoptions[unit]; lcp_options *ho = &lcp_hisoptions[pcb->unit];
int i; int i;
struct protent *protp; struct protent *protp;
@ -773,7 +759,7 @@ link_established(unit)
for (i = 0; (protp = protocols[i]) != NULL; ++i) for (i = 0; (protp = protocols[i]) != NULL; ++i)
if (protp->protocol != PPP_LCP && protp->enabled_flag if (protp->protocol != PPP_LCP && protp->enabled_flag
&& protp->lowerup != NULL) && protp->lowerup != NULL)
(*protp->lowerup)(unit); (*protp->lowerup)(pcb->unit);
} }
#if 0 /* UNUSED */ #if 0 /* UNUSED */
@ -809,7 +795,7 @@ link_established(unit)
if (!wo->neg_upap || uselogin || !null_login(unit)) { if (!wo->neg_upap || uselogin || !null_login(unit)) {
warn("peer refused to authenticate: terminating link"); warn("peer refused to authenticate: terminating link");
status = EXIT_PEER_AUTH_FAILED; status = EXIT_PEER_AUTH_FAILED;
lcp_close(unit, "peer refused to authenticate"); lcp_close(pcb->unit, "peer refused to authenticate");
return; return;
} }
} }
@ -841,38 +827,35 @@ link_established(unit)
#if EAP_SUPPORT #if EAP_SUPPORT
if (ho->neg_eap) { if (ho->neg_eap) {
eap_authwithpeer(unit, pcb->settings.user); eap_authwithpeer(pcb->unit, pcb->settings.user);
auth |= EAP_WITHPEER; auth |= EAP_WITHPEER;
} else } else
#endif /* EAP_SUPPORT */ #endif /* EAP_SUPPORT */
#if CHAP_SUPPORT #if CHAP_SUPPORT
if (ho->neg_chap) { if (ho->neg_chap) {
chap_auth_with_peer(unit, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype)); chap_auth_with_peer(pcb->unit, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype));
auth |= CHAP_WITHPEER; auth |= CHAP_WITHPEER;
} else } else
#endif /* CHAP_SUPPORT */ #endif /* CHAP_SUPPORT */
#if PAP_SUPPORT #if PAP_SUPPORT
if (ho->neg_upap) { if (ho->neg_upap) {
upap_authwithpeer(unit, pcb->settings.user, pcb->settings.passwd); upap_authwithpeer(pcb->unit, pcb->settings.user, pcb->settings.passwd);
auth |= PAP_WITHPEER; auth |= PAP_WITHPEER;
} else } else
#endif /* PAP_SUPPORT */ #endif /* PAP_SUPPORT */
{} {}
auth_pending[unit] = auth; auth_pending[pcb->unit] = auth;
auth_done[unit] = 0; auth_done[pcb->unit] = 0;
if (!auth) if (!auth)
network_phase(unit); network_phase(pcb);
} }
/* /*
* Proceed to the network phase. * Proceed to the network phase.
*/ */
static void static void network_phase(ppp_pcb *pcb) {
network_phase(unit)
int unit;
{
#if CBCP_SUPPORT #if CBCP_SUPPORT
ppp_pcb *pcb = &ppp_pcb_list[unit]; ppp_pcb *pcb = &ppp_pcb_list[unit];
#endif #endif
@ -926,14 +909,10 @@ network_phase(unit)
extra_options = 0; extra_options = 0;
} }
#endif /* PPP_OPTIONS */ #endif /* PPP_OPTIONS */
start_networks(unit); start_networks(pcb);
} }
void void start_networks(ppp_pcb *pcb) {
start_networks(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
#if CCP_SUPPORT || ECP_SUPPORT #if CCP_SUPPORT || ECP_SUPPORT
int i; int i;
struct protent *protp; struct protent *protp;
@ -997,13 +976,10 @@ start_networks(unit)
&& !mppe_required && !mppe_required
#endif /* MPPE */ #endif /* MPPE */
) )
continue_networks(unit); continue_networks(pcb);
} }
void void continue_networks(ppp_pcb *pcb) {
continue_networks(unit)
int unit;
{
int i; int i;
struct protent *protp; struct protent *protp;
@ -1115,11 +1091,7 @@ auth_peer_success(unit, protocol, prot_flavor, name, namelen)
/* /*
* We have failed to authenticate ourselves to the peer using `protocol'. * We have failed to authenticate ourselves to the peer using `protocol'.
*/ */
void void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
auth_withpeer_fail(unit, protocol)
int unit, protocol;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
int errcode = PPPERR_AUTHFAIL; int errcode = PPPERR_AUTHFAIL;
/* /*
* We've failed to authenticate ourselves to our peer. * We've failed to authenticate ourselves to our peer.
@ -1135,16 +1107,13 @@ auth_withpeer_fail(unit, protocol)
* we can do except wait for that. * we can do except wait for that.
*/ */
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(unit, "Failed to authenticate ourselves to peer"); lcp_close(pcb->unit, "Failed to authenticate ourselves to peer");
} }
/* /*
* We have successfully authenticated ourselves with the peer using `protocol'. * We have successfully authenticated ourselves with the peer using `protocol'.
*/ */
void void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
auth_withpeer_success(unit, protocol, prot_flavor)
int unit, protocol, prot_flavor;
{
int bit; int bit;
const char *prot = ""; const char *prot = "";
@ -1189,26 +1158,22 @@ auth_withpeer_success(unit, protocol, prot_flavor)
notice("%s authentication succeeded", prot); notice("%s authentication succeeded", prot);
/* Save the authentication method for later. */ /* Save the authentication method for later. */
auth_done[unit] |= bit; auth_done[pcb->unit] |= bit;
/* /*
* If there is no more authentication still being done, * If there is no more authentication still being done,
* proceed to the network (or callback) phase. * proceed to the network (or callback) phase.
*/ */
if ((auth_pending[unit] &= ~bit) == 0) if ((auth_pending[pcb->unit] &= ~bit) == 0)
network_phase(unit); network_phase(pcb);
} }
/* /*
* np_up - a network protocol has come up. * np_up - a network protocol has come up.
*/ */
void void np_up(ppp_pcb *pcb, int proto) {
np_up(unit, proto)
int unit, proto;
{
int tlim; int tlim;
ppp_pcb *pcb = &ppp_pcb_list[unit];
if (num_np_up == 0) { if (num_np_up == 0) {
/* /*
@ -1224,14 +1189,14 @@ np_up(unit, proto)
#endif /* UNUSED */ #endif /* UNUSED */
tlim = pcb->settings.idle_time_limit; tlim = pcb->settings.idle_time_limit;
if (tlim > 0) if (tlim > 0)
TIMEOUT(check_idle, NULL, tlim); TIMEOUT(check_idle, (void*)pcb, tlim);
/* /*
* Set a timeout to close the connection once the maximum * Set a timeout to close the connection once the maximum
* connect time has expired. * connect time has expired.
*/ */
if (pcb->settings.maxconnect > 0) if (pcb->settings.maxconnect > 0)
TIMEOUT(connect_time_expired, 0, pcb->settings.maxconnect); TIMEOUT(connect_time_expired, (void*)pcb, pcb->settings.maxconnect);
#ifdef MAXOCTETS #ifdef MAXOCTETS
if (maxoctets > 0) if (maxoctets > 0)
@ -1252,13 +1217,9 @@ np_up(unit, proto)
/* /*
* np_down - a network protocol has gone down. * np_down - a network protocol has gone down.
*/ */
void void np_down(ppp_pcb *pcb, int proto) {
np_down(unit, proto)
int unit, proto;
{
ppp_pcb *pcb = &ppp_pcb_list[unit];
if (--num_np_up == 0) { if (--num_np_up == 0) {
UNTIMEOUT(check_idle, NULL); UNTIMEOUT(check_idle, (void*)pcb);
UNTIMEOUT(connect_time_expired, NULL); UNTIMEOUT(connect_time_expired, NULL);
#ifdef MAXOCTETS #ifdef MAXOCTETS
UNTIMEOUT(check_maxoctets, NULL); UNTIMEOUT(check_maxoctets, NULL);
@ -1270,10 +1231,7 @@ np_down(unit, proto)
/* /*
* np_finished - a network protocol has finished using the link. * np_finished - a network protocol has finished using the link.
*/ */
void void np_finished(ppp_pcb *pcb, int proto) {
np_finished(unit, proto)
int unit, proto;
{
if (--num_np_open <= 0) { if (--num_np_open <= 0) {
/* no further use for the link: shut up shop. */ /* no further use for the link: shut up shop. */
lcp_close(0, "No network protocols running"); lcp_close(0, "No network protocols running");
@ -1324,12 +1282,8 @@ check_maxoctets(arg)
* check_idle - check whether the link has been idle for long * check_idle - check whether the link has been idle for long
* enough that we can shut it down. * enough that we can shut it down.
*/ */
static void static void check_idle(void *arg) {
check_idle(arg) ppp_pcb *pcb = (ppp_pcb*)arg;
void *arg;
{
/* FIXME: fix forced unit 0 */
ppp_pcb *pcb = &ppp_pcb_list[0];
struct ppp_idle idle; struct ppp_idle idle;
time_t itime; time_t itime;
int tlim; int tlim;
@ -1355,19 +1309,15 @@ check_idle(arg)
need_holdoff = 0; need_holdoff = 0;
#endif /* UNUSED */ #endif /* UNUSED */
} else { } else {
TIMEOUT(check_idle, NULL, tlim); TIMEOUT(check_idle, (void*)pcb, tlim);
} }
} }
/* /*
* connect_time_expired - log a message and close the connection. * connect_time_expired - log a message and close the connection.
*/ */
static void static void connect_time_expired(void *arg) {
connect_time_expired(arg) ppp_pcb *pcb = (ppp_pcb*)arg;
void *arg;
{
/* FIXME: fix forced unit 0 */
ppp_pcb *pcb = &ppp_pcb_list[0];
info("Connect time expired"); info("Connect time expired");
pcb->status = EXIT_CONNECT_TIME; pcb->status = EXIT_CONNECT_TIME;
lcp_close(0, "Connect time expired"); /* Close connection */ lcp_close(0, "Connect time expired"); /* Close connection */
@ -1517,13 +1467,9 @@ auth_check_options()
* authentication options, i.e. whether we have appropriate secrets * authentication options, i.e. whether we have appropriate secrets
* to use for authenticating ourselves and/or the peer. * to use for authenticating ourselves and/or the peer.
*/ */
void void auth_reset(ppp_pcb *pcb) {
auth_reset(unit) lcp_options *go = &lcp_gotoptions[pcb->unit];
int unit; lcp_options *ao = &lcp_allowoptions[pcb->unit];
{
lcp_options *go = &lcp_gotoptions[unit];
lcp_options *ao = &lcp_allowoptions[unit];
ppp_pcb *pcb = &ppp_pcb_list[unit];
if( pcb->settings.passwd[0] ) { if( pcb->settings.passwd[0] ) {
@ -1986,19 +1932,9 @@ have_srp_secret(client, server, need_ip, lacks_ipp)
* for authenticating the given client on the given server. * for authenticating the given client on the given server.
* (We could be either client or server). * (We could be either client or server).
*/ */
int int get_secret(ppp_pcb *pcb, char *client, char *server, char *secret, int *secret_len, int am_server) {
get_secret(unit, client, server, secret, secret_len, am_server)
int unit;
char *client;
char *server;
char *secret;
int *secret_len;
int am_server;
{
int len; int len;
ppp_pcb *pcb = &ppp_pcb_list[unit];
LWIP_UNUSED_ARG(unit);
LWIP_UNUSED_ARG(server); LWIP_UNUSED_ARG(server);
LWIP_UNUSED_ARG(am_server); LWIP_UNUSED_ARG(am_server);

View File

@ -458,7 +458,7 @@ chap_verify_response(char *name, char *ourname, int id,
int secret_len; int secret_len;
/* Get the secret that the peer is supposed to know */ /* Get the secret that the peer is supposed to know */
if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) { if (!get_secret(pcb, name, ourname, (char *)secret, &secret_len, 1)) {
error("No CHAP secret found for authenticating %q", name); error("No CHAP secret found for authenticating %q", name);
return 0; return 0;
} }
@ -503,7 +503,7 @@ chap_respond(struct chap_client_state *cs, int id,
strlcpy(rname, pc->settings.remote_name, sizeof(rname)); strlcpy(rname, pc->settings.remote_name, sizeof(rname));
/* get secret for authenticating ourselves with the specified host */ /* get secret for authenticating ourselves with the specified host */
if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) { if (!get_secret(pcb, cs->name, rname, secret, &secret_len, 0)) {
secret_len = 0; /* assume null secret if can't find one */ secret_len = 0; /* assume null secret if can't find one */
warn("No CHAP secret found for authenticating us to %q", rname); warn("No CHAP secret found for authenticating us to %q", rname);
} }
@ -534,6 +534,8 @@ static void
chap_handle_status(struct chap_client_state *cs, int code, int id, chap_handle_status(struct chap_client_state *cs, int code, int id,
unsigned char *pkt, int len) unsigned char *pkt, int len)
{ {
/* FIXME: fix forced unit 0 */
ppp_pcb *pcb = &ppp_pcb_list[0];
const char *msg = NULL; const char *msg = NULL;
if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP)) if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
@ -561,11 +563,11 @@ chap_handle_status(struct chap_client_state *cs, int code, int id,
info("%s", msg); info("%s", msg);
} }
if (code == CHAP_SUCCESS) if (code == CHAP_SUCCESS)
auth_withpeer_success(0, PPP_CHAP, cs->digest->code); auth_withpeer_success(pcb, PPP_CHAP, cs->digest->code);
else { else {
cs->flags |= AUTH_FAILED; cs->flags |= AUTH_FAILED;
error("CHAP authentication failed"); error("CHAP authentication failed");
auth_withpeer_fail(0, PPP_CHAP); auth_withpeer_fail(pcb, PPP_CHAP);
} }
} }
@ -608,6 +610,7 @@ chap_input(int unit, unsigned char *pkt, int pktlen)
static void static void
chap_protrej(int unit) chap_protrej(int unit)
{ {
ppp_pcb *pcb = &ppp_pcb_list[unit];
struct chap_client_state *cs = &client; struct chap_client_state *cs = &client;
#if PPP_SERVER #if PPP_SERVER
struct chap_server_state *ss = &server; struct chap_server_state *ss = &server;
@ -624,7 +627,7 @@ chap_protrej(int unit)
if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) { if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
cs->flags &= ~AUTH_STARTED; cs->flags &= ~AUTH_STARTED;
error("CHAP authentication failed due to protocol-reject"); error("CHAP authentication failed due to protocol-reject");
auth_withpeer_fail(0, PPP_CHAP); auth_withpeer_fail(pcb, PPP_CHAP);
} }
} }

View File

@ -222,12 +222,13 @@ eap_client_timeout(arg)
void *arg; void *arg;
{ {
eap_state *esp = (eap_state *) arg; eap_state *esp = (eap_state *) arg;
ppp_pcb *pcb = &ppp_pcb_list[esp->es_unit];
if (!eap_client_active(esp)) if (!eap_client_active(esp))
return; return;
error("EAP: timeout waiting for Request from peer"); error("EAP: timeout waiting for Request from peer");
auth_withpeer_fail(esp->es_unit, PPP_EAP); auth_withpeer_fail(pcb, PPP_EAP);
esp->es_client.ea_state = eapBadAuth; esp->es_client.ea_state = eapBadAuth;
} }
@ -1043,16 +1044,17 @@ static void
eap_protrej(unit) eap_protrej(unit)
int unit; int unit;
{ {
ppp_pcb *pcb = &ppp_pcb_list[unit];
eap_state *esp = &eap_states[unit]; eap_state *esp = &eap_states[unit];
if (eap_client_active(esp)) { if (eap_client_active(esp)) {
error("EAP authentication failed due to Protocol-Reject"); error("EAP authentication failed due to Protocol-Reject");
auth_withpeer_fail(unit, PPP_EAP); auth_withpeer_fail(pcb, PPP_EAP);
} }
#if PPP_SERVER #if PPP_SERVER
if (eap_server_active(esp)) { if (eap_server_active(esp)) {
error("EAP authentication of peer failed on Protocol-Reject"); error("EAP authentication of peer failed on Protocol-Reject");
auth_peer_fail(unit, PPP_EAP); auth_peer_fail(pcb, PPP_EAP);
} }
#endif /* PPP_SERVER */ #endif /* PPP_SERVER */
eap_lowerdown(unit); eap_lowerdown(unit);
@ -1341,7 +1343,7 @@ u_char *inp;
int id; int id;
int len; int len;
{ {
ppp_pcb *pc = &ppp_pcb_list[esp->es_unit]; ppp_pcb *pcb = &ppp_pcb_list[esp->es_unit];
u_char typenum; u_char typenum;
u_char vallen; u_char vallen;
int secret_len; int secret_len;
@ -1371,7 +1373,7 @@ int len;
if (esp->es_client.ea_timeout > 0) { if (esp->es_client.ea_timeout > 0) {
UNTIMEOUT(eap_client_timeout, (void *)esp); UNTIMEOUT(eap_client_timeout, (void *)esp);
} }
auth_withpeer_fail(esp->es_unit, PPP_EAP); auth_withpeer_fail(pcb, PPP_EAP);
return; return;
} }
@ -1460,15 +1462,15 @@ int len;
} }
/* In case the remote doesn't give us his name. */ /* In case the remote doesn't give us his name. */
if (pc->settings.explicit_remote || if (pcb->settings.explicit_remote ||
(pc->settings.remote_name[0] != '\0' && vallen == len)) (pcb->settings.remote_name[0] != '\0' && vallen == len))
strlcpy(rhostname, pc->settings.remote_name, sizeof (rhostname)); strlcpy(rhostname, pcb->settings.remote_name, sizeof (rhostname));
/* /*
* Get the secret for authenticating ourselves with * Get the secret for authenticating ourselves with
* the specified host. * the specified host.
*/ */
if (!get_secret(esp->es_unit, esp->es_client.ea_name, if (!get_secret(pcb, esp->es_client.ea_name,
rhostname, secret, &secret_len, 0)) { rhostname, secret, &secret_len, 0)) {
dbglog("EAP: no MD5 secret for auth to %q", rhostname); dbglog("EAP: no MD5 secret for auth to %q", rhostname);
eap_send_nak(esp, id, EAPT_SRP); eap_send_nak(esp, id, EAPT_SRP);
@ -1738,7 +1740,7 @@ client_failure:
} }
esp->es_client.ea_session = NULL; esp->es_client.ea_session = NULL;
t_clientclose(tc); t_clientclose(tc);
auth_withpeer_fail(esp->es_unit, PPP_EAP); auth_withpeer_fail(pcb, PPP_EAP);
#endif /* USE_SRP */ #endif /* USE_SRP */
} }
@ -1896,7 +1898,7 @@ int len;
* Get the secret for authenticating the specified * Get the secret for authenticating the specified
* host. * host.
*/ */
if (!get_secret(esp->es_unit, rhostname, if (!get_secret(pcb, rhostname,
esp->es_server.ea_name, secret, &secret_len, 1)) { esp->es_server.ea_name, secret, &secret_len, 1)) {
dbglog("EAP: no MD5 secret for auth of %q", rhostname); dbglog("EAP: no MD5 secret for auth of %q", rhostname);
eap_send_failure(esp); eap_send_failure(esp);
@ -2050,6 +2052,7 @@ u_char *inp;
int id; int id;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[esp->es_unit];
if (esp->es_client.ea_state != eapOpen && !eap_client_active(esp)) { if (esp->es_client.ea_state != eapOpen && !eap_client_active(esp)) {
dbglog("EAP unexpected success message in state %s (%d)", dbglog("EAP unexpected success message in state %s (%d)",
eap_state_name(esp->es_client.ea_state), eap_state_name(esp->es_client.ea_state),
@ -2067,7 +2070,7 @@ int len;
} }
esp->es_client.ea_state = eapOpen; esp->es_client.ea_state = eapOpen;
auth_withpeer_success(esp->es_unit, PPP_EAP, 0); auth_withpeer_success(pcb, PPP_EAP, 0);
} }
/* /*
@ -2080,6 +2083,7 @@ u_char *inp;
int id; int id;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[esp->es_unit];
if (!eap_client_active(esp)) { if (!eap_client_active(esp)) {
dbglog("EAP unexpected failure message in state %s (%d)", dbglog("EAP unexpected failure message in state %s (%d)",
eap_state_name(esp->es_client.ea_state), eap_state_name(esp->es_client.ea_state),
@ -2098,7 +2102,7 @@ int len;
esp->es_client.ea_state = eapBadAuth; esp->es_client.ea_state = eapBadAuth;
error("EAP: peer reports authentication failure"); error("EAP: peer reports authentication failure");
auth_withpeer_fail(esp->es_unit, PPP_EAP); auth_withpeer_fail(pcb, PPP_EAP);
} }
/* /*

View File

@ -1982,7 +1982,7 @@ ipcp_up(f)
reset_link_stats(f->unit); reset_link_stats(f->unit);
#endif /* PPP_STATS_SUPPORT */ #endif /* PPP_STATS_SUPPORT */
np_up(f->unit, PPP_IP); np_up(pcb, PPP_IP);
ipcp_is_up = 1; ipcp_is_up = 1;
#if PPP_NOTIFY #if PPP_NOTIFY
@ -2023,7 +2023,7 @@ ipcp_down(f)
#endif /* UNUSED */ #endif /* UNUSED */
if (ipcp_is_up) { if (ipcp_is_up) {
ipcp_is_up = 0; ipcp_is_up = 0;
np_down(f->unit, PPP_IP); np_down(pcb, PPP_IP);
} }
sifvjcomp(pcb, 0, 0, 0); sifvjcomp(pcb, 0, 0, 0);
@ -2087,9 +2087,10 @@ static void
ipcp_finished(f) ipcp_finished(f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
if (ipcp_is_open) { if (ipcp_is_open) {
ipcp_is_open = 0; ipcp_is_open = 0;
np_finished(f->unit, PPP_IP); np_finished(pcb, PPP_IP);
} }
} }

View File

@ -735,6 +735,7 @@ static void
lcp_resetci(f) lcp_resetci(f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *wo = &lcp_wantoptions[f->unit];
lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *go = &lcp_gotoptions[f->unit];
lcp_options *ao = &lcp_allowoptions[f->unit]; lcp_options *ao = &lcp_allowoptions[f->unit];
@ -754,7 +755,7 @@ lcp_resetci(f)
if (noendpoint) if (noendpoint)
ao->neg_endpoint = 0; ao->neg_endpoint = 0;
peer_mru[f->unit] = PPP_MRU; peer_mru[f->unit] = PPP_MRU;
auth_reset(f->unit); auth_reset(pcb);
} }
@ -2317,7 +2318,7 @@ lcp_up(f)
lcp_echo_lowerup(f->unit); /* Enable echo messages */ lcp_echo_lowerup(f->unit); /* Enable echo messages */
link_established(f->unit); link_established(pcb);
} }
@ -2335,7 +2336,7 @@ lcp_down(f)
lcp_echo_lowerdown(f->unit); lcp_echo_lowerdown(f->unit);
link_down(f->unit); link_down(pcb);
ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0); ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0);
ppp_recv_config(pcb, PPP_MRU, ppp_recv_config(pcb, PPP_MRU,
@ -2348,22 +2349,18 @@ lcp_down(f)
/* /*
* lcp_starting - LCP needs the lower layer up. * lcp_starting - LCP needs the lower layer up.
*/ */
static void static void lcp_starting(fsm *f) {
lcp_starting(f) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; link_required(pcb);
{
link_required(f->unit);
} }
/* /*
* lcp_finished - LCP has finished with the lower layer. * lcp_finished - LCP has finished with the lower layer.
*/ */
static void static void lcp_finished(fsm *f) {
lcp_finished(f) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; link_terminated(pcb);
{
link_terminated(f->unit);
} }

View File

@ -482,7 +482,7 @@ static void ppp_stop(ppp_pcb *pcb) {
static void ppp_hup(ppp_pcb *pcb) { static void ppp_hup(ppp_pcb *pcb) {
PPPDEBUG(LOG_DEBUG, ("ppp_hup: unit %d\n", pcb->unit)); PPPDEBUG(LOG_DEBUG, ("ppp_hup: unit %d\n", pcb->unit));
lcp_lowerdown(pcb->unit); lcp_lowerdown(pcb->unit);
link_terminated(pcb->unit); link_terminated(pcb);
} }
/* /*

View File

@ -544,27 +544,27 @@ void update_link_stats(int u); /* Get stats at link termination */
#define EXIT_CNID_AUTH_FAILED 21 #define EXIT_CNID_AUTH_FAILED 21
/* Procedures exported from auth.c */ /* Procedures exported from auth.c */
void link_required (int); /* we are starting to use the link */ void link_required(ppp_pcb *pcb); /* we are starting to use the link */
void link_terminated (int); /* we are finished with the link */ void link_terminated(ppp_pcb *pcb); /* we are finished with the link */
void link_down (int); /* the LCP layer has left the Opened state */ void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */
void upper_layers_down (int);/* take all NCPs down */ void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */
void link_established (int); /* the link is up; authenticate now */ void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */
void start_networks (int); /* start all the network control protos */ void start_networks(ppp_pcb *pcb); /* start all the network control protos */
void continue_networks (int); /* start network [ip, etc] control protos */ void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */
void auth_peer_fail (int, int); void auth_peer_fail (int, int);
/* peer failed to authenticate itself */ /* peer failed to authenticate itself */
void auth_peer_success (int, int, int, char *, int); void auth_peer_success (int, int, int, char *, int);
/* peer successfully authenticated itself */ /* peer successfully authenticated itself */
void auth_withpeer_fail (int, int); void auth_withpeer_fail(ppp_pcb *pcb, int protocol);
/* we failed to authenticate ourselves */ /* we failed to authenticate ourselves */
void auth_withpeer_success (int, int, int); void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor);
/* we successfully authenticated ourselves */ /* we successfully authenticated ourselves */
void np_up (int, int); /* a network protocol has come up */ void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */
void np_down (int, int); /* a network protocol has gone down */ void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */
void np_finished (int, int); /* a network protocol no longer needs link */ void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */
void auth_reset (int); /* check what secrets we have */ void auth_reset(ppp_pcb *pcb); /* check what secrets we have */
int get_secret (int, char *, char *, char *, int *, int); int get_secret(ppp_pcb *pcb, char *client, char *server, char *secret, int *secret_len, int am_server);
/* get "secret" for chap */ /* get "secret" for chap */
/* Procedures exported from ipcp.c */ /* Procedures exported from ipcp.c */

View File

@ -222,6 +222,7 @@ upap_timeout(arg)
void *arg; void *arg;
{ {
upap_state *u = (upap_state *) arg; upap_state *u = (upap_state *) arg;
ppp_pcb *pcb = &ppp_pcb_list[u->us_unit];
if (u->us_clientstate != UPAPCS_AUTHREQ) if (u->us_clientstate != UPAPCS_AUTHREQ)
return; return;
@ -230,7 +231,7 @@ upap_timeout(arg)
/* give up in disgust */ /* give up in disgust */
error("No response to PAP authenticate-requests"); error("No response to PAP authenticate-requests");
u->us_clientstate = UPAPCS_BADAUTH; u->us_clientstate = UPAPCS_BADAUTH;
auth_withpeer_fail(u->us_unit, PPP_PAP); auth_withpeer_fail(pcb, PPP_PAP);
return; return;
} }
@ -321,15 +322,16 @@ upap_protrej(unit)
int unit; int unit;
{ {
upap_state *u = &upap[unit]; upap_state *u = &upap[unit];
ppp_pcb *pcb = &ppp_pcb_list[u->us_unit];
if (u->us_clientstate == UPAPCS_AUTHREQ) { if (u->us_clientstate == UPAPCS_AUTHREQ) {
error("PAP authentication failed due to protocol-reject"); error("PAP authentication failed due to protocol-reject");
auth_withpeer_fail(unit, PPP_PAP); auth_withpeer_fail(pcb, PPP_PAP);
} }
#if PPP_SERVER #if PPP_SERVER
if (u->us_serverstate == UPAPSS_LISTEN) { if (u->us_serverstate == UPAPSS_LISTEN) {
error("PAP authentication of peer failed (protocol-reject)"); error("PAP authentication of peer failed (protocol-reject)");
auth_peer_fail(unit, PPP_PAP); auth_peer_fail(pcb, PPP_PAP);
} }
#endif /* PPP_SERVER */ #endif /* PPP_SERVER */
upap_lowerdown(unit); upap_lowerdown(unit);
@ -506,6 +508,7 @@ upap_rauthack(u, inp, id, len)
int id; int id;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[u->us_unit];
u_char msglen; u_char msglen;
char *msg; char *msg;
@ -532,7 +535,7 @@ upap_rauthack(u, inp, id, len)
u->us_clientstate = UPAPCS_OPEN; u->us_clientstate = UPAPCS_OPEN;
auth_withpeer_success(u->us_unit, PPP_PAP, 0); auth_withpeer_success(pcb, PPP_PAP, 0);
} }
@ -546,6 +549,7 @@ upap_rauthnak(u, inp, id, len)
int id; int id;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[u->us_unit];
u_char msglen; u_char msglen;
char *msg; char *msg;
@ -573,7 +577,7 @@ upap_rauthnak(u, inp, id, len)
u->us_clientstate = UPAPCS_BADAUTH; u->us_clientstate = UPAPCS_BADAUTH;
error("PAP authentication failed"); error("PAP authentication failed");
auth_withpeer_fail(u->us_unit, PPP_PAP); auth_withpeer_fail(pcb, PPP_PAP);
} }