MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_generic_msg

Function ng_generic_msg

lib/ff_ng_base.c:2528–2966  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2526 * Implement the 'generic' control messages
2527 ***********************************************************************/
2528static int
2529ng_generic_msg(node_p here, item_p item, hook_p lasthook)
2530{
2531 int error = 0;
2532 struct ng_mesg *msg;
2533 struct ng_mesg *resp = NULL;
2534
2535 NGI_GET_MSG(item, msg);
2536 if (msg->header.typecookie != NGM_GENERIC_COOKIE) {
2537 TRAP_ERROR();
2538 error = EINVAL;
2539 goto out;
2540 }
2541 switch (msg->header.cmd) {
2542 case NGM_SHUTDOWN:
2543 ng_rmnode(here, NULL, NULL, 0);
2544 break;
2545 case NGM_MKPEER:
2546 {
2547 struct ngm_mkpeer *const mkp = (struct ngm_mkpeer *) msg->data;
2548
2549 if (msg->header.arglen != sizeof(*mkp)) {
2550 TRAP_ERROR();
2551 error = EINVAL;
2552 break;
2553 }
2554 mkp->type[sizeof(mkp->type) - 1] = '\0';
2555 mkp->ourhook[sizeof(mkp->ourhook) - 1] = '\0';
2556 mkp->peerhook[sizeof(mkp->peerhook) - 1] = '\0';
2557 error = ng_mkpeer(here, mkp->ourhook, mkp->peerhook, mkp->type);
2558 break;
2559 }
2560 case NGM_CONNECT:
2561 {
2562 struct ngm_connect *const con =
2563 (struct ngm_connect *) msg->data;
2564 node_p node2;
2565
2566 if (msg->header.arglen != sizeof(*con)) {
2567 TRAP_ERROR();
2568 error = EINVAL;
2569 break;
2570 }
2571 con->path[sizeof(con->path) - 1] = '\0';
2572 con->ourhook[sizeof(con->ourhook) - 1] = '\0';
2573 con->peerhook[sizeof(con->peerhook) - 1] = '\0';
2574 /* Don't forget we get a reference.. */
2575 error = ng_path2noderef(here, con->path, &node2, NULL);
2576 if (error)
2577 break;
2578 error = ng_con_nodes(item, here, con->ourhook,
2579 node2, con->peerhook);
2580 NG_NODE_UNREF(node2);
2581 break;
2582 }
2583 case NGM_NAME:
2584 {
2585 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