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

Function pfil_head_register

freebsd/net/pfil.c:205–231  ·  view source on GitHub ↗

* pfil_head_register() registers a pfil_head with the packet filter hook * mechanism. */

Source from the content-addressed store, hash-verified

203 * mechanism.
204 */
205pfil_head_t
206pfil_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

Callers 4

ip_initFunction · 0.85
ip6_initFunction · 0.85
iflib_add_pfilFunction · 0.85
vnet_ether_initFunction · 0.85

Calls 3

mallocFunction · 0.85
strcmpFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected