* pfil_head_register() registers a pfil_head with the packet filter hook * mechanism. */
| 203 | * mechanism. |
| 204 | */ |
| 205 | pfil_head_t |
| 206 | pfil_head_register(struct pfil_head_args *pa) |
| 207 | { |
| 208 | struct pfil_head *head, *list; |
| 209 | |
| 210 | MPASS(pa->pa_version == PFIL_VERSION); |
| 211 | |
| 212 | head = malloc(sizeof(struct pfil_head), M_PFIL, M_WAITOK); |
| 213 | |
| 214 | head->head_nhooksin = head->head_nhooksout = 0; |
| 215 | head->head_flags = pa->pa_flags; |
| 216 | head->head_type = pa->pa_type; |
| 217 | head->head_name = pa->pa_headname; |
| 218 | CK_STAILQ_INIT(&head->head_in); |
| 219 | CK_STAILQ_INIT(&head->head_out); |
| 220 | |
| 221 | PFIL_LOCK(); |
| 222 | LIST_FOREACH(list, &V_pfil_head_list, head_list) |
| 223 | if (strcmp(pa->pa_headname, list->head_name) == 0) { |
| 224 | printf("pfil: duplicate head \"%s\"\n", |
| 225 | pa->pa_headname); |
| 226 | } |
| 227 | LIST_INSERT_HEAD(&V_pfil_head_list, head, head_list); |
| 228 | PFIL_UNLOCK(); |
| 229 | |
| 230 | return (head); |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | * pfil_head_unregister() removes a pfil_head from the packet filter hook |
no test coverage detected