| 1080 | } |
| 1081 | |
| 1082 | static int |
| 1083 | nat_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 | |
| 1115 | void |
| 1116 | ipfw_show_nat(int ac, char **av) |
no test coverage detected