version 1.1.1.2, 2013/07/22 08:44:29
|
version 1.1.1.4, 2021/03/17 00:39:23
|
Line 3
|
Line 3
|
* nat.c |
* nat.c |
* |
* |
* Written by Alexander Motin <mav@FreeBSD.org> |
* Written by Alexander Motin <mav@FreeBSD.org> |
|
* Rewritten by Dmitry Luhtionov <dmitryluhtionov@gmail.com> |
*/ |
*/ |
|
|
#include "ppp.h" |
#include "ppp.h" |
Line 33
|
Line 34
|
UNSET_REDIRECT_PROTO |
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 |
* GLOBAL VARIABLES |
Line 47 static int NatSetCommand(Context ctx, int ac, char *av
|
Line 48 static int NatSetCommand(Context ctx, int ac, char *av
|
NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_ADDR }, |
NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_ADDR }, |
{ "red-proto {proto} {alias-addr} {local_addr} [{remote-addr}]", "Redirect protocol", |
{ "red-proto {proto} {alias-addr} {local_addr} [{remote-addr}]", "Redirect protocol", |
NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_PROTO }, |
NatSetCommand, AdmitBund, 2, (void *) UNSET_REDIRECT_PROTO }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
#endif |
#endif |
|
|
Line 68 static int NatSetCommand(Context ctx, int ac, char *av
|
Line 69 static int NatSetCommand(Context ctx, int ac, char *av
|
NatSetCommand, AdmitBund, 2, (void *) SET_ENABLE }, |
NatSetCommand, AdmitBund, 2, (void *) SET_ENABLE }, |
{ "disable [opt ...]", "Disable option", |
{ "disable [opt ...]", "Disable option", |
NatSetCommand, AdmitBund, 2, (void *) SET_DISABLE }, |
NatSetCommand, AdmitBund, 2, (void *) SET_DISABLE }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
/* |
/* |
Line 115 NatInit(Bund b)
|
Line 116 NatInit(Bund b)
|
*/ |
*/ |
|
|
static int |
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; |
NatState const nat = &ctx->bund->iface.nat; |
IfaceState const iface = &ctx->bund->iface; |
IfaceState const iface = &ctx->bund->iface; |
Line 408 NatSetCommand(Context ctx, int ac, char *av[], void *a
|
Line 409 NatSetCommand(Context ctx, int ac, char *av[], void *a
|
*/ |
*/ |
|
|
int |
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; |
NatState const nat = &ctx->bund->iface.nat; |
#ifdef NGM_NAT_LIBALIAS_INFO | #ifdef NG_NAT_LIBALIAS_INFO |
IfaceState const iface = &ctx->bund->iface; |
IfaceState const iface = &ctx->bund->iface; |
union { |
union { |
u_char buf[sizeof(struct ng_mesg) + sizeof(struct ng_nat_libalias_info)]; |
u_char buf[sizeof(struct ng_mesg) + sizeof(struct ng_nat_libalias_info)]; |
struct ng_mesg reply; |
struct ng_mesg reply; |
} u; |
} u; |
struct ng_nat_libalias_info *const li = \ | struct ng_nat_libalias_info *const nli = \ |
(struct ng_nat_libalias_info *)(void *)u.reply.data; |
(struct ng_nat_libalias_info *)(void *)u.reply.data; |
char path[NG_PATHSIZ]; |
char path[NG_PATHSIZ]; |
#endif |
#endif |
char buf[48]; |
char buf[48]; |
int k; |
int k; |
|
|
|
(void)ac; |
|
(void)av; |
|
(void)arg; |
|
|
Printf("NAT configuration:\r\n"); |
Printf("NAT configuration:\r\n"); |
Printf("\tAlias addresses : %s\r\n", |
Printf("\tAlias addresses : %s\r\n", |
u_addrtoa(&nat->alias_addr,buf,sizeof(buf))); |
u_addrtoa(&nat->alias_addr,buf,sizeof(buf))); |
Line 469 NatStat(Context ctx, int ac, char *av[], void *arg)
|
Line 474 NatStat(Context ctx, int ac, char *av[], void *arg)
|
#endif |
#endif |
Printf("NAT options:\r\n"); |
Printf("NAT options:\r\n"); |
OptStat(ctx, &nat->options, gConfList); |
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) { |
if (Enabled(&nat->options, NAT_CONF_LOG) && iface->up && iface->nat_up) { |
snprintf(path, sizeof(path), "mpd%d-%s-nat:", gPid, \ |
snprintf(path, sizeof(path), "mpd%d-%s-nat:", gPid, \ |
(char *)&ctx->bund->name); |
(char *)&ctx->bund->name); |
|
bzero(nli, sizeof(struct ng_nat_libalias_info)); |
Printf("LibAlias statistic:\r\n"); |
Printf("LibAlias statistic:\r\n"); |
if (NgFuncSendQuery(path, NGM_NAT_COOKIE, NGM_NAT_LIBALIAS_INFO, |
if (NgFuncSendQuery(path, NGM_NAT_COOKIE, NGM_NAT_LIBALIAS_INFO, |
NULL, 0, &u.reply, sizeof(u), NULL) < 0) |
NULL, 0, &u.reply, sizeof(u), NULL) < 0) |
Perror("Can't get LibAlis stats"); | Perror("Can't get LibAlias stats"); |
Printf("\ticmpLinkCount : %u\r\n", li->icmpLinkCount); | Printf("\ticmpLinkCount : %u\r\n", nli->icmpLinkCount); |
Printf("\tudpLinkCount : %u\r\n", li->udpLinkCount); | Printf("\tudpLinkCount : %u\r\n", nli->udpLinkCount); |
Printf("\ttcpLinkCount : %u\r\n", li->tcpLinkCount); | Printf("\ttcpLinkCount : %u\r\n", nli->tcpLinkCount); |
Printf("\tsctpLinkCount : %u\r\n", li->sctpLinkCount); | Printf("\tsctpLinkCount : %u\r\n", nli->sctpLinkCount); |
Printf("\tpptpLinkCount : %u\r\n", li->pptpLinkCount); | Printf("\tpptpLinkCount : %u\r\n", nli->pptpLinkCount); |
Printf("\tprotoLinkCount : %u\r\n", li->protoLinkCount); | Printf("\tprotoLinkCount : %u\r\n", nli->protoLinkCount); |
Printf("\tfragmentIdLinkCount : %u\r\n", li->fragmentIdLinkCount); | Printf("\tfragmentIdLinkCount : %u\r\n", nli->fragmentIdLinkCount); |
Printf("\tfragmentPtrLinkCount : %u\r\n", li->fragmentPtrLinkCount); | Printf("\tfragmentPtrLinkCount : %u\r\n", nli->fragmentPtrLinkCount); |
Printf("\tsockCount : %u\r\n", li->sockCount); | Printf("\tsockCount : %u\r\n", nli->sockCount); |
} |
} |
#endif |
#endif |
return(0); |
return(0); |