MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ipfw_show_nat

Function ipfw_show_nat

tools/ipfw/nat.c:1115–1160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113}
1114
1115void
1116ipfw_show_nat(int ac, char **av)
1117{
1118 ipfw_obj_header *oh;
1119 char *name;
1120 int cmd;
1121 struct nat_list_arg nla;
1122
1123 ac--;
1124 av++;
1125
1126 if (g_co.test_only)
1127 return;
1128
1129 /* Parse parameters. */
1130 cmd = 0; /* XXX: Change to IP_FW_NAT44_XGETLOG @ MFC */
1131 name = NULL;
1132 for ( ; ac != 0; ac--, av++) {
1133 if (!strncmp(av[0], "config", strlen(av[0]))) {
1134 cmd = IP_FW_NAT44_XGETCONFIG;
1135 continue;
1136 }
1137 if (strcmp(av[0], "log") == 0) {
1138 cmd = IP_FW_NAT44_XGETLOG;
1139 continue;
1140 }
1141 if (name != NULL)
1142 err(EX_USAGE,"only one instance name may be specified");
1143 name = av[0];
1144 }
1145
1146 if (cmd == 0)
1147 errx(EX_USAGE, "Please specify action. Available: config,log");
1148
1149 if (name == NULL) {
1150 memset(&nla, 0, sizeof(nla));
1151 nla.cmd = cmd;
1152 nla.is_all = 1;
1153 nat_foreach(nat_show_data, &nla, 1);
1154 } else {
1155 if (nat_get_cmd(name, cmd, &oh) != 0)
1156 err(EX_OSERR, "Error getting nat %s instance info", name);
1157 nat_show_cfg((struct nat44_cfg_nat *)(oh + 1), NULL);
1158 free(oh);
1159 }
1160}
1161

Callers 2

ipfw_config_natFunction · 0.85
main.cFile · 0.85

Calls 7

strncmpFunction · 0.85
strcmpFunction · 0.85
memsetFunction · 0.85
nat_foreachFunction · 0.85
nat_get_cmdFunction · 0.85
nat_show_cfgFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected