On Mon, Sep 13, 2004 at 10:32:11PM -0400, Robert Story wrote:
>
> Please note for the future, that you really should submit patches to the
> sourceforge tracker, so it doesn't get lost. Actually, in this case, I probably
> would have submitted a bug report and attached the patch to that.
>
> Patches on the lists are often overlooked, with the assumption that 'someone
> else will look at it'. After a while, newer mail scrolls the message of the
> screen, never to be seen again. However, we all check the trackers once in a
> while, usually before a release.
>
Yes - I should start putting patches in the tracker but the problem is that the
once in a while is so infrequent that it feels hopeless to put them there.
First nothing happens for a mounth and then the patch is rejected.
Oh yes, attached is the following patches:
patch.ws.1
Change indentation in snmpUnixDomain.c from 4-wide tabs to spaces P #1031046
patch.register_many
Support registration of multiple leaf nodes P #1009799
patch.junkoutput
Save all junkoutputfiles - great for debugging test failures
patch.SKIPIF
Check for modules in agent_module_config.h as well
patch.agentx_test_skip
Depends on patch.SKIPIF
Makes the agentx testcases run if netsnmp is configured with "agentx/master
agentx/subagent" as opposed to "agentx"
patch.agentx_length
Makes the agentx subsystem cache partial messages that are less than 20 bytes
as well
patch.T115
Depends on patch.SKIPIF
Testcase for patch.register_many and patch.agentx_short_msg
Adds the testing level in the build tree to the PATH for tests
Builds binaries at that level
Adds a testcase
-*- NOT FINISHED - DO NOT APPLY -*-
It shuld probably be implemented in terms of netsnmp_transport but I have not
got around to do that yet.
Also I think I should redo how the test subagent is started to make it more
consistent.
(T114 is a silly testcase I used to understand how to write testcases, thus
T115 for this one)
Index: snmplib/snmpUnixDomain.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/snmplib/snmpUnixDomain.c,v
retrieving revision 5.15
diff -u -r5.15 snmpUnixDomain.c
--- snmplib/snmpUnixDomain.c 17 Aug 2004 08:51:03 -0000 5.15
+++ snmplib/snmpUnixDomain.c 20 Sep 2004 06:05:29 -0000
@@ -41,7 +41,7 @@
#ifndef SUN_LEN
/*
- * Evaluate to actual length of the `sockaddr_un' structure.
+ * Evaluate to actual length of the `sockaddr_un' structure.
*/
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
+ strlen ((ptr)->sun_path))
@@ -52,7 +52,7 @@
/*
- * This is the structure we use to hold transport-specific data.
+ * This is the structure we use to hold transport-specific data.
*/
typedef struct _sockaddr_un_pair {
@@ -64,7 +64,7 @@
/*
* Return a string representing the address in data, or else the "far end"
- * address if data is NULL.
+ * address if data is NULL.
*/
static char *
@@ -103,9 +103,9 @@
/*
- * You can write something into opaque that will subsequently get passed back
+ * You can write something into opaque that will subsequently get passed back
* to your send function if you like. For instance, you might want to
- * remember where a PDU came from, so that you can send a reply there...
+ * remember where a PDU came from, so that you can send a reply there...
*/
static int
@@ -125,24 +125,24 @@
return -1;
} else {
memset(to, 0, tolen);
- }
- if(getsockname(t->sock, to, &tolen) != 0){
- free(to);
+ }
+ if(getsockname(t->sock, to, &tolen) != 0){
+ free(to);
*opaque = NULL;
*olength = 0;
- return -1;
- };
- while (rc < 0) {
- rc = recv(t->sock, buf, size, 0);
- if (rc < 0 && errno != EINTR) {
- DEBUGMSGTL(("netsnmp_unix", "recv fd %d err %d (\"%s\")\n",
- t->sock, errno, strerror(errno)));
- return rc;
- }
- *opaque = (void*)to;
- *olength = sizeof(struct sockaddr_un);
- }
- DEBUGMSGTL(("netsnmp_unix", "recv fd %d got %d bytes\n", t->sock, rc));
+ return -1;
+ };
+ while (rc < 0) {
+ rc = recv(t->sock, buf, size, 0);
+ if (rc < 0 && errno != EINTR) {
+ DEBUGMSGTL(("netsnmp_unix", "recv fd %d err %d (\"%s\")\n",
+ t->sock, errno, strerror(errno)));
+ return rc;
+ }
+ *opaque = (void*)to;
+ *olength = sizeof(struct sockaddr_un);
+ }
+ DEBUGMSGTL(("netsnmp_unix", "recv fd %d got %d bytes\n", t->sock, rc));
}
return rc;
}
@@ -158,12 +158,12 @@
if (t != NULL && t->sock >= 0) {
DEBUGMSGTL(("netsnmp_unix", "send %d bytes to %p on fd %d\n",
size, buf, t->sock));
- while (rc < 0) {
- rc = send(t->sock, buf, size, 0);
- if (rc < 0 && errno != EINTR) {
- break;
- }
- }
+ while (rc < 0) {
+ rc = send(t->sock, buf, size, 0);
+ if (rc < 0 && errno != EINTR) {
+ break;
+ }
+ }
}
return rc;
}
@@ -213,7 +213,7 @@
if (farend == NULL) {
/*
- * Indicate that the acceptance of this socket failed.
+ * Indicate that the acceptance of this socket failed.
*/
DEBUGMSGTL(("netsnmp_unix", "accept: malloc failed\n"));
return -1;
@@ -225,7 +225,7 @@
if (newsock < 0) {
DEBUGMSGTL(("netsnmp_unix","accept failed rc %d errno %d \"%s\"\n",
- newsock, errno, strerror(errno)));
+ newsock, errno, strerror(errno)));
free(farend);
return newsock;
}
@@ -235,7 +235,7 @@
}
DEBUGMSGTL(("netsnmp_unix", "accept succeeded (farend %p len %d)\n",
- farend, farendlen));
+ farend, farendlen));
t->data = farend;
t->data_length = sizeof(struct sockaddr_un);
return newsock;
@@ -248,10 +248,10 @@
/*
- * Open a Unix-domain transport for SNMP. Local is TRUE if addr is the local
- * address to bind to (i.e. this is a server-type session); otherwise addr is
+ * Open a Unix-domain transport for SNMP. Local is TRUE if addr is the local
+ * address to bind to (i.e. this is a server-type session); otherwise addr is
* the remote address to send things to (and we make up a temporary name for
- * the local end of the connection).
+ * the local end of the connection).
*/
netsnmp_transport *
@@ -271,8 +271,8 @@
return NULL;
}
- string = netsnmp_unix_fmtaddr(NULL, (void *)addr,
- sizeof(struct sockaddr_un));
+ string = netsnmp_unix_fmtaddr(NULL, (void *)addr,
+ sizeof(struct sockaddr_un));
DEBUGMSGTL(("netsnmp_unix", "open %s %s\n", local ? "local" : "remote",
string));
free(string);
@@ -311,7 +311,7 @@
/*
* This session is inteneded as a server, so we must bind to the given
- * path (unlinking it first, to avoid errors).
+ * path (unlinking it first, to avoid errors).
*/
t->flags |= NETSNMP_TRANSPORT_FLAG_LISTEN;
@@ -337,7 +337,7 @@
sup->local = 1;
/*
- * Now sit here and listen for connections to arrive.
+ * Now sit here and listen for connections to arrive.
*/
rc = listen(t->sock, NETSNMP_STREAM_QUEUE_LEN);
@@ -371,7 +371,7 @@
/*
* Save the remote address in the transport-specific data pointer for
- * later use by netsnmp_unix_send.
+ * later use by netsnmp_unix_send.
*/
sup->server.sun_family = AF_UNIX;
@@ -381,7 +381,7 @@
/*
* Message size is not limited by this transport (hence msgMaxSize
- * is equal to the maximum legal size of an SNMP message).
+ * is equal to the maximum legal size of an SNMP message).
*/
t->msgMaxSize = 0x7fffffff;
@@ -480,7 +480,7 @@
/*
* Special case if there are NO entries (as opposed to no MATCHING
- * entries).
+ * entries).
*/
if (com2SecUnixList == NULL) {
@@ -490,36 +490,35 @@
/*
* If there is no unix socket path, then there can be no valid security
- * name.
+ * name.
*/
-
+
if (opaque == NULL || olength != sizeof(struct sockaddr_un) ||
to->sun_family != AF_UNIX) {
DEBUGMSGTL(("netsnmp_unix_getSecName",
- "no unix destine address in PDU?\n"));
+ "no unix destine address in PDU?\n"));
return 1;
}
DEBUGIF("netsnmp_unix_getSecName") {
- ztcommunity = (char *)malloc(community_len + 1);
- if (ztcommunity != NULL) {
- memcpy(ztcommunity, community, community_len);
- ztcommunity[community_len] = '\0';
- }
-
- DEBUGMSGTL(("netsnmp_unix_getSecName", "resolve <\"%s\">\n",
- ztcommunity ? ztcommunity : "<malloc error>"
- ));
+ ztcommunity = (char *)malloc(community_len + 1);
+ if (ztcommunity != NULL) {
+ memcpy(ztcommunity, community, community_len);
+ ztcommunity[community_len] = '\0';
+ }
+
+ DEBUGMSGTL(("netsnmp_unix_getSecName", "resolve <\"%s\">\n",
+ ztcommunity ? ztcommunity : "<malloc error>"));
}
for (c = com2SecUnixList; c != NULL; c = c->next) {
DEBUGMSGTL(("netsnmp_unix_getSecName","compare <\"%s\",to socket %s>",
- c->community, c->sockpath ));
+ c->community, c->sockpath ));
if ((community_len == strlen(c->community)) &&
- (memcmp(community, c->community, community_len) == 0) &&
+ (memcmp(community, c->community, community_len) == 0) &&
/* compare sockpath, if pathlen == 0, always match */
(strlen(to->sun_path) == c->pathlen || c->pathlen == 0) &&
- (memcmp(to->sun_path, c->sockpath, c->pathlen) == 0)
+ (memcmp(to->sun_path, c->sockpath, c->pathlen) == 0)
) {
DEBUGMSG(("netsnmp_unix_getSecName", "... SUCCESS\n"));
if (secName != NULL) {
@@ -539,10 +538,10 @@
void
netsnmp_unix_parse_security(const char *token, char *param)
{
- char secName[VACMSTRINGLEN + 1], community[VACMSTRINGLEN + 1];
- char contextName[VACMSTRINGLEN + 1];
- char sockpath[sizeof(struct sockaddr_un) + 1];
- com2SecUnixEntry *e = NULL;
+ char secName[VACMSTRINGLEN + 1], community[VACMSTRINGLEN + 1];
+ char contextName[VACMSTRINGLEN + 1];
+ char sockpath[sizeof(struct sockaddr_un) + 1];
+ com2SecUnixEntry *e = NULL;
param = copy_nword(param, secName, VACMSTRINGLEN);
@@ -564,7 +563,7 @@
return;
}
- param = copy_nword(param, sockpath, sizeof(struct sockaddr_un) - 1);
+ param = copy_nword(param, sockpath, sizeof(struct sockaddr_un) - 1);
if (sockpath[0] == '\0') {
config_perror("missing SOCKPATH parameter");
return;
@@ -572,19 +571,18 @@
config_perror("sockpath too long");
return;
}
- /* if sockpath == "default", set pathlen=0*/
- if(strcmp(sockpath, "default") == 0){
- sockpath[0] = 0;
- }
-
- param = copy_nword(param, community, VACMSTRINGLEN);
+ /* if sockpath == "default", set pathlen=0*/
+ if(strcmp(sockpath, "default") == 0){
+ sockpath[0] = 0;
+ }
+
+ param = copy_nword(param, community, VACMSTRINGLEN);
if (community[0] == '\0') {
config_perror("missing COMMUNITY parameter\n");
return;
- } else
- if (strncmp
- (community, EXAMPLE_COMMUNITY, strlen(EXAMPLE_COMMUNITY))
- == 0) {
+ } else if (strncmp
+ (community, EXAMPLE_COMMUNITY, strlen(EXAMPLE_COMMUNITY))
+ == 0) {
config_perror("example config COMMUNITY not properly configured");
return;
} else if (strlen(community) > (VACMSTRINGLEN - 1)) {
@@ -605,7 +603,7 @@
strcpy(e->contextName, contextName);
strcpy(e->community, community);
strcpy(e->sockpath, sockpath);
- e->pathlen = strlen(sockpath);
+ e->pathlen = strlen(sockpath);
e->next = NULL;
if (com2SecUnixListLast != NULL) {
@@ -638,5 +636,3 @@
"[-Cn CONTEXT] secName sockpath community");
#endif /* support for community based SNMP */
}
-
-
Index: agent/agent_registry.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/agent_registry.c,v
retrieving revision 5.20
diff -c -r5.20 agent_registry.c
*** agent/agent_registry.c 2 Aug 2004 21:17:37 -0000 5.20
--- agent/agent_registry.c 15 Aug 2004 21:03:25 -0000
***************
*** 636,641 ****
--- 636,643 ----
sub2->name_a[range_subid - 1] = i;
sub2->start_a[range_subid - 1] = i;
sub2->end_a[range_subid - 1] = i; /* XXX - ???? */
+ if (range_subid == mibloclen)
+ ++sub2->end_a[range_subid - 1];
res = netsnmp_subtree_load(sub2, context);
sub2->flags |= SUBTREE_ATTACHED;
if (res != MIB_REGISTERED_OK) {
Index: testing/eval_tools.sh
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/eval_tools.sh,v
retrieving revision 5.22
diff -u -r5.22 eval_tools.sh
--- testing/eval_tools.sh 13 Sep 2004 10:34:04 -0000 5.22
+++ testing/eval_tools.sh 16 Sep 2004 19:47:11 -0000
@@ -179,6 +179,15 @@
KNORG
fi
+
+ if [ -f "$junkoutputfile" ] ; then
+ let x=1
+ while [ -f "${junkoutputfile}.${x}" ]; do
+ let x=x+1
+ done
+ mv "$junkoutputfile" "${junkoutputfile}.${x}"
+ fi
+
( $* 2>&1 ) > $junkoutputfile 2>&1
RC=$?
Index: testing/eval_tools.sh
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/eval_tools.sh,v
retrieving revision 5.22
diff -u -r5.22 eval_tools.sh
--- testing/eval_tools.sh 13 Sep 2004 10:34:04 -0000 5.22
+++ testing/eval_tools.sh 28 Sep 2004 04:21:33 -0000
@@ -106,7 +106,7 @@
#------------------------------------ -o-
#
SKIPIFNOT() {
- grep "^#define $1 " $SNMP_UPDIR/include/net-snmp/net-snmp-config.h
$SNMP_UPDIR/include/net-snmp/agent/mib_module_config.h > /dev/null
+ grep "^#define $1 " $SNMP_UPDIR/include/net-snmp/net-snmp-config.h
$SNMP_UPDIR/include/net-snmp/agent/mib_module_config.h
$SNMP_UPDIR/include/net-snmp/agent/agent_module_config.h > /dev/null
if [ $? != 0 ]; then
REMOVETESTDATA
echo "SKIPPED"
@@ -115,7 +115,7 @@
}
SKIPIF() {
- grep "^#define $1 " $SNMP_UPDIR/include/net-snmp/net-snmp-config.h
$SNMP_UPDIR/include/net-snmp/agent/mib_module_config.h > /dev/null
+ grep "^#define $1 " $SNMP_UPDIR/include/net-snmp/net-snmp-config.h
$SNMP_UPDIR/include/net-snmp/agent/mib_module_config.h
$SNMP_UPDIR/include/net-snmp/agent/agent_module_config.h > /dev/null
if [ $? = 0 ]; then
REMOVETESTDATA
echo "SKIPPED"
Index: testing/tests/T110agentxget
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/tests/T110agentxget,v
retrieving revision 5.3
diff -u -r5.3 T110agentxget
--- testing/tests/T110agentxget 21 Apr 2004 00:28:09 -0000 5.3
+++ testing/tests/T110agentxget 28 Sep 2004 04:21:34 -0000
@@ -4,7 +4,8 @@
HEADER AgentX GET support
-SKIPIFNOT USING_AGENTX_MODULE
+SKIPIFNOT USING_AGENTX_MASTER_MODULE
+SKIPIFNOT USING_AGENTX_SUBAGENT_MODULE
SKIPIFNOT USING_MIBII_SYSTEM_MIB_MODULE
#
Index: testing/tests/T111agentxset
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/tests/T111agentxset,v
retrieving revision 5.3
diff -u -r5.3 T111agentxset
--- testing/tests/T111agentxset 21 Apr 2004 00:28:09 -0000 5.3
+++ testing/tests/T111agentxset 28 Sep 2004 04:21:34 -0000
@@ -4,7 +4,8 @@
HEADER AgentX SET support
-SKIPIFNOT USING_AGENTX_MODULE
+SKIPIFNOT USING_AGENTX_MASTER_MODULE
+SKIPIFNOT USING_AGENTX_SUBAGENT_MODULE
SKIPIFNOT USING_MIBII_SYSTEM_MIB_MODULE
#
Index: testing/tests/T112agentxsetfail
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/tests/T112agentxsetfail,v
retrieving revision 5.3
diff -u -r5.3 T112agentxsetfail
--- testing/tests/T112agentxsetfail 21 Apr 2004 00:28:09 -0000 5.3
+++ testing/tests/T112agentxsetfail 28 Sep 2004 04:21:34 -0000
@@ -4,7 +4,8 @@
HEADER AgentX illegal SET handling support
-SKIPIFNOT USING_AGENTX_MODULE
+SKIPIFNOT USING_AGENTX_MASTER_MODULE
+SKIPIFNOT USING_AGENTX_SUBAGENT_MODULE
SKIPIFNOT USING_MIBII_SYSTEM_MIB_MODULE
#
Index: testing/tests/T113agentxtrap
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/tests/T113agentxtrap,v
retrieving revision 5.3
diff -u -r5.3 T113agentxtrap
--- testing/tests/T113agentxtrap 21 Apr 2004 00:28:09 -0000 5.3
+++ testing/tests/T113agentxtrap 28 Sep 2004 04:21:34 -0000
@@ -4,7 +4,8 @@
HEADER AgentX trap sending support
-SKIPIFNOT USING_AGENTX_MODULE
+SKIPIFNOT USING_AGENTX_MASTER_MODULE
+SKIPIFNOT USING_AGENTX_SUBAGENT_MODULE
SKIPIFNOT USING_EXAMPLES_EXAMPLE_MODULE
#
Index: agent/mibgroup/agentx/protocol.c
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/agent/mibgroup/agentx/protocol.c,v
retrieving revision 5.4
diff -u -r5.4 protocol.c
--- agent/mibgroup/agentx/protocol.c 9 Mar 2004 19:34:24 -0000 5.4
+++ agent/mibgroup/agentx/protocol.c 16 Sep 2004 19:46:50 -0000
@@ -2049,7 +2049,7 @@
{
if (packet_len < 20)
- return 0; /* minimum header length == 20 */
+ return 20; /* minimum header length == 20 */
return agentx_parse_int(packet + 16,
*(packet +
Index: testing/Makefile.in
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/Makefile.in,v
retrieving revision 5.3
diff -u -r5.3 Makefile.in
--- testing/Makefile.in 2 Apr 2004 02:37:18 -0000 5.3
+++ testing/Makefile.in 28 Sep 2004 04:33:13 -0000
@@ -11,6 +11,7 @@
@NON_GNU_VPATH@ $(srcdir)
#TARG = etest ktest misctest stest
+TOOLS = T115
USELIBS = ../snmplib/libsnmp.$(LIB_EXTENSION)$(LIB_VERSION)
LIBS = -L../snmplib $(CC_RUNTIME_ARG) -lsnmp @LIBS@
@@ -22,9 +23,11 @@
all: $(TARG)
-test:
+test: tools
$(srcdir)/RUNTESTS -a -D `pwd`/.. $(TESTOPTS)
+tools: $(TOOLS)
+
etest: etimetest.o $(PARSEOBJS) $(USELIBS)
${CC} -o $@ etimetest.o $(PARSEOBJS) ${LDFLAGS} ${LIBS}
Index: testing/RUNTESTS
===================================================================
RCS file: /cvsroot/net-snmp/net-snmp/testing/RUNTESTS,v
retrieving revision 5.12
diff -u -r5.12 RUNTESTS
--- testing/RUNTESTS 24 Aug 2004 16:24:44 -0000 5.12
+++ testing/RUNTESTS 28 Sep 2004 04:33:13 -0000
@@ -174,6 +174,13 @@
break
fi
done
+for dd in testing; do
+ bf=$dd/T115
+ if [ -x "$bf" ] ; then
+ PATH=$SNMP_UPDIR/$dd:$PATH
+ break
+ fi
+done
bf=include/net-snmp/net-snmp-config.h
if [ ! -s "$bf" ] ; then
Index: testing/T115.c
===================================================================
RCS file: testing/T115.c
diff -N testing/T115.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testing/T115.c 28 Sep 2004 04:33:13 -0000
@@ -0,0 +1,157 @@
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+
+void dump(const char* buf, int n)
+{
+ int i;
+ if(n < 0) {
+ printf("ERROR: %d [%s]\n", errno, strerror(errno));
+ return;
+ }
+ while(n > 16) {
+ printf("%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x
%02x %02x %02x"
+ " %c%c%c%c%c%c%c%c %c%c%c%c%c%c%c%c\n",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7],
+ buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15],
+ isgraph(buf[0]) ? buf[0] : '.', isgraph(buf[1]) ? buf[1] : '.',
+ isgraph(buf[2]) ? buf[2] : '.', isgraph(buf[3]) ? buf[3] : '.',
+ isgraph(buf[4]) ? buf[4] : '.', isgraph(buf[5]) ? buf[5] : '.',
+ isgraph(buf[6]) ? buf[6] : '.', isgraph(buf[7]) ? buf[7] : '.',
+ isgraph(buf[8]) ? buf[8] : '.', isgraph(buf[9]) ? buf[9] : '.',
+ isgraph(buf[10]) ? buf[10] : '.', isgraph(buf[11]) ? buf[11] : '.',
+ isgraph(buf[12]) ? buf[12] : '.', isgraph(buf[13]) ? buf[13] : '.',
+ isgraph(buf[14]) ? buf[14] : '.', isgraph(buf[15]) ? buf[15] : '.');
+ buf += 16;
+ n -= 16;
+ }
+ if(n > 8) {
+ printf("%02x %02x %02x %02x %02x %02x %02x %02x - ",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]);
+ i = 8;
+ } else
+ i = 0;
+ while(i < n) {
+ printf("%02x ", buf[i]);
+ ++i;
+ }
+ printf("%*s", 3 * ((16 - n) + (n <= 8)), "");
+
+ if(n > 8) {
+ printf(" %c%c%c%c%c%c%c%c",
+ isgraph(buf[0]) ? buf[0] : '.', isgraph(buf[1]) ? buf[1] : '.',
+ isgraph(buf[2]) ? buf[2] : '.', isgraph(buf[3]) ? buf[3] : '.',
+ isgraph(buf[4]) ? buf[4] : '.', isgraph(buf[5]) ? buf[5] : '.',
+ isgraph(buf[6]) ? buf[6] : '.', isgraph(buf[7]) ? buf[7] : '.');
+ i = 8;
+ } else
+ i = 0;
+ printf(" ");
+ while(i < n) {
+ printf("%c", isgraph(buf[i]) ? buf[i] : '.');
+ ++i;
+ }
+ printf("\n");
+}
+
+int main(int argc, char* argv[])
+{
+ char buf[256];
+ int fd;
+ struct sockaddr_un sa;
+
+ sa.sun_family = AF_UNIX;
+ if(argc > 1)
+ strcpy(sa.sun_path, argv[1]);
+ else
+ strcpy(sa.sun_path, "/var/master/agentx");
+
+ fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if(fd < 0) {
+ perror("ex: failed to open socket\n");
+ return 1;
+ }
+
+ if(connect(fd, (struct sockaddr*)&sa, SUN_LEN(&sa)) < 0) {
+ perror("ex: failed to connect\n");
+ return 1;
+ }
+
+ /* Open-PDU */
+ if(write(fd,
+ "\1\1\20\0"
+ "\0\0\0\0"
+ "\0\0\0\0"
+ "\0\0\0\0"
+ "\0\0\0\14"
+ "\0\0\0\0"
+ "\0\0\0\0"
+ "\0\0\0\0", 32) < 32) {
+ perror("write");
+ return 1;
+ }
+
+ /* Response-PDU */
+ printf("OPEN-RESPONSE:\n");
+ dump(buf, read(fd, buf, 256));
+
+ /* Register-PDU */
+ if(write(fd,
+ "\1\3\21\0", 4) < 4) {
+ perror("write");
+ return 1;
+ }
+ if(write(fd,
+ buf + 4, 4) < 4) {
+ perror("write");
+ return 1;
+ }
+ if(write(fd,
+ "\0\0\0\0"
+ "\0\0\0\1"
+ "\0\0\0\20"
+ "\0\177\6\0"
+ "\1\3\0\0"
+ "\0\0\0\4"
+ "\0\0\0\6", 28) < 28) {
+ perror("write");
+ return 1;
+ }
+
+ printf("REGISTER-RESPONSE:\n");
+ dump(buf, read(fd, buf, 256));
+
+ /* Block to avoid dying... */
+ {
+ fd_set rfd;
+ struct timeval tv;
+ int i;
+ tv.tv_sec = 5;
+ tv.tv_usec = 0;
+ FD_ZERO(&rfd);
+ FD_SET(fd, &rfd);
+ i = select(fd + 1, &rfd, NULL, NULL, &tv);
+ if(i > 0) {
+ i = read(fd, buf, 256);
+ printf("WRITE\n");
+ dump(buf, i);
+ } else if(i == 0)
+ printf("TIMEOUT\n");
+ else {
+ perror("select");
+ return 1;
+ }
+ }
+
+ /* Terminate */
+ close(fd);
+ return 0;
+}
Index: testing/tests/T115agentxreg
===================================================================
RCS file: testing/tests/T115agentxreg
diff -N testing/tests/T115agentxreg
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testing/tests/T115agentxreg 28 Sep 2004 04:33:15 -0000
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. ../eval_tools.sh
+
+HEADER AgentX registration support
+
+SKIPIFNOT USING_AGENTX_MASTER_MODULE
+
+#
+# Begin test
+#
+
+# standard V3 configuration for initial user
+. ./Sv2cconfig
+
+AGENT_FLAGS="$AGENT_FLAGS -x $SNMP_TMPDIR/agentx_socket"
+STARTAGENT
+
+CAPTURE "ex2 $SNMP_TMPDIR/agentx_socket" &
+snmpget -On -t 3 -r 0 -c testcommunity -v 2c $SNMP_FLAGS $AUTHTESTARGS
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.3.3 > /dev/null 2>&1
+wait
+CHECK "TIMEOUT"
+
+CAPTURE "ex2 $SNMP_TMPDIR/agentx_socket" &
+snmpget -On -t 3 -r 0 -c testcommunity -v 2c $SNMP_FLAGS $AUTHTESTARGS
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.3.4 > /dev/null 2>&1
+wait
+CHECK "WRITE"
+
+CAPTURE "ex2 $SNMP_TMPDIR/agentx_socket"
+snmpget -On -t 3 -r 0 -c testcommunity -v 2c $SNMP_FLAGS $AUTHTESTARGS
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.3.5 > /dev/null 2>&1
+wait
+CHECK "WRITE"
+
+CAPTURE "ex2 $SNMP_TMPDIR/agentx_socket"
+snmpget -On -t 3 -r 0 -c testcommunity -v 2c $SNMP_FLAGS $AUTHTESTARGS
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.3.6 > /dev/null 2>&1
+wait
+CHECK "WRITE"
+
+CAPTURE "ex2 $SNMP_TMPDIR/agentx_socket"
+snmpget -On -t 3 -r 0 -c testcommunity -v 2c $SNMP_FLAGS $AUTHTESTARGS
$SNMP_TRANSPORT_SPEC:$SNMP_TEST_DEST$SNMP_SNMPD_PORT .1.3.6.1.3.7 > /dev/null 2>&1
+wait
+CHECK "TIMEOUT"
+
+# stop the master agent
+STOPAGENT
+
+# all done (whew)
+FINISHED