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

Function ng_nat_rcvmsg

freebsd/netgraph/ng_nat.c:358–752  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358static int
359ng_nat_rcvmsg(node_p node, item_p item, hook_p lasthook)
360{
361 const priv_p priv = NG_NODE_PRIVATE(node);
362 struct ng_mesg *resp = NULL;
363 struct ng_mesg *msg;
364 int error = 0;
365
366 NGI_GET_MSG(item, msg);
367
368 switch (msg->header.typecookie) {
369 case NGM_NAT_COOKIE:
370 switch (msg->header.cmd) {
371 case NGM_NAT_SET_IPADDR:
372 {
373 struct in_addr *const ia = (struct in_addr *)msg->data;
374
375 if (msg->header.arglen < sizeof(*ia)) {
376 error = EINVAL;
377 break;
378 }
379
380 LibAliasSetAddress(priv->lib, *ia);
381
382 priv->flags |= NGNAT_ADDR_DEFINED;
383 }
384 break;
385 case NGM_NAT_SET_MODE:
386 {
387 struct ng_nat_mode *const mode =
388 (struct ng_nat_mode *)msg->data;
389
390 if (msg->header.arglen < sizeof(*mode)) {
391 error = EINVAL;
392 break;
393 }
394
395 if (LibAliasSetMode(priv->lib,
396 ng_nat_translate_flags(mode->flags),
397 ng_nat_translate_flags(mode->mask)) < 0) {
398 error = ENOMEM;
399 break;
400 }
401 }
402 break;
403 case NGM_NAT_SET_TARGET:
404 {
405 struct in_addr *const ia = (struct in_addr *)msg->data;
406
407 if (msg->header.arglen < sizeof(*ia)) {
408 error = EINVAL;
409 break;
410 }
411
412 LibAliasSetTarget(priv->lib, *ia);
413 }
414 break;
415 case NGM_NAT_REDIRECT_PORT:

Callers

nothing calls this directly

Calls 13

LibAliasSetAddressFunction · 0.85
LibAliasSetModeFunction · 0.85
ng_nat_translate_flagsFunction · 0.85
LibAliasSetTargetFunction · 0.85
mallocFunction · 0.85
LibAliasRedirectPortFunction · 0.85
LibAliasRedirectAddrFunction · 0.85
LibAliasRedirectProtoFunction · 0.85
LibAliasRedirectDynamicFunction · 0.85
LibAliasRedirectDeleteFunction · 0.85
LibAliasAddServerFunction · 0.85
LibAliasProxyRuleFunction · 0.85

Tested by

no test coverage detected