diff options
| author | Rasmus Lerdorf <rasmus@php.net> | 2001-07-13 05:09:40 +0000 |
|---|---|---|
| committer | Rasmus Lerdorf <rasmus@php.net> | 2001-07-13 05:09:40 +0000 |
| commit | 60c8e4409f95de35c14745528c2c256fc57ec2ba (patch) | |
| tree | da13a3e0126b79b810299978c1d20601327e49fa /ext | |
| parent | 86ae8add13d95785e28fc4ccab022c9469796fda (diff) | |
| download | php-git-60c8e4409f95de35c14745528c2c256fc57ec2ba.tar.gz | |
Add port support to snmp functions
@ - Add hostname:port support to snmp functions
@ (nbougues@axialys.net, Rasmus)
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/snmp/snmp.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 2a59a92277..0403e30bbe 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -164,7 +164,10 @@ void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) { 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) { WRONG_PARAM_COUNT; @@ -226,7 +229,14 @@ void php_snmp(INTERNAL_FUNCTION_PARAMETERS, int st) { memset(&session, 0, sizeof(struct snmp_session)); - session.peername = (*a1)->value.str.val; + 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 |
