| 383 | } |
| 384 | |
| 385 | static int |
| 386 | ng_bridge_rcvmsg(node_p node, item_p item, hook_p lasthook) |
| 387 | { |
| 388 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 389 | struct ng_mesg *resp = NULL; |
| 390 | int error = 0; |
| 391 | struct ng_mesg *msg; |
| 392 | |
| 393 | NGI_GET_MSG(item, msg); |
| 394 | switch (msg->header.typecookie) { |
| 395 | #ifdef NGM_BRIDGE_TABLE_ABI |
| 396 | case NGM_BRIDGE_COOKIE_TBL: |
| 397 | switch (msg->header.cmd) { |
| 398 | case NGM_BRIDGE_GET_CONFIG: |
| 399 | { |
| 400 | struct ng_bridge_config_tbl *conf; |
| 401 | |
| 402 | NG_MKRESPONSE(resp, msg, sizeof(*conf), |
| 403 | M_NOWAIT|M_ZERO); |
| 404 | if (resp == NULL) { |
| 405 | error = ENOMEM; |
| 406 | break; |
| 407 | } |
| 408 | conf = (struct ng_bridge_config_tbl *)resp->data; |
| 409 | conf->cfg = priv->conf; |
| 410 | break; |
| 411 | } |
| 412 | case NGM_BRIDGE_SET_CONFIG: |
| 413 | { |
| 414 | struct ng_bridge_config_tbl *conf; |
| 415 | |
| 416 | if (msg->header.arglen != sizeof(*conf)) { |
| 417 | error = EINVAL; |
| 418 | break; |
| 419 | } |
| 420 | conf = (struct ng_bridge_config_tbl *)msg->data; |
| 421 | priv->conf = conf->cfg; |
| 422 | break; |
| 423 | } |
| 424 | case NGM_BRIDGE_GET_TABLE: |
| 425 | { |
| 426 | struct ng_bridge_host_tbl_ary *ary; |
| 427 | struct ng_bridge_hent *hent; |
| 428 | int i, bucket; |
| 429 | |
| 430 | NG_MKRESPONSE(resp, msg, sizeof(*ary) + |
| 431 | (priv->numHosts * sizeof(*ary->hosts)), M_NOWAIT); |
| 432 | if (resp == NULL) { |
| 433 | error = ENOMEM; |
| 434 | break; |
| 435 | } |
| 436 | ary = (struct ng_bridge_host_tbl_ary *)resp->data; |
| 437 | ary->numHosts = priv->numHosts; |
| 438 | i = 0; |
| 439 | for (bucket = 0; bucket < priv->numBuckets; bucket++) { |
| 440 | SLIST_FOREACH(hent, &priv->tab[bucket], next) { |
| 441 | memcpy(ary->hosts[i].addr, |
| 442 | hent->host.addr, |
nothing calls this directly
no test coverage detected