From ea7bf1905773d979ea42f35bd85560d24e77543d Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 17 Jun 2012 00:17:22 +0200 Subject: [PATCH] fixed most "unit 0" used instead of pcb pointer --- src/netif/ppp/auth.c | 26 +++++++++++++------------- src/netif/ppp/demand.c | 18 +++++++++--------- src/netif/ppp/multilink.c | 14 +++++++------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index d3913f2b..3d191709 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -593,7 +593,7 @@ void start_link(unit) new_phase(pcb, PHASE_ESTABLISH); - lcp_lowerup(0); + lcp_lowerup(pcb); return; disconnect: @@ -632,7 +632,7 @@ void link_terminated(ppp_pcb *pcb) { } else notice("Link terminated."); - lcp_lowerdown(0); + lcp_lowerdown(pcb); new_phase(pcb, PHASE_DEAD); ppp_link_terminated(pcb); @@ -659,7 +659,7 @@ void link_terminated(ppp_pcb *pcb) { fd_ppp = -1; } if (!hungup) - lcp_lowerdown(0); + lcp_lowerdown(pcb); if (!doing_multilink && !demand) script_unsetenv("IFNAME"); @@ -778,7 +778,7 @@ void link_established(ppp_pcb *pcb) { if (!wo->neg_upap || uselogin || !null_login(unit)) { warn("peer refused to authenticate: terminating link"); status = EXIT_PEER_AUTH_FAILED; - lcp_close(pcb->unit, "peer refused to authenticate"); + lcp_close(pcb, "peer refused to authenticate"); return; } } @@ -878,7 +878,7 @@ static void network_phase(ppp_pcb *pcb) { */ if (go->neg_cbcp) { new_phase(pcb, PHASE_CALLBACK); - (*cbcp_protent.open)(unit); + (*cbcp_protent.open)(pcb); return; } #endif @@ -939,7 +939,7 @@ void start_networks(ppp_pcb *pcb) { #endif /* CCP_SUPPORT */ ) && protp->enabled_flag && protp->open != NULL) - (*protp->open)(0); + (*protp->open)(pcb); #endif /* CCP_SUPPORT || ECP_SUPPORT */ /* @@ -985,7 +985,7 @@ void continue_networks(ppp_pcb *pcb) { if (pcb->num_np_open == 0) /* nothing to do */ - lcp_close(0, "No network protocols running"); + lcp_close(pcb, "No network protocols running"); } #if PPP_SERVER @@ -997,7 +997,7 @@ void auth_peer_fail(ppp_pcb *pcb, int protocol) { * Authentication failure: take the link down */ status = EXIT_PEER_AUTH_FAILED; - lcp_close(pcb->unit, "Authentication failed"); + lcp_close(pcb, "Authentication failed"); } /* @@ -1210,7 +1210,7 @@ void np_down(ppp_pcb *pcb, int proto) { void np_finished(ppp_pcb *pcb, int proto) { if (--pcb->num_np_open <= 0) { /* no further use for the link: shut up shop. */ - lcp_close(0, "No network protocols running"); + lcp_close(pcb, "No network protocols running"); } } @@ -1243,7 +1243,7 @@ check_maxoctets(arg) if (used > maxoctets) { notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); status = EXIT_TRAFFIC_LIMIT; - lcp_close(0, "Traffic limit"); + lcp_close(pcb, "Traffic limit"); #if 0 /* UNUSED */ need_holdoff = 0; #endif /* UNUSED */ @@ -1280,7 +1280,7 @@ static void check_idle(void *arg) { /* link is idle: shut it down. */ notice("Terminating connection due to lack of activity."); pcb->status = EXIT_IDLE_TIMEOUT; - lcp_close(0, "Link inactive"); + lcp_close(pcb, "Link inactive"); #if 0 /* UNUSED */ need_holdoff = 0; #endif /* UNUSED */ @@ -1296,7 +1296,7 @@ static void connect_time_expired(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; info("Connect time expired"); pcb->status = EXIT_CONNECT_TIME; - lcp_close(0, "Connect time expired"); /* Close connection */ + lcp_close(pcb, "Connect time expired"); /* Close connection */ } #if PPP_OPTIONS @@ -1662,7 +1662,7 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg) */ if (attempts++ >= 10) { warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user); - lcp_close(unit, "login failed"); + lcp_close(pcb, "login failed"); } if (attempts > 3) sleep((u_int) (attempts - 3) * 5); diff --git a/src/netif/ppp/demand.c b/src/netif/ppp/demand.c index b7c33e0f..75b43a13 100644 --- a/src/netif/ppp/demand.c +++ b/src/netif/ppp/demand.c @@ -98,9 +98,9 @@ demand_conf() flush_flag = 0; fcs = PPP_INITFCS; - netif_set_mtu(0, LWIP_MIN(lcp_allowoptions[0].mru, PPP_MRU)); - if (ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0) < 0 - || ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0) < 0) + netif_set_mtu(pcb, LWIP_MIN(lcp_allowoptions[0].mru, PPP_MRU)); + if (ppp_send_config(pcb, PPP_MRU, (u_int32_t) 0, 0, 0) < 0 + || ppp_recv_config(pcb, PPP_MRU, (u_int32_t) 0, 0, 0) < 0) fatal("Couldn't set up demand-dialled PPP interface: %m"); #ifdef PPP_FILTER @@ -112,10 +112,10 @@ demand_conf() */ for (i = 0; (protp = protocols[i]) != NULL; ++i) if (protp->enabled_flag && protp->demand_conf != NULL) - ((*protp->demand_conf)(0)); + ((*protp->demand_conf)(pcb)); /* FIXME: find a way to die() here */ #if 0 - if (!((*protp->demand_conf)(0))) + if (!((*protp->demand_conf)(pcb))) die(1); #endif } @@ -132,7 +132,7 @@ demand_block() for (i = 0; (protp = protocols[i]) != NULL; ++i) if (protp->enabled_flag && protp->demand_conf != NULL) - sifnpmode(0, protp->protocol & ~0x8000, NPMODE_QUEUE); + sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_QUEUE); get_loop_output(); } @@ -149,7 +149,7 @@ demand_discard() for (i = 0; (protp = protocols[i]) != NULL; ++i) if (protp->enabled_flag && protp->demand_conf != NULL) - sifnpmode(0, protp->protocol & ~0x8000, NPMODE_ERROR); + sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_ERROR); get_loop_output(); /* discard all saved packets */ @@ -175,7 +175,7 @@ demand_unblock() for (i = 0; (protp = protocols[i]) != NULL; ++i) if (protp->enabled_flag && protp->demand_conf != NULL) - sifnpmode(0, protp->protocol & ~0x8000, NPMODE_PASS); + sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_PASS); } /* @@ -411,7 +411,7 @@ demand_rexmit(proto, newip) ntohs(*( (short *) (pkt->data+iphdr+6)))); } } - output(0, pkt->data, pkt->length); + output(pcb, pkt->data, pkt->length); free(pkt); } else { if (prev == NULL) diff --git a/src/netif/ppp/multilink.c b/src/netif/ppp/multilink.c index 5648d26c..551a067c 100644 --- a/src/netif/ppp/multilink.c +++ b/src/netif/ppp/multilink.c @@ -130,7 +130,7 @@ mp_join_bundle() /* have previously joined a bundle */ if (!go->neg_mrru || !ho->neg_mrru) { notice("oops, didn't get multilink on renegotiation"); - lcp_close(0, "multilink required"); + lcp_close(pcb, "multilink required"); return 0; } /* XXX should check the peer_authname and ho->endpoint @@ -148,12 +148,12 @@ mp_join_bundle() if (demand) { /* already have a bundle */ cfg_bundle(0, 0, 0, 0); - netif_set_mtu(0, mtu); + netif_set_mtu(pcb, mtu); return 0; } make_new_bundle(0, 0, 0, 0); set_ifunit(1); - netif_set_mtu(0, mtu); + netif_set_mtu(pcb, mtu); return 0; } @@ -198,7 +198,7 @@ mp_join_bundle() mtu = LWIP_MIN(ho->mrru, ao->mru); if (demand) { cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); - netif_set_mtu(0, mtu); + netif_set_mtu(pcb, mtu); script_setenv("BUNDLE", bundle_id + 7, 1); return 0; } @@ -245,9 +245,9 @@ mp_join_bundle() /* we have to make a new bundle */ make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); set_ifunit(1); - netif_set_mtu(0, mtu); + netif_set_mtu(pcb, mtu); script_setenv("BUNDLE", bundle_id + 7, 1); - make_bundle_links(0); + make_bundle_links(pcb); unlock_db(); info("New bundle %s created", ifname); multilink_master = 1; @@ -277,7 +277,7 @@ void mp_bundle_terminated() TDB_DATA key; bundle_terminating = 1; - upper_layers_down(0); + upper_layers_down(pcb); notice("Connection terminated."); #if PPP_STATS_SUPPORT print_link_stats();