php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9401 Unable to set remote SNMP port
Submitted: 2001-02-22 08:39 UTC Modified: 2001-07-13 01:04 UTC
From: nbougues at axialys dot net Assigned:
Status: Closed Package: SNMP related
PHP Version: 4.0.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nbougues at axialys dot net
New email:
PHP Version: OS:

 

 [2001-02-22 08:39 UTC] nbougues at axialys dot net
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 ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-22 11:06 UTC] nbougues at axialys dot net
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

 [2001-07-13 01:04 UTC] rasmus@php.net
Looks ok, implemented.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC