| 1143 | } |
| 1144 | |
| 1145 | static void |
| 1146 | table_lookup(ipfw_obj_header *oh, int ac, char *av[]) |
| 1147 | { |
| 1148 | ipfw_obj_tentry xtent; |
| 1149 | ipfw_xtable_info xi; |
| 1150 | char key[64]; |
| 1151 | int error; |
| 1152 | |
| 1153 | if (ac == 0) |
| 1154 | errx(EX_USAGE, "address required"); |
| 1155 | |
| 1156 | strlcpy(key, *av, sizeof(key)); |
| 1157 | |
| 1158 | memset(&xi, 0, sizeof(xi)); |
| 1159 | error = table_do_lookup(oh, key, &xi, &xtent); |
| 1160 | |
| 1161 | switch (error) { |
| 1162 | case 0: |
| 1163 | break; |
| 1164 | case ESRCH: |
| 1165 | errx(EX_UNAVAILABLE, "Table %s not found", oh->ntlv.name); |
| 1166 | case ENOENT: |
| 1167 | errx(EX_UNAVAILABLE, "Entry %s not found", *av); |
| 1168 | case ENOTSUP: |
| 1169 | errx(EX_UNAVAILABLE, "Table %s algo does not support " |
| 1170 | "\"lookup\" method", oh->ntlv.name); |
| 1171 | default: |
| 1172 | err(EX_OSERR, "getsockopt(IP_FW_TABLE_XFIND)"); |
| 1173 | } |
| 1174 | |
| 1175 | table_show_entry(&xi, &xtent); |
| 1176 | } |
| 1177 | |
| 1178 | static void |
| 1179 | tentry_fill_key_type(char *arg, ipfw_obj_tentry *tentry, uint8_t type, |
no test coverage detected