Lines Matching +full:op +full:- +full:tee

2  * Copyright (c) 2001-2003
147 d->cookie = cookie; in ng_register_cookie()
148 d->id = id; in ng_register_cookie()
149 d->func = func; in ng_register_cookie()
150 d->arg = arg; in ng_register_cookie()
151 d->mod = mod; in ng_register_cookie()
182 strcpy(d->hook, hook); in ng_register_hook()
183 d->func = func; in ng_register_hook()
184 d->arg = arg; in ng_register_hook()
185 d->mod = mod; in ng_register_hook()
217 if (m->mod == mod) { in ng_unregister_module()
227 if (d->mod == mod) { in ng_unregister_module()
255 if (d->cookie == mesg->header.typecookie && in csock_handle()
256 (d->id == 0 || d->id == id || id == 0)) in csock_handle()
257 (*d->func)(mesg, path, id, d->arg); in csock_handle()
291 syslog(LOG_DEBUG, "node closed -- exiting"); in csock_read()
384 if (setsockopt(csock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) in ng_dialog()
391 if (mesg->header.token == (u_int)token) in ng_dialog()
399 b->mesg = mesg; in ng_dialog()
400 strcpy(b->path, rpath); in ng_dialog()
406 if (setsockopt(csock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) in ng_dialog()
464 if ((len = NgRecvData(fd, resbuf, resbufsiz + 1, hook)) == -1) { in dsock_input()
487 if (strcmp(hook, d->hook) == 0) in dsock_input()
488 (*d->func)(hook, resbuf, len, d->arg); in dsock_input()
507 csock_handle(b->mesg, b->path); in ng_idle()
513 * Called when the module is loaded. Returning a non-zero value means,
540 if (sysctl(name, 2, &clockinfo, &len, NULL, 0) == -1) in ng_init()
560 id = ((struct nodeinfo *)(void *)resp->data)->id; in ng_node_id()
573 id = ((struct nodeinfo *)(void *)resp->data)->id; in ng_node_id_node()
585 strcpy(name, ((struct nodeinfo *)(void *)resp->data)->name); in ng_node_name()
598 strcpy(type, ((struct nodeinfo *)(void *)resp->data)->type); in ng_node_type()
651 ng_ID_t tee; in ng_connect2_tee_id() local
653 if ((tee = ng_mkpeer_id(id, NULL, "tee", ourhook, "left")) == 0) in ng_connect2_tee_id()
654 return (-1); in ng_connect2_tee_id()
656 snprintf(path, NG_PATHSIZ, "[%x]:", tee); in ng_connect2_tee_id()
667 * and return its node id. tee nodes between node and the target node
668 * are skipped. If the type is wrong, or the hook is a dead-end return 0.
684 hooklist = (struct hooklist *)(void *)resp->data; in ng_next_node_id_internal()
686 for (i = 0; i < hooklist->nodeinfo.hooks; i++) in ng_next_node_id_internal()
687 if (strcmp(hooklist->link[i].ourhook, hook) == 0) in ng_next_node_id_internal()
690 if (i == hooklist->nodeinfo.hooks) { in ng_next_node_id_internal()
695 node = hooklist->link[i].nodeinfo.id; in ng_next_node_id_internal()
697 if (skip_tee && strcmp(hooklist->link[i].nodeinfo.type, "tee") == 0) { in ng_next_node_id_internal()
698 if (strcmp(hooklist->link[i].peerhook, "left") == 0) in ng_next_node_id_internal()
700 else if (strcmp(hooklist->link[i].peerhook, "right") == 0) in ng_next_node_id_internal()
703 strcmp(hooklist->link[i].nodeinfo.type, type) != 0) in ng_next_node_id_internal()
707 strcmp(hooklist->link[i].nodeinfo.type, type) != 0) in ng_next_node_id_internal()
717 * and return its node id. tee nodes between node and the target node
718 * are skipped. If the type is wrong, or the hook is a dead-end return 0.
741 &mkpeer, sizeof(mkpeer)) == -1) in ng_mkpeer_id()
751 &name, sizeof(name)) == -1) in ng_mkpeer_id()
799 * Disconnect a hook and shutdown all tee nodes that were connected to that
813 /* if we have just shutdown a tee node, which had no other hooks in ng_rmhook_tee_id()
819 hooklist = (struct hooklist *)(void *)resp->data; in ng_rmhook_tee_id()
821 for (i = 0; i < hooklist->nodeinfo.hooks; i++) in ng_rmhook_tee_id()
822 if (strcmp(hooklist->link[i].ourhook, hook) == 0) in ng_rmhook_tee_id()
825 if (i == hooklist->nodeinfo.hooks) { in ng_rmhook_tee_id()
832 if (strcmp(hooklist->link[i].nodeinfo.type, "tee") == 0) { in ng_rmhook_tee_id()
833 if (strcmp(hooklist->link[i].peerhook, "left") == 0) { in ng_rmhook_tee_id()
834 next_node = hooklist->link[i].nodeinfo.id; in ng_rmhook_tee_id()
836 } else if (strcmp(hooklist->link[i].peerhook, "right") == 0) { in ng_rmhook_tee_id()
837 next_node = hooklist->link[i].nodeinfo.id; in ng_rmhook_tee_id()
857 * Get the peer hook of a hook on a given node. Skip any tee nodes in between
872 hooklist = (struct hooklist *)(void *)resp->data; in ng_peer_hook_id()
874 for (i = 0; i < hooklist->nodeinfo.hooks; i++) in ng_peer_hook_id()
875 if (strcmp(hooklist->link[i].ourhook, hook) == 0) in ng_peer_hook_id()
878 if (i == hooklist->nodeinfo.hooks) { in ng_peer_hook_id()
880 return (-1); in ng_peer_hook_id()
883 node = hooklist->link[i].nodeinfo.id; in ng_peer_hook_id()
886 if (strcmp(hooklist->link[i].nodeinfo.type, "tee") == 0) { in ng_peer_hook_id()
887 if (strcmp(hooklist->link[i].peerhook, "left") == 0) in ng_peer_hook_id()
889 else if (strcmp(hooklist->link[i].peerhook, "right") == 0) in ng_peer_hook_id()
892 strcpy(peerhook, hooklist->link[i].peerhook); in ng_peer_hook_id()
895 strcpy(peerhook, hooklist->link[i].peerhook); in ng_peer_hook_id()
960 "This module implements access to the netgraph sub-system",
975 u_int sub, u_int iidx __unused, enum snmp_op op) in op_ng_config() argument
977 asn_subid_t which = value->var.subs[sub - 1]; in op_ng_config()
980 switch (op) { in op_ng_config()
992 return (string_get(value, snmp_nodename, -1)); in op_ng_config()
995 value->v.integer = resbufsiz; in op_ng_config()
999 value->v.integer = timeout; in op_ng_config()
1003 value->v.uint32 = debug_level; in op_ng_config()
1022 if ((ret = string_save(value, ctx, -1, &snmp_nodename)) in op_ng_config()
1036 ctx->scratch->int1 = resbufsiz; in op_ng_config()
1037 if (value->v.integer < 1024 || in op_ng_config()
1038 value->v.integer > 0x10000) in op_ng_config()
1040 resbufsiz = value->v.integer; in op_ng_config()
1044 ctx->scratch->int1 = timeout; in op_ng_config()
1045 if (value->v.integer < 10 || in op_ng_config()
1046 value->v.integer > 10000) in op_ng_config()
1048 timeout = value->v.integer; in op_ng_config()
1052 ctx->scratch->int1 = debug_level; in op_ng_config()
1053 debug_level = value->v.uint32; in op_ng_config()
1070 resbufsiz = ctx->scratch->int1; in op_ng_config()
1074 timeout = ctx->scratch->int1; in op_ng_config()
1078 debug_level = ctx->scratch->int1; in op_ng_config()
1103 u_int sub, u_int iidx __unused, enum snmp_op op) in op_ng_stats() argument
1105 switch (op) { in op_ng_stats()
1111 value->v.uint32 = stats[value->var.subs[sub - 1] - 1]; in op_ng_stats()
1146 typelist = (struct typelist *)(void *)resp->data; in fetch_types()
1148 for (u = 0; u < typelist->numtypes; u++) { in fetch_types()
1153 strcpy(t->name, typelist->typeinfo[u].type_name); in fetch_types()
1154 t->index.subs[0] = strlen(t->name); in fetch_types()
1155 t->index.len = t->index.subs[0] + 1; in fetch_types()
1156 for (i = 0; i < t->index.subs[0]; i++) in fetch_types()
1157 t->index.subs[i + 1] = t->name[i]; in fetch_types()
1179 return (-1); in ngtype_load()
1199 return (-1); in ngtype_unload()
1204 if ((id = kldfind(mod)) == -1) { in ngtype_unload()
1206 return (-1); in ngtype_unload()
1214 u_int sub, u_int iidx, enum snmp_op op) in op_ng_type() argument
1216 asn_subid_t which = value->var.subs[sub - 1]; in op_ng_type()
1223 switch (op) { in op_ng_type()
1228 if ((t = NEXT_OBJECT_OID(&ngtype_list, &value->var, sub)) == NULL) in op_ng_type()
1230 index_append(&value->var, sub, &t->index); in op_ng_type()
1236 if ((t = FIND_OBJECT_OID(&ngtype_list, &value->var, sub)) == NULL) in op_ng_type()
1241 if (index_decode(&value->var, sub, iidx, &name, &namelen)) in op_ng_type()
1251 t = FIND_OBJECT_OID(&ngtype_list, &value->var, sub); in op_ng_type()
1259 if (!TRUTH_OK(value->v.integer)) { in op_ng_type()
1263 ctx->scratch->int1 = TRUTH_GET(value->v.integer); in op_ng_type()
1264 ctx->scratch->int1 |= (t != NULL) << 1; in op_ng_type()
1265 ctx->scratch->ptr2 = name; in op_ng_type()
1266 ctx->scratch->int2 = namelen; in op_ng_type()
1270 if (ctx->scratch->int1 & 1) { in op_ng_type()
1272 if (ngtype_load(name, namelen) == -1) { in op_ng_type()
1282 if (!(ctx->scratch->int1 & 1)) { in op_ng_type()
1284 if (ngtype_unload(name, namelen) == -1) { in op_ng_type()
1294 if (!(ctx->scratch->int1 & 2)) { in op_ng_type()
1296 if (ctx->scratch->int1 & 1) { in op_ng_type()
1297 /* request to load - unload */ in op_ng_type()
1298 if (ngtype_unload(ctx->scratch->ptr2, in op_ng_type()
1299 ctx->scratch->int2) == -1) in op_ng_type()
1304 if (!(ctx->scratch->int1 & 1)) { in op_ng_type()
1305 /* request to unload - reload */ in op_ng_type()
1306 if (ngtype_load(ctx->scratch->ptr2, in op_ng_type()
1307 ctx->scratch->int2) == -1) in op_ng_type()
1311 free(ctx->scratch->ptr2); in op_ng_type()
1315 free(ctx->scratch->ptr2); in op_ng_type()
1328 value->v.integer = status; in op_ng_type()
1343 ng_ID_t id = oid->subs[sub]; in find_node()
1348 return (-1); in find_node()
1350 *info = *(struct nodeinfo *)(void *)resp->data; in find_node()
1361 if (i1->id < i2->id) in ncmp()
1362 return (-1); in ncmp()
1363 if (i1->id > i2->id) in ncmp()
1371 u_int idxlen = oid->len - sub; in find_node_next()
1379 return (-1); in find_node_next()
1380 list = (struct namelist *)(void *)resp->data; in find_node_next()
1382 qsort(list->nodeinfo, list->numnames, sizeof(list->nodeinfo[0]), ncmp); in find_node_next()
1385 if (list->numnames == 0) { in find_node_next()
1387 return (-1); in find_node_next()
1389 *info = list->nodeinfo[0]; in find_node_next()
1393 id = oid->subs[sub]; in find_node_next()
1395 for (i = 0; i < list->numnames; i++) in find_node_next()
1396 if (list->nodeinfo[i].id > id) { in find_node_next()
1397 *info = list->nodeinfo[i]; in find_node_next()
1403 return (-1); in find_node_next()
1408 u_int sub, u_int iidx __unused, enum snmp_op op) in op_ng_node() argument
1410 asn_subid_t which = value->var.subs[sub - 1]; in op_ng_node()
1411 u_int idxlen = value->var.len - sub; in op_ng_node()
1414 switch (op) { in op_ng_node()
1417 if (find_node_next(&value->var, sub, &nodeinfo) == -1) in op_ng_node()
1419 value->var.len = sub + 1; in op_ng_node()
1420 value->var.subs[sub] = nodeinfo.id; in op_ng_node()
1426 if (find_node(&value->var, sub, &nodeinfo) == -1) in op_ng_node()
1433 if (find_node(&value->var, sub, &nodeinfo) == -1) in op_ng_node()
1449 value->v.integer = 1; in op_ng_node()
1452 return (string_get(value, nodeinfo.name, -1)); in op_ng_node()
1454 return (string_get(value, nodeinfo.type, -1)); in op_ng_node()
1456 value->v.uint32 = nodeinfo.hooks; in op_ng_node()
1477 return (-1); in find_hook()
1479 list = (struct hooklist *)(void *)resp->data; in find_hook()
1481 for (i = 0; i < list->nodeinfo.hooks; i++) { in find_hook()
1482 if (strlen(list->link[i].ourhook) == hooklen && in find_hook()
1483 strncmp(list->link[i].ourhook, hook, hooklen) == 0) { in find_hook()
1484 *info = list->link[i]; in find_hook()
1490 return (-1); in find_hook()
1499 if (strlen(i1->ourhook) < strlen(i2->ourhook)) in hook_cmp()
1500 return (-1); in hook_cmp()
1501 if (strlen(i1->ourhook) > strlen(i2->ourhook)) in hook_cmp()
1503 return (strcmp(i1->ourhook, i2->ourhook)); in hook_cmp()
1510 u_int idxlen = oid->len - sub; in find_hook_next()
1524 return (-1); in find_hook_next()
1525 list = (struct namelist *)(void *)resp->data; in find_hook_next()
1527 qsort(list->nodeinfo, list->numnames, sizeof(list->nodeinfo[0]), ncmp); in find_hook_next()
1541 for (node_index = 0; node_index < list->numnames; node_index++) in find_hook_next()
1542 if (list->nodeinfo[node_index].id >= oid->subs[sub]) in find_hook_next()
1549 if (idxlen == 1 || node_index >= list->numnames || in find_hook_next()
1550 list->nodeinfo[node_index].id > oid->subs[sub]) in find_hook_next()
1558 if ((resp1 = ng_dialog_id(list->nodeinfo[node_index].id, in find_hook_next()
1561 return (-1); in find_hook_next()
1563 hooks = (struct hooklist *)(void *)resp1->data; in find_hook_next()
1564 if (hooks->nodeinfo.hooks > 0) { in find_hook_next()
1565 qsort(hooks->link, hooks->nodeinfo.hooks, in find_hook_next()
1566 sizeof(hooks->link[0]), hook_cmp); in find_hook_next()
1567 for (i = 0; i < hooks->nodeinfo.hooks; i++) { in find_hook_next()
1568 idx.len = strlen(hooks->link[i].ourhook) + 1; in find_hook_next()
1569 idx.subs[0] = idx.len - 1; in find_hook_next()
1571 idx.subs[j + 1] = hooks->link[i].ourhook[j]; in find_hook_next()
1575 if (i < hooks->nodeinfo.hooks) { in find_hook_next()
1576 *nodeinfo = hooks->nodeinfo; in find_hook_next()
1577 *linkinfo = hooks->link[i]; in find_hook_next()
1585 /* no hook found larger than the index on the index node - take in find_hook_next()
1591 while (node_index < list->numnames) { in find_hook_next()
1592 if ((resp1 = ng_dialog_id(list->nodeinfo[node_index].id, in find_hook_next()
1595 hooks = (struct hooklist *)(void *)resp1->data; in find_hook_next()
1596 if (hooks->nodeinfo.hooks > 0) { in find_hook_next()
1597 qsort(hooks->link, hooks->nodeinfo.hooks, in find_hook_next()
1598 sizeof(hooks->link[0]), hook_cmp); in find_hook_next()
1600 *nodeinfo = hooks->nodeinfo; in find_hook_next()
1601 *linkinfo = hooks->link[0]; in find_hook_next()
1614 return (-1); in find_hook_next()
1619 u_int sub, u_int iidx, enum snmp_op op) in op_ng_hook() argument
1621 asn_subid_t which = value->var.subs[sub - 1]; in op_ng_hook()
1629 switch (op) { in op_ng_hook()
1632 if (find_hook_next(&value->var, sub, &nodeinfo, &linkinfo) == -1) in op_ng_hook()
1635 value->var.len = sub + 1 + 1 + strlen(linkinfo.ourhook); in op_ng_hook()
1636 value->var.subs[sub] = nodeinfo.id; in op_ng_hook()
1637 value->var.subs[sub + 1] = strlen(linkinfo.ourhook); in op_ng_hook()
1639 value->var.subs[sub + i + 2] = in op_ng_hook()
1644 if (index_decode(&value->var, sub, iidx, &lid, in op_ng_hook()
1647 if (find_hook(lid, hook, hooklen, &linkinfo) == -1) { in op_ng_hook()
1655 if (index_decode(&value->var, sub, iidx, &lid, in op_ng_hook()
1658 if (find_hook(lid, hook, hooklen, &linkinfo) == -1) { in op_ng_hook()
1675 value->v.integer = 1; in op_ng_hook()
1678 value->v.uint32 = linkinfo.nodeinfo.id; in op_ng_hook()
1681 return (string_get(value, linkinfo.peerhook, -1)); in op_ng_hook()
1683 return (string_get(value, linkinfo.nodeinfo.type, -1)); in op_ng_hook()