| 356 | } |
| 357 | |
| 358 | static int |
| 359 | ng_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: |
nothing calls this directly
no test coverage detected