--- embedaddon/mpd/src/nat.c 2013/07/22 08:44:29 1.1.1.2 +++ embedaddon/mpd/src/nat.c 2023/09/27 11:08:01 1.1.1.4.2.1 @@ -3,6 +3,7 @@ * nat.c * * Written by Alexander Motin + * Rewritten by Dmitry Luhtionov */ #include "ppp.h" @@ -33,7 +34,7 @@ UNSET_REDIRECT_PROTO }; -static int NatSetCommand(Context ctx, int ac, char *av[], void *arg); +static int NatSetCommand(Context ctx, int ac, const char *const av[], const void *arg); /* * GLOBAL VARIABLES @@ -47,7 +48,7 @@ static int NatSetCommand(Context ctx, int ac, char *av NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_ADDR }, { "red-proto {proto} {alias-addr} {local_addr} [{remote-addr}]", "Redirect protocol", NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_PROTO }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; #endif @@ -68,7 +69,7 @@ static int NatSetCommand(Context ctx, int ac, char *av NatSetCommand, AdmitBund, 2, (void *) SET_ENABLE }, { "disable [opt ...]", "Disable option", NatSetCommand, AdmitBund, 2, (void *) SET_DISABLE }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; /* @@ -115,7 +116,7 @@ NatInit(Bund b) */ static int -NatSetCommand(Context ctx, int ac, char *av[], void *arg) +NatSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { NatState const nat = &ctx->bund->iface.nat; IfaceState const iface = &ctx->bund->iface; @@ -185,7 +186,7 @@ NatSetCommand(Context ctx, int ac, char *av[], void *a if (!inet_aton (av[5], &r_addr)) Error("bad remote IP address \"%s\"", av[5]); rp = atoi(av[6]); - if (rp <= 0 || rp > 65535) + if (rp < 0 || rp > 65535) Error("Incorrect remote port number \"%s\"", av[6]); } /* OK */ @@ -408,22 +409,26 @@ NatSetCommand(Context ctx, int ac, char *av[], void *a */ int -NatStat(Context ctx, int ac, char *av[], void *arg) +NatStat(Context ctx, int ac, const char *const av[], const void *arg) { NatState const nat = &ctx->bund->iface.nat; -#ifdef NGM_NAT_LIBALIAS_INFO +#ifdef NG_NAT_LIBALIAS_INFO IfaceState const iface = &ctx->bund->iface; union { u_char buf[sizeof(struct ng_mesg) + sizeof(struct ng_nat_libalias_info)]; struct ng_mesg reply; } u; - struct ng_nat_libalias_info *const li = \ + struct ng_nat_libalias_info *const nli = \ (struct ng_nat_libalias_info *)(void *)u.reply.data; char path[NG_PATHSIZ]; #endif char buf[48]; int k; + (void)ac; + (void)av; + (void)arg; + Printf("NAT configuration:\r\n"); Printf("\tAlias addresses : %s\r\n", u_addrtoa(&nat->alias_addr,buf,sizeof(buf))); @@ -469,23 +474,24 @@ NatStat(Context ctx, int ac, char *av[], void *arg) #endif Printf("NAT options:\r\n"); OptStat(ctx, &nat->options, gConfList); -#ifdef NGM_NAT_LIBALIAS_INFO +#ifdef NG_NAT_LIBALIAS_INFO if (Enabled(&nat->options, NAT_CONF_LOG) && iface->up && iface->nat_up) { snprintf(path, sizeof(path), "mpd%d-%s-nat:", gPid, \ (char *)&ctx->bund->name); + bzero(nli, sizeof(struct ng_nat_libalias_info)); Printf("LibAlias statistic:\r\n"); if (NgFuncSendQuery(path, NGM_NAT_COOKIE, NGM_NAT_LIBALIAS_INFO, NULL, 0, &u.reply, sizeof(u), NULL) < 0) - Perror("Can't get LibAlis stats"); - Printf("\ticmpLinkCount : %u\r\n", li->icmpLinkCount); - Printf("\tudpLinkCount : %u\r\n", li->udpLinkCount); - Printf("\ttcpLinkCount : %u\r\n", li->tcpLinkCount); - Printf("\tsctpLinkCount : %u\r\n", li->sctpLinkCount); - Printf("\tpptpLinkCount : %u\r\n", li->pptpLinkCount); - Printf("\tprotoLinkCount : %u\r\n", li->protoLinkCount); - Printf("\tfragmentIdLinkCount : %u\r\n", li->fragmentIdLinkCount); - Printf("\tfragmentPtrLinkCount : %u\r\n", li->fragmentPtrLinkCount); - Printf("\tsockCount : %u\r\n", li->sockCount); + Perror("Can't get LibAlias stats"); + Printf("\ticmpLinkCount : %u\r\n", nli->icmpLinkCount); + Printf("\tudpLinkCount : %u\r\n", nli->udpLinkCount); + Printf("\ttcpLinkCount : %u\r\n", nli->tcpLinkCount); + Printf("\tsctpLinkCount : %u\r\n", nli->sctpLinkCount); + Printf("\tpptpLinkCount : %u\r\n", nli->pptpLinkCount); + Printf("\tprotoLinkCount : %u\r\n", nli->protoLinkCount); + Printf("\tfragmentIdLinkCount : %u\r\n", nli->fragmentIdLinkCount); + Printf("\tfragmentPtrLinkCount : %u\r\n", nli->fragmentPtrLinkCount); + Printf("\tsockCount : %u\r\n", nli->sockCount); } #endif return(0);