From: <no...@so...> - 2001-07-30 15:23:33
|
Bugs item #416836, was opened at 2001-04-17 14:00 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112694&aid=416836&group_id=12694 Category: apps Group: None Status: Closed Resolution: Wont Fix Priority: 1 Submitted By: Nobody/Anonymous (nobody) Assigned to: John Naylon (jbpn) Summary: snmptrapd-not listening on specified I/F Initial Comment: UCD-snmp version: 4.2.1 compiled from source for RedHat 6.2 with kernel 2.2.17-14.1s6 on an i686 ---------------- starting snmptrapd with -p option does not appear to limit interfaces on which it listens. If I execute snmpd -p 16...@my...s netstat (and a walk of the udp table) shows snmpd only listening on that i/f If I execute snmptrapd -p 16...@my...s netstat (and a walk of the udp table) shows snmptrapd listening on all interfaces. david ---------------------------------------------------------------------- Comment By: Zing Shishak (shishz) Date: 2001-07-30 08:23 Message: Logged In: YES user_id=284784 hacked in -i <ip addr>... had to do this recently. yechh. --- ucd-snmp-4.2.1/apps/snmptrapd.c.orig Mon Jul 30 10:06:40 2001 +++ ucd-snmp-4.2.1/apps/snmptrapd.c Mon Jul 30 10:50:54 2001 @@ -657,6 +657,7 @@ int count, numfds, block; fd_set fdset; struct timeval timeout, *tvp; + char local_ip[80] = "\0"; int local_port = SNMP_TRAP_PORT; int dofork=1; char *cp; @@ -702,7 +703,7 @@ /* * usage: snmptrapd [-D] [-u PIDFILE] [-p #] [-P] [-s] [-l [d0-7]] [-d] [-e] [-a] */ - while ((arg = getopt(argc, argv, "VdnqRD:p:m:M:Po:O:esSafl:Hu:c:CF:T:")) != EOF){ + while ((arg = getopt(argc, argv, "VdnqRD:i:p:m:M:Po:O:esSafl:Hu:c:CF:T:")) != EOF){ switch(arg) { case 'V': fprintf(stderr,"UCD-snmp version: %s\n", VersionInfo); @@ -718,6 +719,10 @@ debug_register_tokens(optarg); snmp_set_do_debugging(1); break; + case 'i': + local_ip[80]='\0'; + strncpy(local_ip, optarg,79); + break; case 'p': local_port = atoi(optarg); break; @@ -908,7 +913,14 @@ snmp_sess_init(session); - session->peername = SNMP_DEFAULT_PEERNAME; /* Original code had NULL here */ + + /* hack in support for binding to specific interface (-i <ip addr>) */ + if (strlen(local_ip)) { + session->peername = malloc(strlen(local_ip)); + strcpy(session->peername, local_ip); + } + else + session->peername = SNMP_DEFAULT_PEERNAME; /* Original code had NULL here */ session->version = SNMP_DEFAULT_VERSION; session->community_len = SNMP_DEFAULT_COMMUNITY_LEN; ---------------------------------------------------------------------- Comment By: John Naylon (jbpn) Date: 2001-04-18 02:52 Message: Logged In: YES user_id=93926 Binding to a specific interface is not currently supported by snmptrapd, only snmpd. I know this seems inconsistent, but I don't believe it is claimed anywhere that snmptrapd does support binding to a specific interface. It would be pretty easy to hack this to make it work if you need to (see snmptrapd.c). "Unified transport endpoint specifier handling" is a work item for 5.0, and how it works will likely completely change, so I don't propose to put any effort into a "quick fix" now. Of course if someone else wants to... ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112694&aid=416836&group_id=12694 |