ID: 9401
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: SNMP related
Description: Unable to set remote SNMP port

Here is a small patch that will enable "host:port" in snmp connections :

*** snmp.c.old  Thu Sep 14 22:22:02 2000
--- snmp.c      Thu Feb 22 17:02:06 2001
***************
*** 148,153 ****
--- 148,156 ----
        int myargc = ZEND_NUM_ARGS();
      char type = (char) 0;
      char *value = (char *) 0;
+       char hostname[MAX_NAME_LEN];
+       int remote_port = 161;
+       char *pptr;
        
        if (myargc < 3 || myargc > 7 ||
                zend_get_parameters_ex(myargc, &a1, &a2, &a3, &a4, &a5, &a6, &a7) == 
FAILURE) {
***************
*** 210,216 ****
        
        memset(&session, 0, sizeof(struct snmp_session));
  
!       session.peername = (*a1)->value.str.val;
        session.version = SNMP_VERSION_1;
        /*
        * FIXME: potential memory leak
--- 213,226 ----
        
        memset(&session, 0, sizeof(struct snmp_session));
  
!       strcpy (hostname, (*a1)->value.str.val);
!       if ((pptr = strchr (hostname, ':'))) {
!               remote_port = strtol (pptr + 1, NULL, 0);
!               *pptr = 0;
!       }
! 
!       session.peername = hostname;
!       session.remote_port = remote_port;
        session.version = SNMP_VERSION_1;
        /*
        * FIXME: potential memory leak


Previous Comments:
---------------------------------------------------------------------------

[2001-02-22 08:39:46] [EMAIL PROTECTED]
According to the source in snmp.c, it looks like it's impossible to use an snmp* 
function on a non standard remote port (other that 161).

For that, the session structure passed to snmp_open needs to have its remote_port 
field filled.

Maybe it could be possible to add a new argument to the snmp functions, or handle 
something like "hostname:port" in the hostname field ?

---------------------------------------------------------------------------


Full Bug description available at: http://bugs.php.net/?id=9401


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to