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

Function nat_get_cmd

tools/ipfw/nat.c:1082–1113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1080}
1081
1082static int
1083nat_get_cmd(char *name, uint16_t cmd, ipfw_obj_header **ooh)
1084{
1085 ipfw_obj_header *oh;
1086 struct nat44_cfg_nat *cfg;
1087 size_t sz;
1088
1089 /* Start with reasonable default */
1090 sz = sizeof(*oh) + sizeof(*cfg) + 128;
1091
1092 for (;;) {
1093 if ((oh = calloc(1, sz)) == NULL)
1094 return (ENOMEM);
1095 cfg = (struct nat44_cfg_nat *)(oh + 1);
1096 oh->ntlv.head.length = sizeof(oh->ntlv);
1097 strlcpy(oh->ntlv.name, name, sizeof(oh->ntlv.name));
1098 strlcpy(cfg->name, name, sizeof(cfg->name));
1099
1100 if (do_get3(cmd, &oh->opheader, &sz) != 0) {
1101 sz = cfg->size;
1102 free(oh);
1103 if (errno == ENOMEM)
1104 continue;
1105 return (errno);
1106 }
1107
1108 *ooh = oh;
1109 break;
1110 }
1111
1112 return (0);
1113}
1114
1115void
1116ipfw_show_nat(int ac, char **av)

Callers 2

nat_show_dataFunction · 0.85
ipfw_show_natFunction · 0.85

Calls 4

callocFunction · 0.85
do_get3Function · 0.85
strlcpyFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected