--- embedaddon/mpd/src/bund.c 2012/02/21 23:32:47 1.1 +++ embedaddon/mpd/src/bund.c 2021/03/17 00:39:23 1.1.1.5 @@ -72,7 +72,7 @@ static void BundBmTimeout(void *arg); static void BundReasses(Bund b); - static int BundSetCommand(Context ctx, int ac, char *av[], void *arg); + static int BundSetCommand(Context ctx, int ac, const char *const av[], const void *arg); static void BundNcpsUp(Bund b); static void BundNcpsDown(Bund b); @@ -115,7 +115,7 @@ BundSetCommand, NULL, 2, (void *) SET_YES }, { "no {opt ...}", "Disable and deny option", BundSetCommand, NULL, 2, (void *) SET_NO }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; /* @@ -328,7 +328,8 @@ BundJoin(Link l) /* Configure this link */ b->pppConfig.links[l->bundleIndex].enableLink = 1; - b->pppConfig.links[l->bundleIndex].mru = lcp->peer_mru; + b->pppConfig.links[l->bundleIndex].mru = b->iface.mtu_override ? + b->iface.mtu_override : lcp->peer_mru; b->pppConfig.links[l->bundleIndex].enableACFComp = lcp->peer_acfcomp; b->pppConfig.links[l->bundleIndex].enableProtoComp = lcp->peer_protocomp; b->pppConfig.links[l->bundleIndex].bandwidth = @@ -891,7 +892,7 @@ BundUpdateParams(Bund b) } else if (!b->peer_mrru) { /* If no multilink, use peer MRU */ mtu = MIN(b->links[the_link]->lcp.peer_mru, - b->links[the_link]->type->mtu); + PhysGetMtu(b->links[the_link], 0)); } else { /* Multilink, use peer MRRU */ mtu = MIN(b->peer_mrru, MP_MAX_MRRU); @@ -917,11 +918,13 @@ BundUpdateParams(Bund b) */ int -BundCommand(Context ctx, int ac, char *av[], void *arg) +BundCommand(Context ctx, int ac, const char *const av[], const void *arg) { Bund sb; int j, k; + (void)arg; + if (ac > 1) return (-1); @@ -961,10 +964,12 @@ BundCommand(Context ctx, int ac, char *av[], void *arg */ int -MSessionCommand(Context ctx, int ac, char *av[], void *arg) +MSessionCommand(Context ctx, int ac, const char *const av[], const void *arg) { int k; + (void)arg; + if (ac > 1) return (-1); @@ -1005,10 +1010,12 @@ MSessionCommand(Context ctx, int ac, char *av[], void */ int -IfaceCommand(Context ctx, int ac, char *av[], void *arg) +IfaceCommand(Context ctx, int ac, const char *const av[], const void *arg) { int k; + (void)arg; + if (ac > 1) return (-1); @@ -1049,13 +1056,15 @@ IfaceCommand(Context ctx, int ac, char *av[], void *ar */ int -BundCreate(Context ctx, int ac, char *av[], void *arg) +BundCreate(Context ctx, int ac, const char *const av[], const void *arg) { Bund b, bt = NULL; u_char tmpl = 0; u_char stay = 0; int k; + (void)arg; + RESETREF(ctx->lnk, NULL); RESETREF(ctx->bund, NULL); RESETREF(ctx->rep, NULL); @@ -1135,6 +1144,7 @@ BundCreate(Context ctx, int ac, char *av[], void *arg) /* Setup netgraph stuff */ if (BundNgInit(b) < 0) { gBundles[b->id] = NULL; + IfaceDestroy(b); Freee(b); Error("Bundle netgraph initialization failed"); } @@ -1152,10 +1162,12 @@ BundCreate(Context ctx, int ac, char *av[], void *arg) */ int -BundDestroy(Context ctx, int ac, char *av[], void *arg) +BundDestroy(Context ctx, int ac, const char *const av[], const void *arg) { Bund b; + (void)arg; + if (ac > 1) return(-1); @@ -1190,7 +1202,7 @@ BundDestroy(Context ctx, int ac, char *av[], void *arg */ Bund -BundInst(Bund bt, char *name, int tmpl, int stay) +BundInst(Bund bt, const char *name, int tmpl, int stay) { Bund b; int k; @@ -1274,12 +1286,14 @@ BundShutdown(Bund b) */ int -BundStat(Context ctx, int ac, char *av[], void *arg) +BundStat(Context ctx, int ac, const char *const av[], const void *arg) { Bund sb; int k, bw, tbw, nup; char buf[64]; + (void)arg; + /* Find bundle they're talking about */ switch (ac) { case 0: @@ -1317,6 +1331,12 @@ BundStat(Context ctx, int ac, char *av[], void *arg) /* Show configuration */ Printf("Configuration:\r\n"); +#ifdef SIOCSIFDESCR + Printf("\tDesc. template : %s\r\n", + sb->iface.conf.ifdescr ? sb->iface.conf.ifdescr : ""); + Printf("\tDescription : %s\r\n", + sb->iface.ifdescr ? sb->iface.ifdescr : ""); +#endif Printf("\tRetry timeout : %d seconds\r\n", sb->conf.retry_timeout); Printf("\tBW-manage:\r\n"); Printf("\t Period : %d seconds\r\n", sb->conf.bm_S); @@ -1387,9 +1407,9 @@ BundUpdateStats(Bund b) b->stats.runts += abs(stats.runts - b->oldStats.runts); b->stats.dupFragments += abs(stats.dupFragments - b->oldStats.dupFragments); b->stats.dropFragments += abs(stats.dropFragments - b->oldStats.dropFragments); + b->oldStats = stats; } - b->oldStats = stats; #else NgFuncGetStats64(b, l, &b->stats); #endif @@ -1542,11 +1562,19 @@ BundBmTimeout(void *arg) if (b->links[k] && b->links[k]->joined_bund) { Link const l = b->links[k]; +#ifndef NG_PPP_STATS64 struct ng_ppp_link_stat oldStats; +#else + struct ng_ppp_link_stat64 oldStats; +#endif /* Get updated link traffic statistics */ oldStats = l->bm.idleStats; +#ifndef NG_PPP_STATS64 NgFuncGetStats(l->bund, l->bundleIndex, &l->bm.idleStats); +#else + NgFuncGetStats64(l->bund, l->bundleIndex, &l->bm.idleStats); +#endif b->bm.traffic[0][0] += l->bm.idleStats.recvOctets - oldStats.recvOctets; b->bm.traffic[1][0] += l->bm.idleStats.xmitOctets - oldStats.xmitOctets; } @@ -1696,7 +1724,10 @@ BundNgInit(Bund b) newPpp = 1; /* Get PPP node ID */ - b->nodeID = NgGetNodeID(gLinksCsock, b->hook); + if ((b->nodeID = NgGetNodeID(gLinksCsock, b->hook)) == 0) { + Perror("[%s] Cannot get %s node id", b->name, NG_PPP_NODE_TYPE); + goto fail; + } /* Give it a name */ memset(&nm, 0, sizeof(nm)); @@ -1741,7 +1772,7 @@ BundNgShutdown(Bund b, int iface, int ppp) */ static int -BundSetCommand(Context ctx, int ac, char *av[], void *arg) +BundSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { Bund b = ctx->bund; int i, val;