Re: snmptrapd forwarding with OID wildcards [sec:unclass]
"Dave Shield" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On 01/05/07, Hart, Matthew MR 2 <[email protected]> wrote: > Would it be possible for the developers to add wildcard handling for the > forward directive in a future release? Done. See SVN revision 16330. I'll attach the relevant patch. Dave ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Net-snmp-users mailing list [email protected] Please see the following page to unsubscribe or change other options: https://lists.sourceforge.net/lists/listinfo/net-snmp-users
forward_subtree.diff
(text/x-patch, 1.5 KB)
Index: apps/snmptrapd_handlers.c
===================================================================
--- apps/snmptrapd_handlers.c (revision 16306)
+++ apps/snmptrapd_handlers.c (working copy)
@@ -135,9 +135,12 @@
char buf[STRINGMAX];
oid obuf[MAX_OID_LEN];
size_t olen = MAX_OID_LEN;
- char *cptr;
+ char *cptr, *cp;
netsnmp_trapd_handler *traph;
+ int flags = 0;
+ memset( buf, 0, sizeof(buf));
+ memset(obuf, 0, sizeof(obuf));
cptr = copy_nword(line, buf, sizeof(buf));
DEBUGMSGTL(("read_config:forward", "registering forward for: "));
if (!strcmp(buf, "default")) {
@@ -147,6 +150,18 @@
else
traph = netsnmp_add_default_traphandler( forward_handler );
} else {
+ cp = buf+strlen(buf)-1;
+ if ( *cp == '*' ) {
+ flags |= NETSNMP_TRAPHANDLER_FLAG_MATCH_TREE;
+ *(cp--) = '\0';
+ if ( *cp == '.' ) {
+ /*
+ * Distinguish between 'oid.*' & 'oid*'
+ */
+ flags |= NETSNMP_TRAPHANDLER_FLAG_STRICT_SUBTREE;
+ *(cp--) = '\0';
+ }
+ }
if (!read_objid(buf, obuf, &olen)) {
char buf1[STRINGMAX];
@@ -166,6 +181,7 @@
DEBUGMSG(("read_config:forward", "\n"));
if (traph) {
+ traph->flags = flags;
traph->authtypes = TRAP_AUTH_NET;
traph->token = strdup(cptr);
}