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

Function ng_generic_msg

freebsd/netgraph/ng_base.c:2508–2946  ·  view source on GitHub ↗

* Implement the 'generic' control messages ***********************************************************************/

Source from the content-addressed store, hash-verified

2506 * Implement the 'generic' control messages
2507 ***********************************************************************/
2508static int
2509ng_generic_msg(node_p here, item_p item, hook_p lasthook)
2510{
2511 int error = 0;
2512 struct ng_mesg *msg;
2513 struct ng_mesg *resp = NULL;
2514
2515 NGI_GET_MSG(item, msg);
2516 if (msg->header.typecookie != NGM_GENERIC_COOKIE) {
2517 TRAP_ERROR();
2518 error = EINVAL;
2519 goto out;
2520 }
2521 switch (msg->header.cmd) {
2522 case NGM_SHUTDOWN:
2523 ng_rmnode(here, NULL, NULL, 0);
2524 break;
2525 case NGM_MKPEER:
2526 {
2527 struct ngm_mkpeer *const mkp = (struct ngm_mkpeer *) msg->data;
2528
2529 if (msg->header.arglen != sizeof(*mkp)) {
2530 TRAP_ERROR();
2531 error = EINVAL;
2532 break;
2533 }
2534 mkp->type[sizeof(mkp->type) - 1] = '\0';
2535 mkp->ourhook[sizeof(mkp->ourhook) - 1] = '\0';
2536 mkp->peerhook[sizeof(mkp->peerhook) - 1] = '\0';
2537 error = ng_mkpeer(here, mkp->ourhook, mkp->peerhook, mkp->type);
2538 break;
2539 }
2540 case NGM_CONNECT:
2541 {
2542 struct ngm_connect *const con =
2543 (struct ngm_connect *) msg->data;
2544 node_p node2;
2545
2546 if (msg->header.arglen != sizeof(*con)) {
2547 TRAP_ERROR();
2548 error = EINVAL;
2549 break;
2550 }
2551 con->path[sizeof(con->path) - 1] = '\0';
2552 con->ourhook[sizeof(con->ourhook) - 1] = '\0';
2553 con->peerhook[sizeof(con->peerhook) - 1] = '\0';
2554 /* Don't forget we get a reference.. */
2555 error = ng_path2noderef(here, con->path, &node2, NULL);
2556 if (error)
2557 break;
2558 error = ng_con_nodes(item, here, con->ourhook,
2559 node2, con->peerhook);
2560 NG_NODE_UNREF(node2);
2561 break;
2562 }
2563 case NGM_NAME:
2564 {
2565 struct ngm_name *const nam = (struct ngm_name *) msg->data;

Callers 1

ng_apply_itemFunction · 0.70

Calls 13

snprintfFunction · 0.85
ng_unparseFunction · 0.85
strcmpFunction · 0.85
ng_parseFunction · 0.85
ng_rmnodeFunction · 0.70
ng_mkpeerFunction · 0.70
ng_path2noderefFunction · 0.70
ng_con_nodesFunction · 0.70
ng_name_nodeFunction · 0.70
ng_findhookFunction · 0.70
ng_destroy_hookFunction · 0.70
ng_node2IDFunction · 0.70

Tested by

no test coverage detected