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

Function ng_nat_constructor

freebsd/netgraph/ng_nat.c:305–337  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303#define NGNAT_ADDR_DEFINED 0x2 /* NGM_NAT_SET_IPADDR happened */
304
305static int
306ng_nat_constructor(node_p node)
307{
308 priv_p priv;
309
310 /* Initialize private descriptor. */
311 priv = malloc(sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO);
312
313 /* Init aliasing engine. */
314 priv->lib = LibAliasInit(NULL);
315
316 /* Set same ports on. */
317 (void )LibAliasSetMode(priv->lib, PKT_ALIAS_SAME_PORTS,
318 PKT_ALIAS_SAME_PORTS);
319
320 /* Init redirects housekeeping. */
321 priv->rdrcount = 0;
322 priv->nextid = 1;
323 priv->dlt = DLT_RAW;
324 STAILQ_INIT(&priv->redirhead);
325
326 /* Link structs together. */
327 NG_NODE_SET_PRIVATE(node, priv);
328 priv->node = node;
329
330 /*
331 * libalias is not thread safe, so our node
332 * must be single threaded.
333 */
334 NG_NODE_FORCE_WRITER(node);
335
336 return (0);
337}
338
339static int
340ng_nat_newhook(node_p node, hook_p hook, const char *name)

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.85
LibAliasInitFunction · 0.85
LibAliasSetModeFunction · 0.85

Tested by

no test coverage detected