xref: /openbsd-src/regress/usr.sbin/snmpd/backend.c (revision 1434a006ead141f4a995b7fb3ab86f1b270b3ccc)
184417368Smartijn #include <sys/socket.h>
284417368Smartijn #include <sys/time.h>
384417368Smartijn 
4*1434a006Smartijn #include <ber.h>
584417368Smartijn #include <err.h>
684417368Smartijn #include <stdint.h>
784417368Smartijn #include <stdlib.h>
884417368Smartijn #include <string.h>
984417368Smartijn #include <time.h>
1084417368Smartijn #include <unistd.h>
1184417368Smartijn 
1284417368Smartijn #include "regress.h"
1384417368Smartijn 
1484417368Smartijn #define MIB_BACKEND_GET MIB_BACKEND, 1
1584417368Smartijn #define MIB_BACKEND_GETNEXT MIB_BACKEND, 2
1684417368Smartijn #define MIB_BACKEND_GETBULK MIB_BACKEND, 3
1784417368Smartijn #define MIB_BACKEND_ERROR MIB_BACKEND, 4
1884417368Smartijn 
1984417368Smartijn #define MIB_SUBAGENT_BACKEND_GET MIB_SUBAGENT_BACKEND, 1
2084417368Smartijn #define MIB_SUBAGENT_BACKEND_GETNEXT MIB_SUBAGENT_BACKEND, 2
2184417368Smartijn #define MIB_SUBAGENT_BACKEND_GETBULK MIB_SUBAGENT_BACKEND, 3
2284417368Smartijn #define MIB_SUBAGENT_BACKEND_ERROR MIB_SUBAGENT_BACKEND, 4
2384417368Smartijn 
2484417368Smartijn #define nitems(_a)     (sizeof((_a)) / sizeof((_a)[0]))
2584417368Smartijn 
2684417368Smartijn void
backend_get_integer(void)2784417368Smartijn backend_get_integer(void)
2884417368Smartijn {
2984417368Smartijn 	struct sockaddr_storage ss;
3084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
3184417368Smartijn 	socklen_t salen;
3284417368Smartijn 	int snmp_s, ax_s;
3384417368Smartijn 	uint32_t sessionid;
3484417368Smartijn 	struct varbind varbind = {
3584417368Smartijn 		.type = TYPE_NULL,
3684417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 1, 0),
3784417368Smartijn 		.data.int32 = 1
3884417368Smartijn 	};
3984417368Smartijn 	int32_t requestid;
4084417368Smartijn 	char buf[1024];
4184417368Smartijn 	size_t n;
4284417368Smartijn 
4384417368Smartijn 	ax_s = agentx_connect(axsocket);
4484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
4584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 1), __func__);
4684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
4784417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 1), 0);
4884417368Smartijn 
4984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
5084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
5184417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
5284417368Smartijn 
5384417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
5484417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
5584417368Smartijn 
5684417368Smartijn 	varbind.type = TYPE_INTEGER;
5784417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
5884417368Smartijn 
5984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
6084417368Smartijn 	    &varbind, 1);
6184417368Smartijn }
6284417368Smartijn 
6384417368Smartijn void
backend_get_octetstring(void)6484417368Smartijn backend_get_octetstring(void)
6584417368Smartijn {
6684417368Smartijn 	struct sockaddr_storage ss;
6784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
6884417368Smartijn 	socklen_t salen;
6984417368Smartijn 	int snmp_s, ax_s;
7084417368Smartijn 	uint32_t sessionid;
7184417368Smartijn 	struct varbind varbind = {
7284417368Smartijn 		.type = TYPE_NULL,
7384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 2, 0),
7484417368Smartijn 		.data.octetstring.string = "test",
7584417368Smartijn 		.data.octetstring.len = 4
7684417368Smartijn 	};
7784417368Smartijn 	int32_t requestid;
7884417368Smartijn 	char buf[1024];
7984417368Smartijn 	size_t n;
8084417368Smartijn 
8184417368Smartijn 	ax_s = agentx_connect(axsocket);
8284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
8384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 2), __func__);
8484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
8584417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 2), 0);
8684417368Smartijn 
8784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
8884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
8984417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
9084417368Smartijn 
9184417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
9284417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
9384417368Smartijn 
9484417368Smartijn 	varbind.type = TYPE_OCTETSTRING;
9584417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
9684417368Smartijn 
9784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
9884417368Smartijn 	    &varbind, 1);
9984417368Smartijn }
10084417368Smartijn 
10184417368Smartijn void
backend_get_objectidentifier(void)10284417368Smartijn backend_get_objectidentifier(void)
10384417368Smartijn {
10484417368Smartijn 	struct sockaddr_storage ss;
10584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
10684417368Smartijn 	socklen_t salen;
10784417368Smartijn 	int snmp_s, ax_s;
10884417368Smartijn 	uint32_t sessionid;
10984417368Smartijn 	struct varbind varbind = {
11084417368Smartijn 		.type = TYPE_NULL,
11184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 3, 0),
11284417368Smartijn 		.data.oid = OID_STRUCT(MIB_BACKEND_GET, 3, 0),
11384417368Smartijn 	};
11484417368Smartijn 	int32_t requestid;
11584417368Smartijn 	char buf[1024];
11684417368Smartijn 	size_t n;
11784417368Smartijn 
11884417368Smartijn 	ax_s = agentx_connect(axsocket);
11984417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
12084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 3), __func__);
12184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
12284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 3), 0);
12384417368Smartijn 
12484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
12584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
12684417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
12784417368Smartijn 
12884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
12984417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
13084417368Smartijn 
13184417368Smartijn 	varbind.type = TYPE_OBJECTIDENTIFIER;
13284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
13384417368Smartijn 
13484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
13584417368Smartijn 	    &varbind, 1);
13684417368Smartijn }
13784417368Smartijn 
13884417368Smartijn void
backend_get_ipaddress(void)13984417368Smartijn backend_get_ipaddress(void)
14084417368Smartijn {
14184417368Smartijn 	struct sockaddr_storage ss;
14284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
14384417368Smartijn 	socklen_t salen;
14484417368Smartijn 	int snmp_s, ax_s;
14584417368Smartijn 	uint32_t sessionid;
14684417368Smartijn 	struct varbind varbind = {
14784417368Smartijn 		.type = TYPE_NULL,
14884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 4, 0),
14984417368Smartijn 		.data.octetstring.string = "\0\0\0\0",
15084417368Smartijn 		.data.octetstring.len = 4
15184417368Smartijn 	};
15284417368Smartijn 	int32_t requestid;
15384417368Smartijn 	char buf[1024];
15484417368Smartijn 	size_t n;
15584417368Smartijn 
15684417368Smartijn 	ax_s = agentx_connect(axsocket);
15784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
15884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 4), __func__);
15984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
16084417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 4), 0);
16184417368Smartijn 
16284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
16384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
16484417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
16584417368Smartijn 
16684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
16784417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
16884417368Smartijn 
16984417368Smartijn 	varbind.type = TYPE_IPADDRESS;
17084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
17184417368Smartijn 
17284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
17384417368Smartijn 	    &varbind, 1);
17484417368Smartijn }
17584417368Smartijn 
17684417368Smartijn void
backend_get_counter32(void)17784417368Smartijn backend_get_counter32(void)
17884417368Smartijn {
17984417368Smartijn 	struct sockaddr_storage ss;
18084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
18184417368Smartijn 	socklen_t salen;
18284417368Smartijn 	int snmp_s, ax_s;
18384417368Smartijn 	uint32_t sessionid;
18484417368Smartijn 	struct varbind varbind = {
18584417368Smartijn 		.type = TYPE_NULL,
18684417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 5, 0),
18784417368Smartijn 		.data.uint32 = 1
18884417368Smartijn 	};
18984417368Smartijn 	int32_t requestid;
19084417368Smartijn 	char buf[1024];
19184417368Smartijn 	size_t n;
19284417368Smartijn 
19384417368Smartijn 	ax_s = agentx_connect(axsocket);
19484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
19584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 5), __func__);
19684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
19784417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 5), 0);
19884417368Smartijn 
19984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
20084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
20184417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
20284417368Smartijn 
20384417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
20484417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
20584417368Smartijn 
20684417368Smartijn 	varbind.type = TYPE_COUNTER32;
20784417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
20884417368Smartijn 
20984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
21084417368Smartijn 	    &varbind, 1);
21184417368Smartijn }
21284417368Smartijn 
21384417368Smartijn void
backend_get_gauge32(void)21484417368Smartijn backend_get_gauge32(void)
21584417368Smartijn {
21684417368Smartijn 	struct sockaddr_storage ss;
21784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
21884417368Smartijn 	socklen_t salen;
21984417368Smartijn 	int snmp_s, ax_s;
22084417368Smartijn 	uint32_t sessionid;
22184417368Smartijn 	struct varbind varbind = {
22284417368Smartijn 		.type = TYPE_NULL,
22384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 6, 0),
22484417368Smartijn 		.data.uint32 = 1
22584417368Smartijn 	};
22684417368Smartijn 	int32_t requestid;
22784417368Smartijn 	char buf[1024];
22884417368Smartijn 	size_t n;
22984417368Smartijn 
23084417368Smartijn 	ax_s = agentx_connect(axsocket);
23184417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
23284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 6), __func__);
23384417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
23484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 6), 0);
23584417368Smartijn 
23684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
23784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
23884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
23984417368Smartijn 
24084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
24184417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
24284417368Smartijn 
24384417368Smartijn 	varbind.type = TYPE_GAUGE32;
24484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
24584417368Smartijn 
24684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
24784417368Smartijn 	    &varbind, 1);
24884417368Smartijn }
24984417368Smartijn 
25084417368Smartijn void
backend_get_timeticks(void)25184417368Smartijn backend_get_timeticks(void)
25284417368Smartijn {
25384417368Smartijn 	struct sockaddr_storage ss;
25484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
25584417368Smartijn 	socklen_t salen;
25684417368Smartijn 	int snmp_s, ax_s;
25784417368Smartijn 	uint32_t sessionid;
25884417368Smartijn 	struct varbind varbind = {
25984417368Smartijn 		.type = TYPE_NULL,
26084417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 7, 0),
26184417368Smartijn 		.data.uint32 = 1
26284417368Smartijn 	};
26384417368Smartijn 	int32_t requestid;
26484417368Smartijn 	char buf[1024];
26584417368Smartijn 	size_t n;
26684417368Smartijn 
26784417368Smartijn 	ax_s = agentx_connect(axsocket);
26884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
26984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 7), __func__);
27084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
27184417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 7), 0);
27284417368Smartijn 
27384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
27484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
27584417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
27684417368Smartijn 
27784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
27884417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
27984417368Smartijn 
28084417368Smartijn 	varbind.type = TYPE_TIMETICKS;
28184417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
28284417368Smartijn 
28384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
28484417368Smartijn 	    &varbind, 1);
28584417368Smartijn }
28684417368Smartijn 
28784417368Smartijn void
backend_get_opaque(void)28884417368Smartijn backend_get_opaque(void)
28984417368Smartijn {
29084417368Smartijn 	struct sockaddr_storage ss;
29184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
29284417368Smartijn 	socklen_t salen;
29384417368Smartijn 	int snmp_s, ax_s;
29484417368Smartijn 	uint32_t sessionid;
29584417368Smartijn 	struct varbind varbind = {
29684417368Smartijn 		.type = TYPE_NULL,
29784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 8, 0),
29884417368Smartijn 	};
29984417368Smartijn 	int32_t requestid;
30084417368Smartijn 	char buf[1024];
30184417368Smartijn 	size_t n;
302*1434a006Smartijn 	struct ber ber = {};
303*1434a006Smartijn 	struct ber_element *elm;
304*1434a006Smartijn 	ssize_t len;
30584417368Smartijn 
30684417368Smartijn 	ax_s = agentx_connect(axsocket);
30784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
30884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 8), __func__);
30984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
31084417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 8), 0);
31184417368Smartijn 
31284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
31384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
31484417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
31584417368Smartijn 
31684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
31784417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
31884417368Smartijn 
319*1434a006Smartijn 	if ((elm = ober_add_integer(NULL, 1)) == NULL)
320*1434a006Smartijn 		err(1, "ober_add_integer");
321*1434a006Smartijn 	if (ober_write_elements(&ber, elm) == -1)
322*1434a006Smartijn 		err(1, "ober_write_elements");
323*1434a006Smartijn 	varbind.data.octetstring.len = ober_get_writebuf(
324*1434a006Smartijn 	    &ber, (void **)&varbind.data.octetstring.string);
325*1434a006Smartijn 	ober_free_elements(elm);
326*1434a006Smartijn 
32784417368Smartijn 	varbind.type = TYPE_OPAQUE;
32884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
32984417368Smartijn 
33084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
33184417368Smartijn 	    &varbind, 1);
332*1434a006Smartijn 	ober_free(&ber);
33384417368Smartijn }
33484417368Smartijn 
33584417368Smartijn void
backend_get_counter64(void)33684417368Smartijn backend_get_counter64(void)
33784417368Smartijn {
33884417368Smartijn 	struct sockaddr_storage ss;
33984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
34084417368Smartijn 	socklen_t salen;
34184417368Smartijn 	int snmp_s, ax_s;
34284417368Smartijn 	uint32_t sessionid;
34384417368Smartijn 	struct varbind varbind = {
34484417368Smartijn 		.type = TYPE_NULL,
34584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 9, 0),
34684417368Smartijn 		.data.uint64 = 1
34784417368Smartijn 	};
34884417368Smartijn 	int32_t requestid;
34984417368Smartijn 	char buf[1024];
35084417368Smartijn 	size_t n;
35184417368Smartijn 
35284417368Smartijn 	ax_s = agentx_connect(axsocket);
35384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
35484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 9), __func__);
35584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
35684417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 9), 0);
35784417368Smartijn 
35884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
35984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
36084417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
36184417368Smartijn 
36284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
36384417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
36484417368Smartijn 
36584417368Smartijn 	varbind.type = TYPE_COUNTER64;
36684417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
36784417368Smartijn 
36884417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
36984417368Smartijn 	    &varbind, 1);
37084417368Smartijn }
37184417368Smartijn 
37284417368Smartijn void
backend_get_nosuchobject(void)37384417368Smartijn backend_get_nosuchobject(void)
37484417368Smartijn {
37584417368Smartijn 	struct sockaddr_storage ss;
37684417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
37784417368Smartijn 	socklen_t salen;
37884417368Smartijn 	int snmp_s, ax_s;
37984417368Smartijn 	uint32_t sessionid;
38084417368Smartijn 	struct varbind varbind = {
38184417368Smartijn 		.type = TYPE_NULL,
38284417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 10, 0),
38384417368Smartijn 	};
38484417368Smartijn 	int32_t requestid;
38584417368Smartijn 	char buf[1024];
38684417368Smartijn 	size_t n;
38784417368Smartijn 
38884417368Smartijn 	ax_s = agentx_connect(axsocket);
38984417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
39084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 10), __func__);
39184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
39284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 10), 0);
39384417368Smartijn 
39484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
39584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
39684417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
39784417368Smartijn 
39884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
39984417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
40084417368Smartijn 
40184417368Smartijn 	varbind.type = TYPE_NOSUCHOBJECT;
40284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
40384417368Smartijn 
40484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
40584417368Smartijn 	    &varbind, 1);
40684417368Smartijn }
40784417368Smartijn 
40884417368Smartijn void
backend_get_nosuchinstance(void)40984417368Smartijn backend_get_nosuchinstance(void)
41084417368Smartijn {
41184417368Smartijn 	struct sockaddr_storage ss;
41284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
41384417368Smartijn 	socklen_t salen;
41484417368Smartijn 	int snmp_s, ax_s;
41584417368Smartijn 	uint32_t sessionid;
41684417368Smartijn 	struct varbind varbind = {
41784417368Smartijn 		.type = TYPE_NULL,
41884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 11, 0),
41984417368Smartijn 	};
42084417368Smartijn 	int32_t requestid;
42184417368Smartijn 	char buf[1024];
42284417368Smartijn 	size_t n;
42384417368Smartijn 
42484417368Smartijn 	ax_s = agentx_connect(axsocket);
42584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
42684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 11), __func__);
42784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
42884417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 11), 0);
42984417368Smartijn 
43084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
43184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
43284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
43384417368Smartijn 
43484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
43584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
43684417368Smartijn 
43784417368Smartijn 	varbind.type = TYPE_NOSUCHINSTANCE;
43884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
43984417368Smartijn 
44084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
44184417368Smartijn 	    &varbind, 1);
44284417368Smartijn }
44384417368Smartijn 
44484417368Smartijn void
backend_get_endofmibview(void)44584417368Smartijn backend_get_endofmibview(void)
44684417368Smartijn {
44784417368Smartijn 	struct sockaddr_storage ss;
44884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
44984417368Smartijn 	socklen_t salen;
45084417368Smartijn 	int snmp_s, ax_s;
45184417368Smartijn 	uint32_t sessionid;
45284417368Smartijn 	struct varbind varbind = {
45384417368Smartijn 		.type = TYPE_NULL,
45484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 12, 0),
45584417368Smartijn 	};
45684417368Smartijn 	int32_t requestid;
45784417368Smartijn 	char buf[1024];
45884417368Smartijn 	size_t n;
45984417368Smartijn 
46084417368Smartijn 	ax_s = agentx_connect(axsocket);
46184417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
46284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 12), __func__);
46384417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
46484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 12), 0);
46584417368Smartijn 
46684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
46784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
46884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
46984417368Smartijn 
47084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
47184417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
47284417368Smartijn 
47384417368Smartijn 	varbind.type = TYPE_ENDOFMIBVIEW;
47484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
47584417368Smartijn 
47684417368Smartijn 	varbind.type = TYPE_NULL;
47784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
47884417368Smartijn 	    &varbind, 1);
47984417368Smartijn }
48084417368Smartijn 
48184417368Smartijn void
backend_get_two_single_backend(void)48284417368Smartijn backend_get_two_single_backend(void)
48384417368Smartijn {
48484417368Smartijn 	struct sockaddr_storage ss;
48584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
48684417368Smartijn 	socklen_t salen;
48784417368Smartijn 	int snmp_s, ax_s;
48884417368Smartijn 	uint32_t sessionid;
48984417368Smartijn 	struct varbind varbind[] = {
49084417368Smartijn 		{
49184417368Smartijn 			.type = TYPE_NULL,
49284417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 13, 1),
49384417368Smartijn 			.data.int32 = 1
49484417368Smartijn 		},
49584417368Smartijn 		{
49684417368Smartijn 			.type = TYPE_NULL,
49784417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 13, 2),
49884417368Smartijn 			.data.int32 = 2
49984417368Smartijn 		}
50084417368Smartijn 	};
50184417368Smartijn 	struct varbind varbind_ax[] = {
50284417368Smartijn 		{
50384417368Smartijn 			.type = TYPE_INTEGER,
50484417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 13, 1),
50584417368Smartijn 			.data.int32 = 1
50684417368Smartijn 		},
50784417368Smartijn 		{
50884417368Smartijn 			.type = TYPE_INTEGER,
50984417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 13, 2),
51084417368Smartijn 			.data.int32 = 2
51184417368Smartijn 		}
51284417368Smartijn 	};
51384417368Smartijn 	int32_t requestid;
51484417368Smartijn 	char buf[1024];
51584417368Smartijn 	size_t n;
51684417368Smartijn 
51784417368Smartijn 	ax_s = agentx_connect(axsocket);
51884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
51984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 13), __func__);
52084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
52184417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 13), 0);
52284417368Smartijn 
52384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
52484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
52584417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, varbind, 2);
52684417368Smartijn 
52784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
52884417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, varbind_ax, 2);
52984417368Smartijn 
53084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind_ax, 2);
53184417368Smartijn 
53284417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
53384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
53484417368Smartijn 	    varbind, 2);
53584417368Smartijn }
53684417368Smartijn 
53784417368Smartijn void
backend_get_two_double_backend(void)53884417368Smartijn backend_get_two_double_backend(void)
53984417368Smartijn {
54084417368Smartijn 	struct sockaddr_storage ss;
54184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
54284417368Smartijn 	socklen_t salen;
54384417368Smartijn 	int snmp_s, ax_s1, ax_s2;
54484417368Smartijn 	uint32_t sessionid1, sessionid2;
54584417368Smartijn 	struct varbind varbind[] = {
54684417368Smartijn 		{
54784417368Smartijn 			.type = TYPE_NULL,
54884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 14, 1),
54984417368Smartijn 			.data.int32 = 1
55084417368Smartijn 		},
55184417368Smartijn 		{
55284417368Smartijn 			.type = TYPE_NULL,
55384417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 14, 2),
55484417368Smartijn 			.data.int32 = 2
55584417368Smartijn 		}
55684417368Smartijn 	};
55784417368Smartijn 	int32_t requestid;
55884417368Smartijn 	char buf[1024];
55984417368Smartijn 	size_t n;
56084417368Smartijn 
56184417368Smartijn 	ax_s1 = agentx_connect(axsocket);
56284417368Smartijn 	ax_s2 = agentx_connect(axsocket);
56384417368Smartijn 	sessionid1 = agentx_open(ax_s1, 0, 0,
56484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 14, 1),
56584417368Smartijn 	    "backend_get_two_double_backend.1");
56684417368Smartijn 	sessionid2 = agentx_open(ax_s2, 0, 0,
56784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 14, 2),
56884417368Smartijn 	    "backend_get_two_double_backend.2");
56984417368Smartijn 	agentx_register(ax_s1, sessionid1, 0, 0, 127, 0,
57084417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 14, 1), 0);
57184417368Smartijn 	agentx_register(ax_s2, sessionid2, 0, 0, 127, 0,
57284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 14, 2), 0);
57384417368Smartijn 
57484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
57584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
57684417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, varbind, 2);
57784417368Smartijn 
57884417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
57984417368Smartijn 	n = agentx_read(ax_s1, buf, sizeof(buf), 1000);
58084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid1, varbind, 1);
58184417368Smartijn 	agentx_response(ax_s1, buf, NOERROR, 0, varbind, 1);
58284417368Smartijn 
58384417368Smartijn 	n = agentx_read(ax_s2, buf, sizeof(buf), 1000);
58484417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, varbind + 1, 1);
58584417368Smartijn 	agentx_response(ax_s2, buf, NOERROR, 0, varbind + 1, 1);
58684417368Smartijn 
58784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
58884417368Smartijn 	    varbind, 2);
58984417368Smartijn }
59084417368Smartijn 
59184417368Smartijn void
backend_get_wrongorder(void)59284417368Smartijn backend_get_wrongorder(void)
59384417368Smartijn {
59484417368Smartijn 	struct sockaddr_storage ss;
59584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
59684417368Smartijn 	socklen_t salen;
59784417368Smartijn 	int snmp_s, ax_s;
59884417368Smartijn 	uint32_t sessionid;
59984417368Smartijn 	struct varbind varbind[] = {
60084417368Smartijn 		{
60184417368Smartijn 			.type = TYPE_NULL,
60284417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 15, 1),
60384417368Smartijn 		},
60484417368Smartijn 		{
60584417368Smartijn 			.type = TYPE_NULL,
60684417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 15, 2),
60784417368Smartijn 		}
60884417368Smartijn 	};
60984417368Smartijn 	struct varbind varbind_ax[] = {
61084417368Smartijn 		{
61184417368Smartijn 			.type = TYPE_INTEGER,
61284417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 15, 1),
61384417368Smartijn 			.data.int32 = 1
61484417368Smartijn 		},
61584417368Smartijn 		{
61684417368Smartijn 			.type = TYPE_INTEGER,
61784417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 15, 2),
61884417368Smartijn 			.data.int32 = 2
61984417368Smartijn 		}
62084417368Smartijn 	}, tmpvarbind;
62184417368Smartijn 	int32_t requestid;
62284417368Smartijn 	char buf[1024];
62384417368Smartijn 	size_t n;
62484417368Smartijn 
62584417368Smartijn 	ax_s = agentx_connect(axsocket);
62684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
62784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 15), __func__);
62884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
62984417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 15), 0);
63084417368Smartijn 
63184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
63284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
63384417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, varbind, 2);
63484417368Smartijn 
63584417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
63684417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, varbind_ax, 2);
63784417368Smartijn 	tmpvarbind = varbind_ax[0];
63884417368Smartijn 	varbind_ax[0] = varbind_ax[1];
63984417368Smartijn 	varbind_ax[1] = tmpvarbind;
64084417368Smartijn 
64184417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind_ax, 2);
64284417368Smartijn 
64384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 2,
64484417368Smartijn 	    varbind, 2);
64584417368Smartijn }
64684417368Smartijn 
64784417368Smartijn void
backend_get_toofew(void)64884417368Smartijn backend_get_toofew(void)
64984417368Smartijn {
65084417368Smartijn 	struct sockaddr_storage ss;
65184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
65284417368Smartijn 	socklen_t salen;
65384417368Smartijn 	int snmp_s, ax_s;
65484417368Smartijn 	uint32_t sessionid;
65584417368Smartijn 	struct varbind varbind[] = {
65684417368Smartijn 		{
65784417368Smartijn 			.type = TYPE_NULL,
65884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 16, 1),
65984417368Smartijn 		},
66084417368Smartijn 		{
66184417368Smartijn 			.type = TYPE_NULL,
66284417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 16, 2),
66384417368Smartijn 		}
66484417368Smartijn 	};
66584417368Smartijn 	struct varbind varbind_ax[] = {
66684417368Smartijn 		{
66784417368Smartijn 			.type = TYPE_INTEGER,
66884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 16, 1),
66984417368Smartijn 			.data.int32 = 1
67084417368Smartijn 		},
67184417368Smartijn 		{
67284417368Smartijn 			.type = TYPE_INTEGER,
67384417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 16, 2),
67484417368Smartijn 			.data.int32 = 2
67584417368Smartijn 		}
67684417368Smartijn 	}, tmpvarbind;
67784417368Smartijn 	int32_t requestid;
67884417368Smartijn 	char buf[1024];
67984417368Smartijn 	size_t n;
68084417368Smartijn 
68184417368Smartijn 	ax_s = agentx_connect(axsocket);
68284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
68384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 16), __func__);
68484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
68584417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 16), 0);
68684417368Smartijn 
68784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
68884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
68984417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, varbind, 2);
69084417368Smartijn 
69184417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
69284417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, varbind_ax, 2);
69384417368Smartijn 
69484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind_ax, 1);
69584417368Smartijn 
69684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 2,
69784417368Smartijn 	    varbind, 2);
69884417368Smartijn }
69984417368Smartijn 
70084417368Smartijn void
backend_get_toomany(void)70184417368Smartijn backend_get_toomany(void)
70284417368Smartijn {
70384417368Smartijn 	struct sockaddr_storage ss;
70484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
70584417368Smartijn 	socklen_t salen;
70684417368Smartijn 	int snmp_s, ax_s;
70784417368Smartijn 	uint32_t sessionid;
70884417368Smartijn 	struct varbind varbind[] = {
70984417368Smartijn 		{
71084417368Smartijn 			.type = TYPE_NULL,
71184417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 17, 1),
71284417368Smartijn 		},
71384417368Smartijn 		{
71484417368Smartijn 			.type = TYPE_NULL,
71584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 17, 2),
71684417368Smartijn 		}
71784417368Smartijn 	};
71884417368Smartijn 	struct varbind varbind_ax[] = {
71984417368Smartijn 		{
72084417368Smartijn 			.type = TYPE_INTEGER,
72184417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 17, 1),
72284417368Smartijn 			.data.int32 = 1
72384417368Smartijn 		},
72484417368Smartijn 		{
72584417368Smartijn 			.type = TYPE_INTEGER,
72684417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 17, 2),
72784417368Smartijn 			.data.int32 = 2
72884417368Smartijn 		},
72984417368Smartijn 		{
73084417368Smartijn 			.type = TYPE_INTEGER,
73184417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GET, 17, 3),
73284417368Smartijn 			.data.int32 = 3
73384417368Smartijn 		}
73484417368Smartijn 	}, tmpvarbind;
73584417368Smartijn 	int32_t requestid;
73684417368Smartijn 	char buf[1024];
73784417368Smartijn 	size_t n;
73884417368Smartijn 
73984417368Smartijn 	ax_s = agentx_connect(axsocket);
74084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
74184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 17), __func__);
74284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
74384417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 17), 0);
74484417368Smartijn 
74584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
74684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
74784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, varbind, 2);
74884417368Smartijn 
74984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
75084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, varbind_ax, 2);
75184417368Smartijn 
75284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind_ax, 3);
75384417368Smartijn 
75484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 2,
75584417368Smartijn 	    varbind, 2);
75684417368Smartijn }
75784417368Smartijn 
75884417368Smartijn void
backend_get_instance(void)75984417368Smartijn backend_get_instance(void)
76084417368Smartijn {
76184417368Smartijn 	struct sockaddr_storage ss;
76284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
76384417368Smartijn 	socklen_t salen;
76484417368Smartijn 	int snmp_s, ax_s;
76584417368Smartijn 	uint32_t sessionid;
76684417368Smartijn 	struct varbind varbind = {
76784417368Smartijn 		.type = TYPE_NULL,
76884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 18, 0),
76984417368Smartijn 	};
77084417368Smartijn 	int32_t requestid;
77184417368Smartijn 	char buf[1024];
77284417368Smartijn 	size_t n;
77384417368Smartijn 
77484417368Smartijn 	ax_s = agentx_connect(axsocket);
77584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
77684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 18), __func__);
77784417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
77884417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 18, 0), 0);
77984417368Smartijn 
78084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
78184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
78284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
78384417368Smartijn 
78484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
78584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
78684417368Smartijn 
78784417368Smartijn 	varbind.type = TYPE_INTEGER;
78884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
78984417368Smartijn 
79084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
79184417368Smartijn 	    &varbind, 1);
79284417368Smartijn }
79384417368Smartijn 
79484417368Smartijn void
backend_get_instance_below(void)79584417368Smartijn backend_get_instance_below(void)
79684417368Smartijn {
79784417368Smartijn 	struct sockaddr_storage ss;
79884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
79984417368Smartijn 	socklen_t salen;
80084417368Smartijn 	int snmp_s, ax_s;
80184417368Smartijn 	uint32_t sessionid;
80284417368Smartijn 	struct varbind varbind = {
80384417368Smartijn 		.type = TYPE_NULL,
80484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 19, 0),
80584417368Smartijn 	};
80684417368Smartijn 	int32_t requestid;
80784417368Smartijn 	char buf[1024];
80884417368Smartijn 	size_t n;
80984417368Smartijn 
81084417368Smartijn 	ax_s = agentx_connect(axsocket);
81184417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
81284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 19), __func__);
81384417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
81484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 19), 0);
81584417368Smartijn 
81684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
81784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
81884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
81984417368Smartijn 
82084417368Smartijn 	varbind.type = TYPE_NOSUCHINSTANCE;
82184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
82284417368Smartijn 	    &varbind, 1);
82384417368Smartijn }
82484417368Smartijn 
82584417368Smartijn void
backend_get_timeout_default(void)82684417368Smartijn backend_get_timeout_default(void)
82784417368Smartijn {
82884417368Smartijn 	struct sockaddr_storage ss;
82984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
83084417368Smartijn 	socklen_t salen;
83184417368Smartijn 	int snmp_s, ax_s;
83284417368Smartijn 	uint32_t sessionid;
83384417368Smartijn 	struct varbind varbind = {
83484417368Smartijn 		.type = TYPE_NULL,
83584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 20, 0),
83684417368Smartijn 	};
83784417368Smartijn 	int32_t requestid;
83884417368Smartijn 	char buf[1024];
83984417368Smartijn 	size_t n;
84084417368Smartijn 	struct timespec start, end, diff;
84184417368Smartijn 
84284417368Smartijn 	ax_s = agentx_connect(axsocket);
84384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
84484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 20), __func__);
84584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
84684417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 20), 0);
84784417368Smartijn 
84884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
84984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
85084417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)
85184417368Smartijn 		err(1, "clock_gettime");
85284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
85384417368Smartijn 
85484417368Smartijn 	snmpv2_response_validate(snmp_s, 6000, community, requestid, GENERR, 1,
85584417368Smartijn 	    &varbind, 1);
85684417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &end) == -1)
85784417368Smartijn 		err(1, "clock_gettime");
85884417368Smartijn 	timespecsub(&end, &start, &diff);
85984417368Smartijn 	if (diff.tv_sec != 5)
86084417368Smartijn 		errx(1, "%s: unexpected timeout (%lld.%09ld/5)", __func__,
86184417368Smartijn 		    diff.tv_sec, diff.tv_nsec);
86284417368Smartijn }
86384417368Smartijn 
86484417368Smartijn void
backend_get_timeout_session_lower(void)86584417368Smartijn backend_get_timeout_session_lower(void)
86684417368Smartijn {
86784417368Smartijn 	struct sockaddr_storage ss;
86884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
86984417368Smartijn 	socklen_t salen;
87084417368Smartijn 	int snmp_s, ax_s;
87184417368Smartijn 	uint32_t sessionid;
87284417368Smartijn 	struct varbind varbind = {
87384417368Smartijn 		.type = TYPE_NULL,
87484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 21, 0),
87584417368Smartijn 	};
87684417368Smartijn 	int32_t requestid;
87784417368Smartijn 	char buf[1024];
87884417368Smartijn 	size_t n;
87984417368Smartijn 	struct timespec start, end, diff;
88084417368Smartijn 
88184417368Smartijn 	ax_s = agentx_connect(axsocket);
88284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 1,
88384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 21), __func__);
88484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
88584417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 21), 0);
88684417368Smartijn 
88784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
88884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
88984417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)
89084417368Smartijn 		err(1, "clock_gettime");
89184417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
89284417368Smartijn 
89384417368Smartijn 	snmpv2_response_validate(snmp_s, 6000, community, requestid, GENERR, 1,
89484417368Smartijn 	    &varbind, 1);
89584417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &end) == -1)
89684417368Smartijn 		err(1, "clock_gettime");
89784417368Smartijn 	timespecsub(&end, &start, &diff);
89884417368Smartijn 	if (diff.tv_sec != 1)
89984417368Smartijn 		errx(1, "%s: unexpected timeout (%lld.%09ld/1)", __func__,
90084417368Smartijn 		    diff.tv_sec, diff.tv_nsec);
90184417368Smartijn }
90284417368Smartijn 
90384417368Smartijn void
backend_get_timeout_session_higher(void)90484417368Smartijn backend_get_timeout_session_higher(void)
90584417368Smartijn {
90684417368Smartijn 	struct sockaddr_storage ss;
90784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
90884417368Smartijn 	socklen_t salen;
90984417368Smartijn 	int snmp_s, ax_s;
91084417368Smartijn 	uint32_t sessionid;
91184417368Smartijn 	struct varbind varbind = {
91284417368Smartijn 		.type = TYPE_NULL,
91384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 22, 0),
91484417368Smartijn 	};
91584417368Smartijn 	int32_t requestid;
91684417368Smartijn 	char buf[1024];
91784417368Smartijn 	size_t n;
91884417368Smartijn 	struct timespec start, end, diff;
91984417368Smartijn 
92084417368Smartijn 	ax_s = agentx_connect(axsocket);
92184417368Smartijn 	sessionid = agentx_open(ax_s, 0, 6,
92284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 22), __func__);
92384417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
92484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 22), 0);
92584417368Smartijn 
92684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
92784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
92884417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)
92984417368Smartijn 		err(1, "clock_gettime");
93084417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
93184417368Smartijn 
93284417368Smartijn 	snmpv2_response_validate(snmp_s, 7000, community, requestid, GENERR, 1,
93384417368Smartijn 	    &varbind, 1);
93484417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &end) == -1)
93584417368Smartijn 		err(1, "clock_gettime");
93684417368Smartijn 	timespecsub(&end, &start, &diff);
93784417368Smartijn 	if (diff.tv_sec != 6)
93884417368Smartijn 		errx(1, "%s: unexpected timeout (%lld.%09ld/6)", __func__,
93984417368Smartijn 		    diff.tv_sec, diff.tv_nsec);
94084417368Smartijn }
94184417368Smartijn 
94284417368Smartijn void
backend_get_timeout_region_lower(void)94384417368Smartijn backend_get_timeout_region_lower(void)
94484417368Smartijn {
94584417368Smartijn 	struct sockaddr_storage ss;
94684417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
94784417368Smartijn 	socklen_t salen;
94884417368Smartijn 	int snmp_s, ax_s;
94984417368Smartijn 	uint32_t sessionid;
95084417368Smartijn 	struct varbind varbind = {
95184417368Smartijn 		.type = TYPE_NULL,
95284417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 23, 0),
95384417368Smartijn 	};
95484417368Smartijn 	int32_t requestid;
95584417368Smartijn 	char buf[1024];
95684417368Smartijn 	size_t n;
95784417368Smartijn 	struct timespec start, end, diff;
95884417368Smartijn 
95984417368Smartijn 	ax_s = agentx_connect(axsocket);
96084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 4,
96184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 23), __func__);
96284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 1, 127, 0,
96384417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 23), 0);
96484417368Smartijn 
96584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
96684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
96784417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)
96884417368Smartijn 		err(1, "clock_gettime");
96984417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
97084417368Smartijn 
97184417368Smartijn 	snmpv2_response_validate(snmp_s, 6000, community, requestid, GENERR, 1,
97284417368Smartijn 	    &varbind, 1);
97384417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &end) == -1)
97484417368Smartijn 		err(1, "clock_gettime");
97584417368Smartijn 	timespecsub(&end, &start, &diff);
97684417368Smartijn 	if (diff.tv_sec != 1)
97784417368Smartijn 		errx(1, "%s: unexpected timeout (%lld.%09ld/1)", __func__,
97884417368Smartijn 		    diff.tv_sec, diff.tv_nsec);
97984417368Smartijn }
98084417368Smartijn 
98184417368Smartijn void
backend_get_timeout_region_higher(void)98284417368Smartijn backend_get_timeout_region_higher(void)
98384417368Smartijn {
98484417368Smartijn 	struct sockaddr_storage ss;
98584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
98684417368Smartijn 	socklen_t salen;
98784417368Smartijn 	int snmp_s, ax_s;
98884417368Smartijn 	uint32_t sessionid;
98984417368Smartijn 	struct varbind varbind = {
99084417368Smartijn 		.type = TYPE_NULL,
99184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 24, 0),
99284417368Smartijn 	};
99384417368Smartijn 	int32_t requestid;
99484417368Smartijn 	char buf[1024];
99584417368Smartijn 	size_t n;
99684417368Smartijn 	struct timespec start, end, diff;
99784417368Smartijn 
99884417368Smartijn 	ax_s = agentx_connect(axsocket);
99984417368Smartijn 	sessionid = agentx_open(ax_s, 0, 7,
100084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 24), __func__);
100184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 6, 127, 0,
100284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 24), 0);
100384417368Smartijn 
100484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
100584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
100684417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &start) == -1)
100784417368Smartijn 		err(1, "clock_gettime");
100884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
100984417368Smartijn 
101084417368Smartijn 	snmpv2_response_validate(snmp_s, 8000, community, requestid, GENERR, 1,
101184417368Smartijn 	    &varbind, 1);
101284417368Smartijn 	if (clock_gettime(CLOCK_MONOTONIC, &end) == -1)
101384417368Smartijn 		err(1, "clock_gettime");
101484417368Smartijn 	timespecsub(&end, &start, &diff);
101584417368Smartijn 	if (diff.tv_sec != 6)
101684417368Smartijn 		errx(1, "%s: unexpected timeout (%lld.%09ld/6)", __func__,
101784417368Smartijn 		    diff.tv_sec, diff.tv_nsec);
101884417368Smartijn }
101984417368Smartijn 
102084417368Smartijn void
backend_get_priority_lower(void)102184417368Smartijn backend_get_priority_lower(void)
102284417368Smartijn {
102384417368Smartijn 	struct sockaddr_storage ss;
102484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
102584417368Smartijn 	socklen_t salen;
102684417368Smartijn 	int snmp_s, ax_s;
102784417368Smartijn 	uint32_t sessionid1, sessionid2;
102884417368Smartijn 	struct varbind varbind = {
102984417368Smartijn 		.type = TYPE_NULL,
103084417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 25, 0),
103184417368Smartijn 		.data.int32 = 1
103284417368Smartijn 	};
103384417368Smartijn 	int32_t requestid;
103484417368Smartijn 	char buf[1024];
103584417368Smartijn 	size_t n;
103684417368Smartijn 
103784417368Smartijn 	ax_s = agentx_connect(axsocket);
103884417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
103984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 25, 1), "backend_get_priority.1");
104084417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
104184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 25, 2), "backend_get_priority.2");
104284417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
104384417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 25), 0);
104484417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 126, 0,
104584417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 25), 0);
104684417368Smartijn 
104784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
104884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
104984417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
105084417368Smartijn 
105184417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
105284417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, &varbind, 1);
105384417368Smartijn 
105484417368Smartijn 	varbind.type = TYPE_INTEGER;
105584417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
105684417368Smartijn 
105784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
105884417368Smartijn 	    &varbind, 1);
105984417368Smartijn }
106084417368Smartijn 
106184417368Smartijn void
backend_get_priority_higher(void)106284417368Smartijn backend_get_priority_higher(void)
106384417368Smartijn {
106484417368Smartijn 	struct sockaddr_storage ss;
106584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
106684417368Smartijn 	socklen_t salen;
106784417368Smartijn 	int snmp_s, ax_s;
106884417368Smartijn 	uint32_t sessionid1, sessionid2;
106984417368Smartijn 	struct varbind varbind = {
107084417368Smartijn 		.type = TYPE_NULL,
107184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 26, 0),
107284417368Smartijn 		.data.int32 = 1
107384417368Smartijn 	};
107484417368Smartijn 	int32_t requestid;
107584417368Smartijn 	char buf[1024];
107684417368Smartijn 	size_t n;
107784417368Smartijn 
107884417368Smartijn 	ax_s = agentx_connect(axsocket);
107984417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
108084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 26, 1),
108184417368Smartijn 	    "backend_get_priority_higher.1");
108284417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
108384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 26, 2),
108484417368Smartijn 	    "backend_get_priority_higher.2");
108584417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 126, 0,
108684417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 26), 0);
108784417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
108884417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 26), 0);
108984417368Smartijn 
109084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
109184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
109284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
109384417368Smartijn 
109484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
109584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid1, &varbind, 1);
109684417368Smartijn 
109784417368Smartijn 	varbind.type = TYPE_INTEGER;
109884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
109984417368Smartijn 
110084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
110184417368Smartijn 	    &varbind, 1);
110284417368Smartijn }
110384417368Smartijn 
110484417368Smartijn void
backend_get_priority_below_lower(void)110584417368Smartijn backend_get_priority_below_lower(void)
110684417368Smartijn {
110784417368Smartijn 	struct sockaddr_storage ss;
110884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
110984417368Smartijn 	socklen_t salen;
111084417368Smartijn 	int snmp_s, ax_s;
111184417368Smartijn 	uint32_t sessionid1, sessionid2;
111284417368Smartijn 	struct varbind varbind = {
111384417368Smartijn 		.type = TYPE_NULL,
111484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 27, 0),
111584417368Smartijn 		.data.int32 = 1
111684417368Smartijn 	};
111784417368Smartijn 	int32_t requestid;
111884417368Smartijn 	char buf[1024];
111984417368Smartijn 	size_t n;
112084417368Smartijn 
112184417368Smartijn 	ax_s = agentx_connect(axsocket);
112284417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
112384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 27, 1),
112484417368Smartijn 	    "backend_get_priority_below_lower.1");
112584417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
112684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 27, 2),
112784417368Smartijn 	    "backend_get_priority_below_lower.2");
112884417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
112984417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 27), 0);
113084417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 126, 0,
113184417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 27, 0), 0);
113284417368Smartijn 
113384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
113484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
113584417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
113684417368Smartijn 
113784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
113884417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, &varbind, 1);
113984417368Smartijn 
114084417368Smartijn 	varbind.type = TYPE_INTEGER;
114184417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
114284417368Smartijn 
114384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
114484417368Smartijn 	    &varbind, 1);
114584417368Smartijn }
114684417368Smartijn 
114784417368Smartijn void
backend_get_priority_below_higher(void)114884417368Smartijn backend_get_priority_below_higher(void)
114984417368Smartijn {
115084417368Smartijn 	struct sockaddr_storage ss;
115184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
115284417368Smartijn 	socklen_t salen;
115384417368Smartijn 	int snmp_s, ax_s;
115484417368Smartijn 	uint32_t sessionid1, sessionid2;
115584417368Smartijn 	struct varbind varbind = {
115684417368Smartijn 		.type = TYPE_NULL,
115784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 28, 0),
115884417368Smartijn 		.data.int32 = 1
115984417368Smartijn 	};
116084417368Smartijn 	int32_t requestid;
116184417368Smartijn 	char buf[1024];
116284417368Smartijn 	size_t n;
116384417368Smartijn 
116484417368Smartijn 	ax_s = agentx_connect(axsocket);
116584417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
116684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 28, 1),
116784417368Smartijn 	    "backend_get_priority_below_higher.1");
116884417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
116984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 28, 2),
117084417368Smartijn 	    "backend_get_priority_below_higher.2");
117184417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
117284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 28), 0);
117384417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 128, 0,
117484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 28, 0), 0);
117584417368Smartijn 
117684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
117784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
117884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
117984417368Smartijn 
118084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
118184417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, &varbind, 1);
118284417368Smartijn 
118384417368Smartijn 	varbind.type = TYPE_INTEGER;
118484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
118584417368Smartijn 
118684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
118784417368Smartijn 	    &varbind, 1);
118884417368Smartijn }
118984417368Smartijn 
119084417368Smartijn void
backend_get_close(void)119184417368Smartijn backend_get_close(void)
119284417368Smartijn {
119384417368Smartijn 	struct sockaddr_storage ss;
119484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
119584417368Smartijn 	socklen_t salen;
119684417368Smartijn 	int snmp_s, ax_s;
119784417368Smartijn 	uint32_t sessionid;
119884417368Smartijn 	struct varbind varbind = {
119984417368Smartijn 		.type = TYPE_NULL,
120084417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 29, 0),
120184417368Smartijn 	};
120284417368Smartijn 	int32_t requestid;
120384417368Smartijn 	char buf[1024];
120484417368Smartijn 	size_t n;
120584417368Smartijn 
120684417368Smartijn 	ax_s = agentx_connect(axsocket);
120784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
120884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 29), __func__);
120984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
121084417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 29), 0);
121184417368Smartijn 
121284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
121384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
121484417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
121584417368Smartijn 
121684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
121784417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
121884417368Smartijn 
121984417368Smartijn 	agentx_close(ax_s, sessionid, REASONOTHER);
122084417368Smartijn 
122184417368Smartijn 	varbind.type = TYPE_NOSUCHOBJECT;
122284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
122384417368Smartijn 	    &varbind, 1);
122484417368Smartijn }
122584417368Smartijn 
122684417368Smartijn void
backend_get_close_overlap(void)122784417368Smartijn backend_get_close_overlap(void)
122884417368Smartijn {
122984417368Smartijn 	struct sockaddr_storage ss;
123084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
123184417368Smartijn 	socklen_t salen;
123284417368Smartijn 	int snmp_s, ax_s1, ax_s2;
123384417368Smartijn 	uint32_t sessionid1, sessionid2;
123484417368Smartijn 	struct varbind varbind = {
123584417368Smartijn 		.type = TYPE_NULL,
123684417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 30, 0),
123784417368Smartijn 		.data.int32 = 1
123884417368Smartijn 	};
123984417368Smartijn 	int32_t requestid;
124084417368Smartijn 	char buf[1024];
124184417368Smartijn 	size_t n;
124284417368Smartijn 
124384417368Smartijn 	ax_s1 = agentx_connect(axsocket);
124484417368Smartijn 	ax_s2 = agentx_connect(axsocket);
124584417368Smartijn 	sessionid1 = agentx_open(ax_s1, 0, 0,
124684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 30, 1),
124784417368Smartijn 	    "backend_get_close_overlap.1");
124884417368Smartijn 	sessionid2 = agentx_open(ax_s2, 0, 0,
124984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 30, 1),
125084417368Smartijn 	    "backend_get_close_overlap.2");
125184417368Smartijn 	agentx_register(ax_s1, sessionid1, 0, 0, 127, 0,
125284417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 30), 0);
125384417368Smartijn 	agentx_register(ax_s2, sessionid2, 0, 0, 128, 0,
125484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 30), 0);
125584417368Smartijn 
125684417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
125784417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
125884417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
125984417368Smartijn 
126084417368Smartijn 	n = agentx_read(ax_s1, buf, sizeof(buf), 1000);
126184417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid1, &varbind, 1);
126284417368Smartijn 	agentx_close(ax_s1, sessionid1, REASONOTHER);
126384417368Smartijn 
126484417368Smartijn 	varbind.type = TYPE_INTEGER;
126584417368Smartijn 	n = agentx_read(ax_s2, buf, sizeof(buf), 1000);
126684417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, &varbind, 1);
126784417368Smartijn 	agentx_response(ax_s2, buf, NOERROR, 0, &varbind, 1);
126884417368Smartijn 
126984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
127084417368Smartijn 	    &varbind, 1);
127184417368Smartijn }
127284417368Smartijn 
127384417368Smartijn void
backend_get_disappear(void)127484417368Smartijn backend_get_disappear(void)
127584417368Smartijn {
127684417368Smartijn 	struct sockaddr_storage ss;
127784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
127884417368Smartijn 	socklen_t salen;
127984417368Smartijn 	int snmp_s, ax_s;
128084417368Smartijn 	uint32_t sessionid;
128184417368Smartijn 	struct varbind varbind = {
128284417368Smartijn 		.type = TYPE_NULL,
128384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 31, 0),
128484417368Smartijn 	};
128584417368Smartijn 	int32_t requestid;
128684417368Smartijn 	char buf[1024];
128784417368Smartijn 	size_t n;
128884417368Smartijn 
128984417368Smartijn 	ax_s = agentx_connect(axsocket);
129084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
129184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 31), __func__);
129284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
129384417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 31), 0);
129484417368Smartijn 
129584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
129684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
129784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
129884417368Smartijn 
129984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
130084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
130184417368Smartijn 	close(ax_s);
130284417368Smartijn 
130384417368Smartijn 	varbind.type = TYPE_NOSUCHOBJECT;
130484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
130584417368Smartijn 	    &varbind, 1);
130684417368Smartijn }
130784417368Smartijn 
130884417368Smartijn void
backend_get_disappear_overlap(void)130984417368Smartijn backend_get_disappear_overlap(void)
131084417368Smartijn {
131184417368Smartijn 	struct sockaddr_storage ss;
131284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
131384417368Smartijn 	socklen_t salen;
131484417368Smartijn 	int snmp_s, ax_s1, ax_s2;
131584417368Smartijn 	uint32_t sessionid1, sessionid2;
131684417368Smartijn 	struct varbind varbind = {
131784417368Smartijn 		.type = TYPE_NULL,
131884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 32, 0),
131984417368Smartijn 		.data.int32 = 1
132084417368Smartijn 	};
132184417368Smartijn 	int32_t requestid;
132284417368Smartijn 	char buf[1024];
132384417368Smartijn 	size_t n;
132484417368Smartijn 
132584417368Smartijn 	ax_s1 = agentx_connect(axsocket);
132684417368Smartijn 	ax_s2 = agentx_connect(axsocket);
132784417368Smartijn 	sessionid1 = agentx_open(ax_s1, 0, 0,
132884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 32, 1),
132984417368Smartijn 	    "backend_get_close_overlap.1");
133084417368Smartijn 	sessionid2 = agentx_open(ax_s2, 0, 0,
133184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 32, 1),
133284417368Smartijn 	    "backend_get_close_overlap.2");
133384417368Smartijn 	agentx_register(ax_s1, sessionid1, 0, 0, 127, 0,
133484417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 32), 0);
133584417368Smartijn 	agentx_register(ax_s2, sessionid2, 0, 0, 128, 0,
133684417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 32), 0);
133784417368Smartijn 
133884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
133984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
134084417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
134184417368Smartijn 
134284417368Smartijn 	n = agentx_read(ax_s1, buf, sizeof(buf), 1000);
134384417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid1, &varbind, 1);
134484417368Smartijn 	close(ax_s1);
134584417368Smartijn 
134684417368Smartijn 	varbind.type = TYPE_INTEGER;
134784417368Smartijn 	n = agentx_read(ax_s2, buf, sizeof(buf), 1000);
134884417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid2, &varbind, 1);
134984417368Smartijn 	agentx_response(ax_s2, buf, NOERROR, 0, &varbind, 1);
135084417368Smartijn 
135184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
135284417368Smartijn 	    &varbind, 1);
135384417368Smartijn }
135484417368Smartijn 
135584417368Smartijn void
backend_get_disappear_doublesession(void)135684417368Smartijn backend_get_disappear_doublesession(void)
135784417368Smartijn {
135884417368Smartijn 	struct sockaddr_storage ss;
135984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
136084417368Smartijn 	socklen_t salen;
136184417368Smartijn 	int snmp_s, ax_s;
136284417368Smartijn 	uint32_t sessionid1, sessionid2;
136384417368Smartijn 	struct varbind varbind = {
136484417368Smartijn 		.type = TYPE_NULL,
136584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 33, 0),
136684417368Smartijn 	};
136784417368Smartijn 	int32_t requestid;
136884417368Smartijn 	char buf[1024];
136984417368Smartijn 	size_t n;
137084417368Smartijn 
137184417368Smartijn 	ax_s = agentx_connect(axsocket);
137284417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
137384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 33, 1),
137484417368Smartijn 	    "backend_get_disappear_doublesession.1");
137584417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
137684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 33, 2),
137784417368Smartijn 	    "backend_get_disappear_doublesession.2");
137884417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
137984417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 33), 0);
138084417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 128, 0,
138184417368Smartijn 	    OID_ARG(MIB_BACKEND_GET, 33), 0);
138284417368Smartijn 
138384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
138484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
138584417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
138684417368Smartijn 
138784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
138884417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid1, &varbind, 1);
138984417368Smartijn 	close(ax_s);
139084417368Smartijn 
139184417368Smartijn 	varbind.type = TYPE_NOSUCHOBJECT;
139284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
139384417368Smartijn 	    &varbind, 1);
139484417368Smartijn }
139584417368Smartijn 
139684417368Smartijn void
backend_get_octetstring_max(void)1397*1434a006Smartijn backend_get_octetstring_max(void)
1398*1434a006Smartijn {
1399*1434a006Smartijn 	struct sockaddr_storage ss;
1400*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1401*1434a006Smartijn 	socklen_t salen;
1402*1434a006Smartijn 	int snmp_s, ax_s;
1403*1434a006Smartijn 	uint32_t sessionid;
1404*1434a006Smartijn 	char vbbuf[65535] = {};
1405*1434a006Smartijn 	struct varbind varbind = {
1406*1434a006Smartijn 		.type = TYPE_NULL,
1407*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 34, 0),
1408*1434a006Smartijn 		.data.octetstring.string = vbbuf,
1409*1434a006Smartijn 		.data.octetstring.len = sizeof(vbbuf)
1410*1434a006Smartijn 	};
1411*1434a006Smartijn 	int32_t requestid;
1412*1434a006Smartijn 	char buf[1024];
1413*1434a006Smartijn 	size_t n;
1414*1434a006Smartijn 
1415*1434a006Smartijn 	memset(vbbuf, 'a', sizeof(vbbuf));
1416*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1417*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1418*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 34), __func__);
1419*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1420*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 34), 0);
1421*1434a006Smartijn 
1422*1434a006Smartijn 	/* Too big for SOCK_DGRAM */
1423*1434a006Smartijn 	salen = snmp_resolve(SOCK_STREAM, hostname, servname, sa);
1424*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_STREAM, sa, salen);
1425*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1426*1434a006Smartijn 
1427*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1428*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1429*1434a006Smartijn 
1430*1434a006Smartijn 	varbind.type = TYPE_OCTETSTRING;
1431*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1432*1434a006Smartijn 
1433*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
1434*1434a006Smartijn 	    &varbind, 1);
1435*1434a006Smartijn }
1436*1434a006Smartijn 
1437*1434a006Smartijn void
backend_get_octetstring_too_long(void)1438*1434a006Smartijn backend_get_octetstring_too_long(void)
1439*1434a006Smartijn {
1440*1434a006Smartijn 	struct sockaddr_storage ss;
1441*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1442*1434a006Smartijn 	socklen_t salen;
1443*1434a006Smartijn 	int snmp_s, ax_s;
1444*1434a006Smartijn 	uint32_t sessionid;
1445*1434a006Smartijn 	char vbbuf[65536];
1446*1434a006Smartijn 	struct varbind varbind = {
1447*1434a006Smartijn 		.type = TYPE_NULL,
1448*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 35, 0),
1449*1434a006Smartijn 		.data.octetstring.string = vbbuf,
1450*1434a006Smartijn 		.data.octetstring.len = sizeof(vbbuf)
1451*1434a006Smartijn 	};
1452*1434a006Smartijn 	int32_t requestid;
1453*1434a006Smartijn 	char buf[1024];
1454*1434a006Smartijn 	size_t n;
1455*1434a006Smartijn 
1456*1434a006Smartijn 	memset(vbbuf, 'a', sizeof(vbbuf));
1457*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1458*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1459*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 35), __func__);
1460*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1461*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 35), 0);
1462*1434a006Smartijn 
1463*1434a006Smartijn 	salen = snmp_resolve(SOCK_STREAM, hostname, servname, sa);
1464*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_STREAM, sa, salen);
1465*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1466*1434a006Smartijn 
1467*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1468*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1469*1434a006Smartijn 
1470*1434a006Smartijn 	varbind.type = TYPE_OCTETSTRING;
1471*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1472*1434a006Smartijn 
1473*1434a006Smartijn 	varbind.type = TYPE_NULL;
1474*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
1475*1434a006Smartijn 	    &varbind, 1);
1476*1434a006Smartijn }
1477*1434a006Smartijn 
1478*1434a006Smartijn void
backend_get_ipaddress_too_short(void)1479*1434a006Smartijn backend_get_ipaddress_too_short(void)
1480*1434a006Smartijn {
1481*1434a006Smartijn 	struct sockaddr_storage ss;
1482*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1483*1434a006Smartijn 	socklen_t salen;
1484*1434a006Smartijn 	int snmp_s, ax_s;
1485*1434a006Smartijn 	uint32_t sessionid;
1486*1434a006Smartijn 	struct varbind varbind = {
1487*1434a006Smartijn 		.type = TYPE_NULL,
1488*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 36, 0),
1489*1434a006Smartijn 		.data.octetstring.string = "\0\0\0",
1490*1434a006Smartijn 		.data.octetstring.len = 3
1491*1434a006Smartijn 	};
1492*1434a006Smartijn 	int32_t requestid;
1493*1434a006Smartijn 	char buf[1024];
1494*1434a006Smartijn 	size_t n;
1495*1434a006Smartijn 
1496*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1497*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1498*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 36), __func__);
1499*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1500*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 36), 0);
1501*1434a006Smartijn 
1502*1434a006Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
1503*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
1504*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1505*1434a006Smartijn 
1506*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1507*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1508*1434a006Smartijn 
1509*1434a006Smartijn 	varbind.type = TYPE_IPADDRESS;
1510*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1511*1434a006Smartijn 
1512*1434a006Smartijn 	varbind.type = TYPE_NULL;
1513*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
1514*1434a006Smartijn 	    &varbind, 1);
1515*1434a006Smartijn }
1516*1434a006Smartijn 
1517*1434a006Smartijn void
backend_get_ipaddress_too_long(void)1518*1434a006Smartijn backend_get_ipaddress_too_long(void)
1519*1434a006Smartijn {
1520*1434a006Smartijn 	struct sockaddr_storage ss;
1521*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1522*1434a006Smartijn 	socklen_t salen;
1523*1434a006Smartijn 	int snmp_s, ax_s;
1524*1434a006Smartijn 	uint32_t sessionid;
1525*1434a006Smartijn 	struct varbind varbind = {
1526*1434a006Smartijn 		.type = TYPE_NULL,
1527*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 37, 0),
1528*1434a006Smartijn 		.data.octetstring.string = "\0\0\0\0\0",
1529*1434a006Smartijn 		.data.octetstring.len = 5
1530*1434a006Smartijn 	};
1531*1434a006Smartijn 	int32_t requestid;
1532*1434a006Smartijn 	char buf[1024];
1533*1434a006Smartijn 	size_t n;
1534*1434a006Smartijn 
1535*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1536*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1537*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 37), __func__);
1538*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1539*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 37), 0);
1540*1434a006Smartijn 
1541*1434a006Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
1542*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
1543*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1544*1434a006Smartijn 
1545*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1546*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1547*1434a006Smartijn 
1548*1434a006Smartijn 	varbind.type = TYPE_IPADDRESS;
1549*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1550*1434a006Smartijn 
1551*1434a006Smartijn 	varbind.type = TYPE_NULL;
1552*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
1553*1434a006Smartijn 	    &varbind, 1);
1554*1434a006Smartijn }
1555*1434a006Smartijn 
1556*1434a006Smartijn void
backend_get_opaque_non_ber(void)1557*1434a006Smartijn backend_get_opaque_non_ber(void)
1558*1434a006Smartijn {
1559*1434a006Smartijn 	struct sockaddr_storage ss;
1560*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1561*1434a006Smartijn 	socklen_t salen;
1562*1434a006Smartijn 	int snmp_s, ax_s;
1563*1434a006Smartijn 	uint32_t sessionid;
1564*1434a006Smartijn 	struct varbind varbind = {
1565*1434a006Smartijn 		.type = TYPE_NULL,
1566*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 38, 0),
1567*1434a006Smartijn 		.data.octetstring.string = "\1",
1568*1434a006Smartijn 		.data.octetstring.len = 1
1569*1434a006Smartijn 	};
1570*1434a006Smartijn 	int32_t requestid;
1571*1434a006Smartijn 	char buf[1024];
1572*1434a006Smartijn 	size_t n;
1573*1434a006Smartijn 	ssize_t len;
1574*1434a006Smartijn 
1575*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1576*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1577*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 38), __func__);
1578*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1579*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 38), 0);
1580*1434a006Smartijn 
1581*1434a006Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
1582*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
1583*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1584*1434a006Smartijn 
1585*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1586*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1587*1434a006Smartijn 
1588*1434a006Smartijn 	varbind.type = TYPE_OPAQUE;
1589*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1590*1434a006Smartijn 
1591*1434a006Smartijn 	varbind.type = TYPE_NULL;
1592*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
1593*1434a006Smartijn 	    &varbind, 1);
1594*1434a006Smartijn }
1595*1434a006Smartijn 
1596*1434a006Smartijn void
backend_get_opaque_double_value(void)1597*1434a006Smartijn backend_get_opaque_double_value(void)
1598*1434a006Smartijn {
1599*1434a006Smartijn 	struct sockaddr_storage ss;
1600*1434a006Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
1601*1434a006Smartijn 	socklen_t salen;
1602*1434a006Smartijn 	int snmp_s, ax_s;
1603*1434a006Smartijn 	uint32_t sessionid;
1604*1434a006Smartijn 	char vbbuf[1024];
1605*1434a006Smartijn 	struct varbind varbind = {
1606*1434a006Smartijn 		.type = TYPE_NULL,
1607*1434a006Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GET, 39, 0),
1608*1434a006Smartijn 		.data.octetstring.string = vbbuf
1609*1434a006Smartijn 	};
1610*1434a006Smartijn 	int32_t requestid;
1611*1434a006Smartijn 	void *berdata;
1612*1434a006Smartijn 	char buf[1024];
1613*1434a006Smartijn 	size_t n;
1614*1434a006Smartijn 	struct ber ber = {};
1615*1434a006Smartijn 	struct ber_element *elm;
1616*1434a006Smartijn 	ssize_t len;
1617*1434a006Smartijn 
1618*1434a006Smartijn 	ax_s = agentx_connect(axsocket);
1619*1434a006Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
1620*1434a006Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GET, 39), __func__);
1621*1434a006Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
1622*1434a006Smartijn 	    OID_ARG(MIB_BACKEND_GET, 39), 0);
1623*1434a006Smartijn 
1624*1434a006Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
1625*1434a006Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
1626*1434a006Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
1627*1434a006Smartijn 
1628*1434a006Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
1629*1434a006Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
1630*1434a006Smartijn 
1631*1434a006Smartijn 	if ((elm = ober_add_integer(NULL, 1)) == NULL)
1632*1434a006Smartijn 		err(1, "ober_add_integer");
1633*1434a006Smartijn 	if (ober_write_elements(&ber, elm) == -1)
1634*1434a006Smartijn 		err(1, "ober_write_elements");
1635*1434a006Smartijn 	len = ober_get_writebuf(&ber, &berdata);
1636*1434a006Smartijn 	ober_free_elements(elm);
1637*1434a006Smartijn 
1638*1434a006Smartijn 	memcpy(vbbuf, berdata, len);
1639*1434a006Smartijn 	memcpy(vbbuf + len, berdata, len);
1640*1434a006Smartijn 	varbind.data.octetstring.len = 2 * len;
1641*1434a006Smartijn 
1642*1434a006Smartijn 	varbind.type = TYPE_OPAQUE;
1643*1434a006Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
1644*1434a006Smartijn 
1645*1434a006Smartijn 	varbind.type = TYPE_NULL;
1646*1434a006Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
1647*1434a006Smartijn 	    &varbind, 1);
1648*1434a006Smartijn 	ober_free(&ber);
1649*1434a006Smartijn }
1650*1434a006Smartijn 
1651*1434a006Smartijn void
backend_getnext_selfbound(void)165284417368Smartijn backend_getnext_selfbound(void)
165384417368Smartijn {
165484417368Smartijn 	struct sockaddr_storage ss;
165584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
165684417368Smartijn 	socklen_t salen;
165784417368Smartijn 	int snmp_s, ax_s;
165884417368Smartijn 	uint32_t sessionid;
165984417368Smartijn 	struct varbind varbind = {
166084417368Smartijn 		.type = TYPE_NULL,
166184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 1),
166284417368Smartijn 		.data.int32 = 1
166384417368Smartijn 	};
166484417368Smartijn 	struct searchrange searchrange = {
166584417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 1),
166684417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 2)
166784417368Smartijn 	};
166884417368Smartijn 	int32_t requestid;
166984417368Smartijn 	char buf[1024];
167084417368Smartijn 	size_t n;
167184417368Smartijn 
167284417368Smartijn 	ax_s = agentx_connect(axsocket);
167384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
167484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 1), __func__);
167584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
167684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 1), 0);
167784417368Smartijn 
167884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
167984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
168084417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
168184417368Smartijn 
168284417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
168384417368Smartijn 	varbind.type = TYPE_INTEGER;
168484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
168584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
168684417368Smartijn 	    &varbind, 1);
168784417368Smartijn 
168884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
168984417368Smartijn 
169084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
169184417368Smartijn 	    &varbind, 1);
169284417368Smartijn }
169384417368Smartijn 
169484417368Smartijn void
backend_getnext_lowerbound(void)169584417368Smartijn backend_getnext_lowerbound(void)
169684417368Smartijn {
169784417368Smartijn 	struct sockaddr_storage ss;
169884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
169984417368Smartijn 	socklen_t salen;
170084417368Smartijn 	int snmp_s, ax_s;
170184417368Smartijn 	uint32_t sessionid1, sessionid2;
170284417368Smartijn 	struct varbind varbind = {
170384417368Smartijn 		.type = TYPE_NULL,
170484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 2),
170584417368Smartijn 		.data.int32 = 1
170684417368Smartijn 	};
170784417368Smartijn 	struct searchrange searchrange = {
170884417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 2),
170984417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 2, 1)
171084417368Smartijn 	};
171184417368Smartijn 	int32_t requestid;
171284417368Smartijn 	char buf[1024];
171384417368Smartijn 	size_t n;
171484417368Smartijn 
171584417368Smartijn 	ax_s = agentx_connect(axsocket);
171684417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
171784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 2, 1),
171884417368Smartijn 	    "backend_getnext_lowerbound.1");
171984417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
172084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 2, 2),
172184417368Smartijn 	    "backend_getnext_lowerbound.2");
172284417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
172384417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 2), 0);
172484417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
172584417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 2, 1), 0);
172684417368Smartijn 
172784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
172884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
172984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
173084417368Smartijn 
173184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
173284417368Smartijn 	varbind.type = TYPE_INTEGER;
173384417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
173484417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange,
173584417368Smartijn 	    &varbind, 1);
173684417368Smartijn 
173784417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
173884417368Smartijn 
173984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
174084417368Smartijn 	    &varbind, 1);
174184417368Smartijn }
174284417368Smartijn 
174384417368Smartijn void
backend_getnext_lowerbound_self(void)174484417368Smartijn backend_getnext_lowerbound_self(void)
174584417368Smartijn {
174684417368Smartijn 	struct sockaddr_storage ss;
174784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
174884417368Smartijn 	socklen_t salen;
174984417368Smartijn 	int snmp_s, ax_s;
175084417368Smartijn 	uint32_t sessionid;
175184417368Smartijn 	struct varbind varbind = {
175284417368Smartijn 		.type = TYPE_NULL,
175384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 3),
175484417368Smartijn 		.data.int32 = 1
175584417368Smartijn 	};
175684417368Smartijn 	struct searchrange searchrange = {
175784417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 3),
175884417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 4)
175984417368Smartijn 	};
176084417368Smartijn 	int32_t requestid;
176184417368Smartijn 	char buf[1024];
176284417368Smartijn 	size_t n;
176384417368Smartijn 
176484417368Smartijn 	ax_s = agentx_connect(axsocket);
176584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
176684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 3), __func__);
176784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
176884417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 3), 0);
176984417368Smartijn 
177084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
177184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
177284417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
177384417368Smartijn 
177484417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
177584417368Smartijn 	varbind.type = TYPE_INTEGER;
177684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
177784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
177884417368Smartijn 	    &varbind, 1);
177984417368Smartijn 
178084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
178184417368Smartijn 
178284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
178384417368Smartijn 	    &varbind, 1);
178484417368Smartijn }
178584417368Smartijn 
178684417368Smartijn void
backend_getnext_lowerbound_highprio(void)178784417368Smartijn backend_getnext_lowerbound_highprio(void)
178884417368Smartijn {
178984417368Smartijn 	struct sockaddr_storage ss;
179084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
179184417368Smartijn 	socklen_t salen;
179284417368Smartijn 	int snmp_s, ax_s;
179384417368Smartijn 	uint32_t sessionid1, sessionid2;
179484417368Smartijn 	struct varbind varbind = {
179584417368Smartijn 		.type = TYPE_NULL,
179684417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 4),
179784417368Smartijn 		.data.int32 = 1
179884417368Smartijn 	};
179984417368Smartijn 	struct searchrange searchrange = {
180084417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 4),
180184417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 4, 1)
180284417368Smartijn 	};
180384417368Smartijn 	int32_t requestid;
180484417368Smartijn 	char buf[1024];
180584417368Smartijn 	size_t n;
180684417368Smartijn 
180784417368Smartijn 	ax_s = agentx_connect(axsocket);
180884417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
180984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 4, 1),
181084417368Smartijn 	    "backend_getnext_lowerbound_highprio.1");
181184417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
181284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 4, 2),
181384417368Smartijn 	    "backend_getnext_lowerbound_highprio.2");
181484417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
181584417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 4), 0);
181684417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 128, 0,
181784417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 4, 1), 0);
181884417368Smartijn 
181984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
182084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
182184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
182284417368Smartijn 
182384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
182484417368Smartijn 	varbind.type = TYPE_INTEGER;
182584417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
182684417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange,
182784417368Smartijn 	    &varbind, 1);
182884417368Smartijn 
182984417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
183084417368Smartijn 
183184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
183284417368Smartijn 	    &varbind, 1);
183384417368Smartijn }
183484417368Smartijn 
183584417368Smartijn void
backend_getnext_lowerbound_lowprio(void)183684417368Smartijn backend_getnext_lowerbound_lowprio(void)
183784417368Smartijn {
183884417368Smartijn 	struct sockaddr_storage ss;
183984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
184084417368Smartijn 	socklen_t salen;
184184417368Smartijn 	int snmp_s, ax_s;
184284417368Smartijn 	uint32_t sessionid1, sessionid2;
184384417368Smartijn 	struct varbind varbind = {
184484417368Smartijn 		.type = TYPE_NULL,
184584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 5),
184684417368Smartijn 		.data.int32 = 1
184784417368Smartijn 	};
184884417368Smartijn 	struct searchrange searchrange = {
184984417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 5),
185084417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 5, 1)
185184417368Smartijn 	};
185284417368Smartijn 	int32_t requestid;
185384417368Smartijn 	char buf[1024];
185484417368Smartijn 	size_t n;
185584417368Smartijn 
185684417368Smartijn 	ax_s = agentx_connect(axsocket);
185784417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
185884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 5, 1),
185984417368Smartijn 	    "backend_getnext_lowerbound_lowprio.1");
186084417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
186184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 5, 2),
186284417368Smartijn 	    "backend_getnext_lowerbound_lowprio.2");
186384417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
186484417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 5), 0);
186584417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 128, 0,
186684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 5, 1), 0);
186784417368Smartijn 
186884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
186984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
187084417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
187184417368Smartijn 
187284417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
187384417368Smartijn 	varbind.type = TYPE_INTEGER;
187484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
187584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange,
187684417368Smartijn 	    &varbind, 1);
187784417368Smartijn 
187884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
187984417368Smartijn 
188084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
188184417368Smartijn 	    &varbind, 1);
188284417368Smartijn }
188384417368Smartijn 
188484417368Smartijn void
backend_getnext_sibling(void)188584417368Smartijn backend_getnext_sibling(void)
188684417368Smartijn {
188784417368Smartijn 	struct sockaddr_storage ss;
188884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
188984417368Smartijn 	socklen_t salen;
189084417368Smartijn 	int snmp_s, ax_s;
189184417368Smartijn 	uint32_t sessionid;
189284417368Smartijn 	struct varbind varbind = {
189384417368Smartijn 		.type = TYPE_NULL,
189484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 6),
189584417368Smartijn 		.data.int32 = 1
189684417368Smartijn 	};
189784417368Smartijn 	struct searchrange searchrange = {
189884417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 6),
189984417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 8)
190084417368Smartijn 	};
190184417368Smartijn 	int32_t requestid;
190284417368Smartijn 	char buf[1024];
190384417368Smartijn 	size_t n;
190484417368Smartijn 
190584417368Smartijn 	ax_s = agentx_connect(axsocket);
190684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
190784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 6), __func__);
190884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
190984417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 6), 0);
191084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
191184417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 7), 0);
191284417368Smartijn 
191384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
191484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
191584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
191684417368Smartijn 
191784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
191884417368Smartijn 	varbind.type = TYPE_INTEGER;
191984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
192084417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
192184417368Smartijn 	    &varbind, 1);
192284417368Smartijn 
192384417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
192484417368Smartijn 
192584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
192684417368Smartijn 	    &varbind, 1);
192784417368Smartijn }
192884417368Smartijn 
192984417368Smartijn void
backend_getnext_child_gap(void)193084417368Smartijn backend_getnext_child_gap(void)
193184417368Smartijn {
193284417368Smartijn 	struct sockaddr_storage ss;
193384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
193484417368Smartijn 	socklen_t salen;
193584417368Smartijn 	int snmp_s, ax_s;
193684417368Smartijn 	uint32_t sessionid1, sessionid2;
193784417368Smartijn 	struct varbind varbind = {
193884417368Smartijn 		.type = TYPE_NULL,
193984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 7),
194084417368Smartijn 		.data.int32 = 1
194184417368Smartijn 	};
194284417368Smartijn 	struct searchrange searchrange = {
194384417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 7),
194484417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 7, 2)
194584417368Smartijn 	};
194684417368Smartijn 	int32_t requestid;
194784417368Smartijn 	char buf[1024];
194884417368Smartijn 	size_t n;
194984417368Smartijn 
195084417368Smartijn 	ax_s = agentx_connect(axsocket);
195184417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
195284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 6, 1),
195384417368Smartijn 	    "backend_getnext_child_gap.1");
195484417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
195584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 6, 2),
195684417368Smartijn 	    "backend_getnext_child_gap.2");
195784417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
195884417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 7), 0);
195984417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
196084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 7, 2), 0);
196184417368Smartijn 
196284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
196384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
196484417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
196584417368Smartijn 
196684417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
196784417368Smartijn 	varbind.type = TYPE_INTEGER;
196884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
196984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange,
197084417368Smartijn 	    &varbind, 1);
197184417368Smartijn 
197284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
197384417368Smartijn 
197484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
197584417368Smartijn 	    &varbind, 1);
197684417368Smartijn }
197784417368Smartijn 
197884417368Smartijn void
backend_getnext_nosuchobject(void)197984417368Smartijn backend_getnext_nosuchobject(void)
198084417368Smartijn {
198184417368Smartijn 	struct sockaddr_storage ss;
198284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
198384417368Smartijn 	socklen_t salen;
198484417368Smartijn 	int snmp_s, ax_s;
198584417368Smartijn 	uint32_t sessionid;
198684417368Smartijn 	struct varbind varbind = {
198784417368Smartijn 		.type = TYPE_NULL,
198884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 8),
198984417368Smartijn 	};
199084417368Smartijn 	struct searchrange searchrange = {
199184417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 8),
199284417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 9)
199384417368Smartijn 	};
199484417368Smartijn 	int32_t requestid;
199584417368Smartijn 	char buf[1024];
199684417368Smartijn 	size_t n;
199784417368Smartijn 
199884417368Smartijn 	ax_s = agentx_connect(axsocket);
199984417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
200084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 8), __func__);
200184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
200284417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 8), 0);
200384417368Smartijn 
200484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
200584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
200684417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
200784417368Smartijn 
200884417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
200984417368Smartijn 	varbind.type = TYPE_NOSUCHOBJECT;
201084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
201184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
201284417368Smartijn 	    &varbind, 1);
201384417368Smartijn 	varbind.name.n_subid--;
201484417368Smartijn 	varbind.type = TYPE_NULL;
201584417368Smartijn 
201684417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
201784417368Smartijn 
201884417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
201984417368Smartijn 	    &varbind, 1);
202084417368Smartijn }
202184417368Smartijn 
202284417368Smartijn void
backend_getnext_nosuchinstance(void)202384417368Smartijn backend_getnext_nosuchinstance(void)
202484417368Smartijn {
202584417368Smartijn 	struct sockaddr_storage ss;
202684417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
202784417368Smartijn 	socklen_t salen;
202884417368Smartijn 	int snmp_s, ax_s;
202984417368Smartijn 	uint32_t sessionid;
203084417368Smartijn 	struct varbind varbind = {
203184417368Smartijn 		.type = TYPE_NULL,
203284417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 9),
203384417368Smartijn 	};
203484417368Smartijn 	struct searchrange searchrange = {
203584417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 9),
203684417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 10)
203784417368Smartijn 	};
203884417368Smartijn 	int32_t requestid;
203984417368Smartijn 	char buf[1024];
204084417368Smartijn 	size_t n;
204184417368Smartijn 
204284417368Smartijn 	ax_s = agentx_connect(axsocket);
204384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
204484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 9), __func__);
204584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
204684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 9), 0);
204784417368Smartijn 
204884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
204984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
205084417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
205184417368Smartijn 
205284417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
205384417368Smartijn 	varbind.type = TYPE_NOSUCHINSTANCE;
205484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
205584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
205684417368Smartijn 	    &varbind, 1);
205784417368Smartijn 	varbind.name.n_subid--;
205884417368Smartijn 	varbind.type = TYPE_NULL;
205984417368Smartijn 
206084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
206184417368Smartijn 
206284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
206384417368Smartijn 	    &varbind, 1);
206484417368Smartijn }
206584417368Smartijn 
206684417368Smartijn /* Assume that everything is registered under 1.3.* */
206784417368Smartijn void
backend_getnext_endofmibview(void)206884417368Smartijn backend_getnext_endofmibview(void)
206984417368Smartijn {
207084417368Smartijn 	struct sockaddr_storage ss;
207184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
207284417368Smartijn 	socklen_t salen;
207384417368Smartijn 	int snmp_s, ax_s;
207484417368Smartijn 	uint32_t sessionid;
207584417368Smartijn 	struct varbind varbind = {
207684417368Smartijn 		.type = TYPE_NULL,
207784417368Smartijn 		.name = OID_STRUCT(2, 0),
207884417368Smartijn 	};
207984417368Smartijn 	struct searchrange searchrange = {
208084417368Smartijn 		.start = OID_STRUCT(2, 0),
208184417368Smartijn 		.end = OID_STRUCT(2, 1)
208284417368Smartijn 	};
208384417368Smartijn 	int32_t requestid;
208484417368Smartijn 	char buf[1024];
208584417368Smartijn 	size_t n;
208684417368Smartijn 
208784417368Smartijn 	ax_s = agentx_connect(axsocket);
208884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
208984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 10), __func__);
209084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
209184417368Smartijn 	    OID_ARG(2, 0), 0);
209284417368Smartijn 
209384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
209484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
209584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
209684417368Smartijn 
209784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
209884417368Smartijn 	varbind.type = TYPE_ENDOFMIBVIEW;
209984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
210084417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
210184417368Smartijn 	    &varbind, 1);
210284417368Smartijn 	varbind.name.n_subid--;
210384417368Smartijn 
210484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
210584417368Smartijn 
210684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
210784417368Smartijn 	    &varbind, 1);
210884417368Smartijn }
210984417368Smartijn 
211084417368Smartijn void
backend_getnext_inclusive(void)211184417368Smartijn backend_getnext_inclusive(void)
211284417368Smartijn {
211384417368Smartijn 	struct sockaddr_storage ss;
211484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
211584417368Smartijn 	socklen_t salen;
211684417368Smartijn 	int snmp_s, ax_s;
211784417368Smartijn 	uint32_t sessionid;
211884417368Smartijn 	struct varbind varbind = {
211984417368Smartijn 		.type = TYPE_NULL,
212084417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 11),
212184417368Smartijn 		.data.int32 = 1
212284417368Smartijn 	};
212384417368Smartijn 	struct searchrange searchrange = {
212484417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 11, 0),
212584417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 11, 1)
212684417368Smartijn 	};
212784417368Smartijn 	int32_t requestid;
212884417368Smartijn 	char buf[1024];
212984417368Smartijn 	size_t n;
213084417368Smartijn 
213184417368Smartijn 	searchrange.start.include = 1;
213284417368Smartijn 	ax_s = agentx_connect(axsocket);
213384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
213484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 11), __func__);
213584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
213684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 11, 0), 0);
213784417368Smartijn 
213884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
213984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
214084417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
214184417368Smartijn 
214284417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
214384417368Smartijn 	varbind.type = TYPE_INTEGER;
214484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
214584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
214684417368Smartijn 	    &varbind, 1);
214784417368Smartijn 
214884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
214984417368Smartijn 
215084417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
215184417368Smartijn 	    &varbind, 1);
215284417368Smartijn }
215384417368Smartijn 
215484417368Smartijn void
backend_getnext_jumpnext(void)215584417368Smartijn backend_getnext_jumpnext(void)
215684417368Smartijn {
215784417368Smartijn 	struct sockaddr_storage ss;
215884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
215984417368Smartijn 	socklen_t salen;
216084417368Smartijn 	int snmp_s, ax_s;
216184417368Smartijn 	uint32_t sessionid1, sessionid2;
216284417368Smartijn 	struct varbind varbind1 = {
216384417368Smartijn 		.type = TYPE_NULL,
216484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 12)
216584417368Smartijn 	}, varbind2 = {
216684417368Smartijn 		.type = TYPE_INTEGER,
216784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 12, 1),
216884417368Smartijn 		.data.int32 = 1
216984417368Smartijn 	};
217084417368Smartijn 	struct searchrange searchrange1 = {
217184417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 12),
217284417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 12, 1)
217384417368Smartijn 	}, searchrange2 = {
217484417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 12, 1),
217584417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 12, 2)
217684417368Smartijn 	};
217784417368Smartijn 	int32_t requestid;
217884417368Smartijn 	char buf[1024];
217984417368Smartijn 	size_t n;
218084417368Smartijn 
218184417368Smartijn 	ax_s = agentx_connect(axsocket);
218284417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
218384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 12, 1),
218484417368Smartijn 	    "backend_getnext_jumpnext.1");
218584417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
218684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 12, 2),
218784417368Smartijn 	    "backend_getnext_jumpnext.2");
218884417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
218984417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 12), 0);
219084417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
219184417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 12, 1), 0);
219284417368Smartijn 
219384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
219484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
219584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind1, 1);
219684417368Smartijn 
219784417368Smartijn 	varbind1.type = TYPE_ENDOFMIBVIEW;
219884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
219984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange1,
220084417368Smartijn 	    &varbind1, 1);
220184417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind1, 1);
220284417368Smartijn 
220384417368Smartijn 	searchrange2.start.include = 1;
220484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
220584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid2, &searchrange2,
220684417368Smartijn 	    &varbind2, 1);
220784417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind2, 1);
220884417368Smartijn 
220984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
221084417368Smartijn 	    &varbind2, 1);
221184417368Smartijn }
221284417368Smartijn 
221384417368Smartijn /* Assume that everything is registered under 1.3.* */
221484417368Smartijn void
backend_getnext_jumpnext_endofmibview(void)221584417368Smartijn backend_getnext_jumpnext_endofmibview(void)
221684417368Smartijn {
221784417368Smartijn 	struct sockaddr_storage ss;
221884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
221984417368Smartijn 	socklen_t salen;
222084417368Smartijn 	int snmp_s, ax_s;
222184417368Smartijn 	uint32_t sessionid1, sessionid2;
222284417368Smartijn 	struct varbind varbind1 = {
222384417368Smartijn 		.type = TYPE_NULL,
222484417368Smartijn 		.name = OID_STRUCT(2, 0)
222584417368Smartijn 	}, varbind2 = {
222684417368Smartijn 		.type = TYPE_ENDOFMIBVIEW,
222784417368Smartijn 		.name = OID_STRUCT(2, 1),
222884417368Smartijn 	};
222984417368Smartijn 	struct searchrange searchrange1 = {
223084417368Smartijn 		.start = OID_STRUCT(2, 0),
223184417368Smartijn 		.end = OID_STRUCT(2, 1)
223284417368Smartijn 	}, searchrange2 = {
223384417368Smartijn 		.start = OID_STRUCT(2, 1),
223484417368Smartijn 		.end = OID_STRUCT(2, 2)
223584417368Smartijn 	};
223684417368Smartijn 	int32_t requestid;
223784417368Smartijn 	char buf[1024];
223884417368Smartijn 	size_t n;
223984417368Smartijn 
224084417368Smartijn 	ax_s = agentx_connect(axsocket);
224184417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
224284417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 13, 1),
224384417368Smartijn 	    "backend_getnext_jumpnext_endofmibview.1");
224484417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
224584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 13, 2),
224684417368Smartijn 	    "backend_getnext_jumpnext_endofmibview.2");
224784417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
224884417368Smartijn 	    OID_ARG(2, 0), 0);
224984417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
225084417368Smartijn 	    OID_ARG(2, 1), 0);
225184417368Smartijn 
225284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
225384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
225484417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind1, 1);
225584417368Smartijn 
225684417368Smartijn 	varbind1.type = TYPE_ENDOFMIBVIEW;
225784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
225884417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange1,
225984417368Smartijn 	    &varbind1, 1);
226084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind1, 1);
226184417368Smartijn 
226284417368Smartijn 	searchrange2.start.include = 1;
226384417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
226484417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid2, &searchrange2,
226584417368Smartijn 	    &varbind2, 1);
226684417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind2, 1);
226784417368Smartijn 
226884417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
226984417368Smartijn 	    &varbind1, 1);
227084417368Smartijn }
227184417368Smartijn 
227284417368Smartijn void
backend_getnext_jump_up(void)227384417368Smartijn backend_getnext_jump_up(void)
227484417368Smartijn {
227584417368Smartijn 	struct sockaddr_storage ss;
227684417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
227784417368Smartijn 	socklen_t salen;
227884417368Smartijn 	int snmp_s, ax_s;
227984417368Smartijn 	uint32_t sessionid1, sessionid2;
228084417368Smartijn 	struct varbind varbind1 = {
228184417368Smartijn 		.type = TYPE_NULL,
228284417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 14, 1)
228384417368Smartijn 	}, varbind2 = {
228484417368Smartijn 		.type = TYPE_INTEGER,
228584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 14, 2),
228684417368Smartijn 		.data.int32 = 1
228784417368Smartijn 	};
228884417368Smartijn 	struct searchrange searchrange1 = {
228984417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 14, 1),
229084417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 14, 2)
229184417368Smartijn 	}, searchrange2 = {
229284417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 14, 2),
229384417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 15)
229484417368Smartijn 	};
229584417368Smartijn 	int32_t requestid;
229684417368Smartijn 	char buf[1024];
229784417368Smartijn 	size_t n;
229884417368Smartijn 
229984417368Smartijn 	ax_s = agentx_connect(axsocket);
230084417368Smartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
230184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 14, 1),
230284417368Smartijn 	    "backend_getnext_jump_up.1");
230384417368Smartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
230484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 14, 2),
230584417368Smartijn 	    "backend_getnext_jump_up.2");
230684417368Smartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
230784417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 14), 0);
230884417368Smartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
230984417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 14, 1), 0);
231084417368Smartijn 
231184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
231284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
231384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind1, 1);
231484417368Smartijn 
231584417368Smartijn 	varbind1.type = TYPE_ENDOFMIBVIEW;
231684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
231784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid2, &searchrange1,
231884417368Smartijn 	    &varbind1, 1);
231984417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind1, 1);
232084417368Smartijn 
232184417368Smartijn 	searchrange2.start.include = 1;
232284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
232384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange2,
232484417368Smartijn 	    &varbind2, 1);
232584417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind2, 1);
232684417368Smartijn 
232784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, 0, 0,
232884417368Smartijn 	    &varbind2, 1);
232984417368Smartijn }
233084417368Smartijn 
233184417368Smartijn void
backend_getnext_two_single_backend(void)233284417368Smartijn backend_getnext_two_single_backend(void)
233384417368Smartijn {
233484417368Smartijn 	struct sockaddr_storage ss;
233584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
233684417368Smartijn 	socklen_t salen;
233784417368Smartijn 	int snmp_s, ax_s;
233884417368Smartijn 	uint32_t sessionid;
233984417368Smartijn 	struct varbind varbind[] = {
234084417368Smartijn 		{
234184417368Smartijn 			.type = TYPE_NULL,
234284417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 0),
234384417368Smartijn 			.data.int32 = 1
234484417368Smartijn 		},
234584417368Smartijn 		{
234684417368Smartijn 			.type = TYPE_NULL,
234784417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 1),
234884417368Smartijn 			.data.int32 = 2
234984417368Smartijn 		}
235084417368Smartijn 	};
235184417368Smartijn 	struct varbind varbind_ax[] = {
235284417368Smartijn 		{
235384417368Smartijn 			.type = TYPE_INTEGER,
235484417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 1),
235584417368Smartijn 			.data.int32 = 1
235684417368Smartijn 		},
235784417368Smartijn 		{
235884417368Smartijn 			.type = TYPE_INTEGER,
235984417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 2),
236084417368Smartijn 			.data.int32 = 2
236184417368Smartijn 		}
236284417368Smartijn 	};
236384417368Smartijn 	struct searchrange searchrange[] = {
236484417368Smartijn 		{
236584417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 0),
236684417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 16)
236784417368Smartijn 		},
236884417368Smartijn 		{
236984417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 15, 1),
237084417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 16)
237184417368Smartijn 		}
237284417368Smartijn 	};
237384417368Smartijn 	int32_t requestid;
237484417368Smartijn 	char buf[1024];
237584417368Smartijn 	size_t n;
237684417368Smartijn 
237784417368Smartijn 	ax_s = agentx_connect(axsocket);
237884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
237984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 15), __func__);
238084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
238184417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 15), 0);
238284417368Smartijn 
238384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
238484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
238584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 2);
238684417368Smartijn 
238784417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
238884417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, searchrange,
238984417368Smartijn 	    varbind_ax, 2);
239084417368Smartijn 
239184417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind_ax, 2);
239284417368Smartijn 
239384417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
239484417368Smartijn 	varbind[0].name.subid[varbind[0].name.n_subid -1]++;
239584417368Smartijn 	varbind[1].name.subid[varbind[1].name.n_subid - 1]++;
239684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
239784417368Smartijn 	    varbind, 2);
239884417368Smartijn }
239984417368Smartijn 
240084417368Smartijn void
backend_getnext_two_double_backend(void)240184417368Smartijn backend_getnext_two_double_backend(void)
240284417368Smartijn {
240384417368Smartijn 	struct sockaddr_storage ss;
240484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
240584417368Smartijn 	socklen_t salen;
240684417368Smartijn 	int snmp_s, ax_s1, ax_s2;
240784417368Smartijn 	uint32_t sessionid1, sessionid2;
240884417368Smartijn 	struct varbind varbind[] = {
240984417368Smartijn 		{
241084417368Smartijn 			.type = TYPE_NULL,
241184417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 1),
241284417368Smartijn 			.data.int32 = 1
241384417368Smartijn 		},
241484417368Smartijn 		{
241584417368Smartijn 			.type = TYPE_NULL,
241684417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 2),
241784417368Smartijn 			.data.int32 = 2
241884417368Smartijn 		}
241984417368Smartijn 	};
242084417368Smartijn 	struct searchrange searchrange1 = {
242184417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 1),
242284417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 2)
242384417368Smartijn 	}, searchrange2 = {
242484417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 2),
242584417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 16, 3)
242684417368Smartijn 	};
242784417368Smartijn 	int32_t requestid;
242884417368Smartijn 	char buf[1024];
242984417368Smartijn 	size_t n;
243084417368Smartijn 
243184417368Smartijn 	ax_s1 = agentx_connect(axsocket);
243284417368Smartijn 	ax_s2 = agentx_connect(axsocket);
243384417368Smartijn 	sessionid1 = agentx_open(ax_s1, 0, 0,
243484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 16, 1),
243584417368Smartijn 	    "backend_getnext_two_double_backend.1");
243684417368Smartijn 	sessionid2 = agentx_open(ax_s2, 0, 0,
243784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 16, 2),
243884417368Smartijn 	    "backend_getnext_two_double_backend.2");
243984417368Smartijn 	agentx_register(ax_s1, sessionid1, 0, 0, 127, 0,
244084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 16, 1), 0);
244184417368Smartijn 	agentx_register(ax_s2, sessionid2, 0, 0, 127, 0,
244284417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 16, 2), 0);
244384417368Smartijn 
244484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
244584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
244684417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 2);
244784417368Smartijn 
244884417368Smartijn 	varbind[0].name.subid[varbind[0].name.n_subid++] = 0;
244984417368Smartijn 	varbind[1].name.subid[varbind[1].name.n_subid++] = 0;
245084417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
245184417368Smartijn 	n = agentx_read(ax_s1, buf, sizeof(buf), 1000);
245284417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, &searchrange1,
245384417368Smartijn 	    varbind + 0, 1);
245484417368Smartijn 	agentx_response(ax_s1, buf, NOERROR, 0, varbind + 0, 1);
245584417368Smartijn 
245684417368Smartijn 	n = agentx_read(ax_s2, buf, sizeof(buf), 1000);
245784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid2, &searchrange2,
245884417368Smartijn 	    varbind + 1, 1);
245984417368Smartijn 	agentx_response(ax_s2, buf, NOERROR, 0, varbind + 1, 1);
246084417368Smartijn 
246184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
246284417368Smartijn 	    varbind, 2);
246384417368Smartijn }
246484417368Smartijn 
246584417368Smartijn void
backend_getnext_instance_below(void)246684417368Smartijn backend_getnext_instance_below(void)
246784417368Smartijn {
246884417368Smartijn 	struct sockaddr_storage ss;
246984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
247084417368Smartijn 	socklen_t salen;
247184417368Smartijn 	int snmp_s, ax_s;
247284417368Smartijn 	uint32_t sessionid;
247384417368Smartijn 	struct varbind varbind = {
247484417368Smartijn 		.type = TYPE_NULL,
247584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 17, 1, 1),
247684417368Smartijn 		.data.int32 = 1
247784417368Smartijn 	};
247884417368Smartijn 	struct searchrange searchrange = {
247984417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 17, 2),
248084417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 17, 3)
248184417368Smartijn 	};
248284417368Smartijn 	int32_t requestid;
248384417368Smartijn 	char buf[1024];
248484417368Smartijn 	size_t n;
248584417368Smartijn 
248684417368Smartijn 	ax_s = agentx_connect(axsocket);
248784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
248884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 17), __func__);
248984417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
249084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 17, 1), 0);
249184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
249284417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 17, 2), 0);
249384417368Smartijn 
249484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
249584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
249684417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
249784417368Smartijn 
249884417368Smartijn 	varbind.type = TYPE_INTEGER;
249984417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 17, 2);
250084417368Smartijn 	searchrange.start.include = 1;
250184417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
250284417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
250384417368Smartijn 	    &varbind, 1);
250484417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
250584417368Smartijn 
250684417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
250784417368Smartijn 	    &varbind, 1);
250884417368Smartijn }
250984417368Smartijn 
251084417368Smartijn void
backend_getnext_instance(void)251184417368Smartijn backend_getnext_instance(void)
251284417368Smartijn {
251384417368Smartijn 	struct sockaddr_storage ss;
251484417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
251584417368Smartijn 	socklen_t salen;
251684417368Smartijn 	int snmp_s, ax_s;
251784417368Smartijn 	uint32_t sessionid;
251884417368Smartijn 	struct varbind varbind = {
251984417368Smartijn 		.type = TYPE_NULL,
252084417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 18),
252184417368Smartijn 		.data.int32 = 1
252284417368Smartijn 	};
252384417368Smartijn 	struct searchrange searchrange = {
252484417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 18, 1),
252584417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 18, 2)
252684417368Smartijn 	};
252784417368Smartijn 	int32_t requestid;
252884417368Smartijn 	char buf[1024];
252984417368Smartijn 	size_t n;
253084417368Smartijn 
253184417368Smartijn 	ax_s = agentx_connect(axsocket);
253284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
253384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 18), __func__);
253484417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
253584417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 18, 1), 0);
253684417368Smartijn 
253784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
253884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
253984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
254084417368Smartijn 
254184417368Smartijn 	varbind.type = TYPE_INTEGER;
254284417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 18, 1);
254384417368Smartijn 	searchrange.start.include = 1;
254484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
254584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
254684417368Smartijn 	    &varbind, 1);
254784417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
254884417368Smartijn 
254984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
255084417368Smartijn 	    &varbind, 1);
255184417368Smartijn }
255284417368Smartijn 
255384417368Smartijn void
backend_getnext_instance_exact(void)255484417368Smartijn backend_getnext_instance_exact(void)
255584417368Smartijn {
255684417368Smartijn 	struct sockaddr_storage ss;
255784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
255884417368Smartijn 	socklen_t salen;
255984417368Smartijn 	int snmp_s, ax_s;
256084417368Smartijn 	uint32_t sessionid;
256184417368Smartijn 	struct varbind varbind = {
256284417368Smartijn 		.type = TYPE_NULL,
256384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 19, 1),
256484417368Smartijn 		.data.int32 = 1
256584417368Smartijn 	};
256684417368Smartijn 	struct searchrange searchrange = {
256784417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 19, 2),
256884417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 19, 3)
256984417368Smartijn 	};
257084417368Smartijn 	int32_t requestid;
257184417368Smartijn 	char buf[1024];
257284417368Smartijn 	size_t n;
257384417368Smartijn 
257484417368Smartijn 	ax_s = agentx_connect(axsocket);
257584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
257684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 19), __func__);
257784417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
257884417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 19, 1), 0);
257984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
258084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 19, 2), 0);
258184417368Smartijn 
258284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
258384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
258484417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
258584417368Smartijn 
258684417368Smartijn 	varbind.type = TYPE_INTEGER;
258784417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 19, 2);
258884417368Smartijn 	searchrange.start.include = 1;
258984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
259084417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
259184417368Smartijn 	    &varbind, 1);
259284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
259384417368Smartijn 
259484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
259584417368Smartijn 	    &varbind, 1);
259684417368Smartijn }
259784417368Smartijn 
259884417368Smartijn void
backend_getnext_instance_ignore(void)259984417368Smartijn backend_getnext_instance_ignore(void)
260084417368Smartijn {
260184417368Smartijn 	struct sockaddr_storage ss;
260284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
260384417368Smartijn 	socklen_t salen;
260484417368Smartijn 	int snmp_s, ax_s;
260584417368Smartijn 	uint32_t sessionid;
260684417368Smartijn 	struct varbind varbind = {
260784417368Smartijn 		.type = TYPE_NULL,
260884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 20),
260984417368Smartijn 		.data.int32 = 1
261084417368Smartijn 	};
261184417368Smartijn 	struct searchrange searchrange = {
261284417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 20, 1),
261384417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 20, 2)
261484417368Smartijn 	};
261584417368Smartijn 	int32_t requestid;
261684417368Smartijn 	char buf[1024];
261784417368Smartijn 	size_t n;
261884417368Smartijn 
261984417368Smartijn 	ax_s = agentx_connect(axsocket);
262084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
262184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 20), __func__);
262284417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
262384417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 20, 1), 0);
262484417368Smartijn 
262584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
262684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
262784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
262884417368Smartijn 
262984417368Smartijn 	varbind.type = TYPE_INTEGER;
263084417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 20, 1, 0);
263184417368Smartijn 	searchrange.start.include = 1;
263284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
263384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
263484417368Smartijn 	    &varbind, 1);
263584417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
263684417368Smartijn 	varbind.type = TYPE_NULL;
263784417368Smartijn 	varbind.name.n_subid -= 2;
263884417368Smartijn 
263984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
264084417368Smartijn 	    &varbind, 1);
264184417368Smartijn }
264284417368Smartijn 
264384417368Smartijn void
backend_getnext_backwards(void)264484417368Smartijn backend_getnext_backwards(void)
264584417368Smartijn {
264684417368Smartijn 	struct sockaddr_storage ss;
264784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
264884417368Smartijn 	socklen_t salen;
264984417368Smartijn 	int snmp_s, ax_s;
265084417368Smartijn 	uint32_t sessionid;
265184417368Smartijn 	struct varbind varbind = {
265284417368Smartijn 		.type = TYPE_NULL,
265384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 21),
265484417368Smartijn 		.data.int32 = 1
265584417368Smartijn 	};
265684417368Smartijn 	struct searchrange searchrange = {
265784417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 21),
265884417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 22)
265984417368Smartijn 	};
266084417368Smartijn 	int32_t requestid;
266184417368Smartijn 	char buf[1024];
266284417368Smartijn 	size_t n;
266384417368Smartijn 
266484417368Smartijn 	ax_s = agentx_connect(axsocket);
266584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
266684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 21), __func__);
266784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
266884417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 21), 0);
266984417368Smartijn 
267084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
267184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
267284417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
267384417368Smartijn 
267484417368Smartijn 	varbind.type = TYPE_INTEGER;
267584417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 21, 1);
267684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
267784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
267884417368Smartijn 	    &varbind, 1);
267984417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 20);
268084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
268184417368Smartijn 	varbind.type = TYPE_NULL;
268284417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 21);
268384417368Smartijn 
268484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
268584417368Smartijn 	    &varbind, 1);
268684417368Smartijn }
268784417368Smartijn 
268884417368Smartijn void
backend_getnext_stale(void)268984417368Smartijn backend_getnext_stale(void)
269084417368Smartijn {
269184417368Smartijn 	struct sockaddr_storage ss;
269284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
269384417368Smartijn 	socklen_t salen;
269484417368Smartijn 	int snmp_s, ax_s;
269584417368Smartijn 	uint32_t sessionid;
269684417368Smartijn 	struct varbind varbind = {
269784417368Smartijn 		.type = TYPE_NULL,
269884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 22),
269984417368Smartijn 		.data.int32 = 1
270084417368Smartijn 	};
270184417368Smartijn 	struct searchrange searchrange = {
270284417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 22),
270384417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 23)
270484417368Smartijn 	};
270584417368Smartijn 	int32_t requestid;
270684417368Smartijn 	char buf[1024];
270784417368Smartijn 	size_t n;
270884417368Smartijn 
270984417368Smartijn 	ax_s = agentx_connect(axsocket);
271084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
271184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 22), __func__);
271284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
271384417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 22), 0);
271484417368Smartijn 
271584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
271684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
271784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
271884417368Smartijn 
271984417368Smartijn 	varbind.type = TYPE_INTEGER;
272084417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 22, 1);
272184417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
272284417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
272384417368Smartijn 	    &varbind, 1);
272484417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 22);
272584417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
272684417368Smartijn 	varbind.type = TYPE_NULL;
272784417368Smartijn 
272884417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
272984417368Smartijn 	    &varbind, 1);
273084417368Smartijn }
273184417368Smartijn 
273284417368Smartijn void
backend_getnext_inclusive_backwards(void)273384417368Smartijn backend_getnext_inclusive_backwards(void)
273484417368Smartijn {
273584417368Smartijn 	struct sockaddr_storage ss;
273684417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
273784417368Smartijn 	socklen_t salen;
273884417368Smartijn 	int snmp_s, ax_s;
273984417368Smartijn 	uint32_t sessionid;
274084417368Smartijn 	struct varbind varbind = {
274184417368Smartijn 		.type = TYPE_NULL,
274284417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 23),
274384417368Smartijn 		.data.int32 = 1
274484417368Smartijn 	};
274584417368Smartijn 	struct searchrange searchrange = {
274684417368Smartijn 		.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 23, 1),
274784417368Smartijn 		.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 23, 2)
274884417368Smartijn 	};
274984417368Smartijn 	int32_t requestid;
275084417368Smartijn 	char buf[1024];
275184417368Smartijn 	size_t n;
275284417368Smartijn 
275384417368Smartijn 	ax_s = agentx_connect(axsocket);
275484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
275584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 23), __func__);
275684417368Smartijn 	agentx_register(ax_s, sessionid, 1, 0, 127, 0,
275784417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 23, 1), 0);
275884417368Smartijn 
275984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
276084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
276184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
276284417368Smartijn 
276384417368Smartijn 	varbind.type = TYPE_INTEGER;
276484417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 23, 1);
276584417368Smartijn 	searchrange.start.include = 1;
276684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
276784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
276884417368Smartijn 	    &varbind, 1);
276984417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 22);
277084417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
277184417368Smartijn 	varbind.type = TYPE_NULL;
277284417368Smartijn 	varbind.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 23);
277384417368Smartijn 
277484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
277584417368Smartijn 	    &varbind, 1);
277684417368Smartijn }
277784417368Smartijn 
277884417368Smartijn void
backend_getnext_toofew(void)277984417368Smartijn backend_getnext_toofew(void)
278084417368Smartijn {
278184417368Smartijn 	struct sockaddr_storage ss;
278284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
278384417368Smartijn 	socklen_t salen;
278484417368Smartijn 	int snmp_s, ax_s;
278584417368Smartijn 	uint32_t sessionid;
278684417368Smartijn 	struct varbind varbind[] = {
278784417368Smartijn 		{
278884417368Smartijn 			.type = TYPE_NULL,
278984417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 0),
279084417368Smartijn 			.data.int32 = 1
279184417368Smartijn 		},
279284417368Smartijn 		{
279384417368Smartijn 			.type = TYPE_NULL,
279484417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 1),
279584417368Smartijn 			.data.int32 = 2
279684417368Smartijn 		}
279784417368Smartijn 	};
279884417368Smartijn 	struct searchrange searchrange[] = {
279984417368Smartijn 		{
280084417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 0),
280184417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 25)
280284417368Smartijn 		},
280384417368Smartijn 		{
280484417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 1),
280584417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 25)
280684417368Smartijn 		}
280784417368Smartijn 	};
280884417368Smartijn 	int32_t requestid;
280984417368Smartijn 	char buf[1024];
281084417368Smartijn 	size_t n;
281184417368Smartijn 
281284417368Smartijn 	ax_s = agentx_connect(axsocket);
281384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
281484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 24), __func__);
281584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
281684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 24), 0);
281784417368Smartijn 
281884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
281984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
282084417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 2);
282184417368Smartijn 
282284417368Smartijn 	varbind[0].name.subid[varbind[0].name.n_subid - 1]++;
282384417368Smartijn 	varbind[1].name.subid[varbind[1].name.n_subid - 1]++;
282484417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
282584417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
282684417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, searchrange,
282784417368Smartijn 	    varbind, 2);
282884417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
282984417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_NULL;
283084417368Smartijn 	varbind[0].name = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 0),
283184417368Smartijn 	varbind[1].name = OID_STRUCT(MIB_BACKEND_GETNEXT, 24, 1),
283284417368Smartijn 
283384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 2,
283484417368Smartijn 	    varbind, 2);
283584417368Smartijn }
283684417368Smartijn 
283784417368Smartijn void
backend_getnext_toomany(void)283884417368Smartijn backend_getnext_toomany(void)
283984417368Smartijn {
284084417368Smartijn 	struct sockaddr_storage ss;
284184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
284284417368Smartijn 	socklen_t salen;
284384417368Smartijn 	int snmp_s, ax_s;
284484417368Smartijn 	uint32_t sessionid;
284584417368Smartijn 	struct varbind varbind[] = {
284684417368Smartijn 		{
284784417368Smartijn 			.type = TYPE_NULL,
284884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 0),
284984417368Smartijn 			.data.int32 = 1
285084417368Smartijn 		},
285184417368Smartijn 		{
285284417368Smartijn 			.type = TYPE_NULL,
285384417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 1),
285484417368Smartijn 			.data.int32 = 2
285584417368Smartijn 		},
285684417368Smartijn 		{
285784417368Smartijn 			.type = TYPE_NULL,
285884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 3),
285984417368Smartijn 			.data.int32 = 3
286084417368Smartijn 		}
286184417368Smartijn 	};
286284417368Smartijn 	struct searchrange searchrange[] = {
286384417368Smartijn 		{
286484417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 0),
286584417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 26)
286684417368Smartijn 		},
286784417368Smartijn 		{
286884417368Smartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 1),
286984417368Smartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 26)
287084417368Smartijn 		}
287184417368Smartijn 	};
287284417368Smartijn 	int32_t requestid;
287384417368Smartijn 	char buf[1024];
287484417368Smartijn 	size_t n;
287584417368Smartijn 
287684417368Smartijn 	ax_s = agentx_connect(axsocket);
287784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
287884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 25), __func__);
287984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
288084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 25), 0);
288184417368Smartijn 
288284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
288384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
288484417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 2);
288584417368Smartijn 
288684417368Smartijn 	varbind[0].name.subid[varbind[0].name.n_subid - 1]++;
288784417368Smartijn 	varbind[1].name.subid[varbind[1].name.n_subid - 1]++;
288884417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_INTEGER;
288984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
289084417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, searchrange,
289184417368Smartijn 	    varbind, 2);
289284417368Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 3);
289384417368Smartijn 	varbind[0].type = varbind[1].type = TYPE_NULL;
289484417368Smartijn 	varbind[0].name = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 0),
289584417368Smartijn 	varbind[1].name = OID_STRUCT(MIB_BACKEND_GETNEXT, 25, 1),
289684417368Smartijn 
289784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 2,
289884417368Smartijn 	    varbind, 2);
289984417368Smartijn }
290084417368Smartijn 
290184417368Smartijn void
backend_getnext_response_equal_end(void)2902dae64e9eSmartijn backend_getnext_response_equal_end(void)
2903dae64e9eSmartijn {
2904dae64e9eSmartijn 	struct sockaddr_storage ss;
2905dae64e9eSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
2906dae64e9eSmartijn 	socklen_t salen;
2907dae64e9eSmartijn 	int snmp_s, ax_s;
2908dae64e9eSmartijn 	uint32_t sessionid1, sessionid2;
2909dae64e9eSmartijn 	struct varbind varbind[] = {
2910dae64e9eSmartijn 		{
2911dae64e9eSmartijn 			.type = TYPE_NULL,
2912dae64e9eSmartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 26),
2913dae64e9eSmartijn 			.data.int32 = 1
2914dae64e9eSmartijn 		},
2915dae64e9eSmartijn 	};
2916dae64e9eSmartijn 	struct searchrange searchrange[] = {
2917dae64e9eSmartijn 		{
2918dae64e9eSmartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 26),
2919dae64e9eSmartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 26, 1, 1)
2920dae64e9eSmartijn 		},
2921dae64e9eSmartijn 	};
2922dae64e9eSmartijn 	int32_t requestid;
2923dae64e9eSmartijn 	char buf[1024];
2924dae64e9eSmartijn 	size_t n;
2925dae64e9eSmartijn 
2926dae64e9eSmartijn 	ax_s = agentx_connect(axsocket);
2927dae64e9eSmartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
2928dae64e9eSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 26, 1),
2929dae64e9eSmartijn 	    "backend_getnext_end_equal.1");
2930dae64e9eSmartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
2931dae64e9eSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 26, 2),
2932dae64e9eSmartijn 	    "backend_getnext_end_equal.2");
2933dae64e9eSmartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
2934dae64e9eSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 26), 0);
2935dae64e9eSmartijn 	agentx_register(ax_s, sessionid2, 0, 0, 127, 0,
2936dae64e9eSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 26, 1, 1), 0);
2937dae64e9eSmartijn 
2938dae64e9eSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
2939dae64e9eSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
2940dae64e9eSmartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 1);
2941dae64e9eSmartijn 
2942dae64e9eSmartijn 	/* Fool agentx_getnext_handle() */
2943dae64e9eSmartijn 	varbind[0].name.subid[varbind[0].name.n_subid++] = 1;
2944dae64e9eSmartijn 	varbind[0].type = TYPE_INTEGER;
2945dae64e9eSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
2946dae64e9eSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, searchrange,
2947dae64e9eSmartijn 	    varbind, 1);
2948dae64e9eSmartijn 	varbind[0].name = searchrange[0].end;
2949dae64e9eSmartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
2950dae64e9eSmartijn 	varbind[0].type = TYPE_NULL;
2951dae64e9eSmartijn 	varbind[0].name = OID_STRUCT(MIB_BACKEND_GETNEXT, 26),
2952dae64e9eSmartijn 
2953dae64e9eSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
2954dae64e9eSmartijn 	    varbind, 1);
2955dae64e9eSmartijn }
2956dae64e9eSmartijn 
2957dae64e9eSmartijn void
backend_getnext_instance_below_region_before_instance(void)2958096a942aSmartijn backend_getnext_instance_below_region_before_instance(void)
2959096a942aSmartijn {
2960096a942aSmartijn 	struct sockaddr_storage ss;
2961096a942aSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
2962096a942aSmartijn 	socklen_t salen;
2963096a942aSmartijn 	int snmp_s, ax_s;
2964096a942aSmartijn 	uint32_t sessionid1, sessionid2;
2965096a942aSmartijn 	struct varbind varbind[] = {
2966096a942aSmartijn 		{
2967096a942aSmartijn 			.type = TYPE_NULL,
2968096a942aSmartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 27),
2969096a942aSmartijn 			.data.int32 = 1
2970096a942aSmartijn 		},
2971096a942aSmartijn 	};
2972096a942aSmartijn 	struct searchrange searchrange[] = {
2973096a942aSmartijn 		{
2974096a942aSmartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 27),
2975096a942aSmartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 27, 1, 0)
2976096a942aSmartijn 		},
2977096a942aSmartijn 	};
2978096a942aSmartijn 	int32_t requestid;
2979096a942aSmartijn 	char buf[1024];
2980096a942aSmartijn 	size_t n;
2981096a942aSmartijn 
2982096a942aSmartijn 	ax_s = agentx_connect(axsocket);
2983096a942aSmartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
2984096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 27, 1),
2985096a942aSmartijn 	    "backend_getnext_instance_below_region_before_instance.1");
2986096a942aSmartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
2987096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 27, 2),
2988096a942aSmartijn 	    "backend_getnext_instance_below_region_before_instance.2");
2989096a942aSmartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
2990096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 27), 0);
2991096a942aSmartijn 	agentx_register(ax_s, sessionid2, 1, 0, 127, 0,
2992096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 27, 1, 0), 0);
2993096a942aSmartijn 
2994096a942aSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
2995096a942aSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
2996096a942aSmartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 1);
2997096a942aSmartijn 
2998096a942aSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
2999096a942aSmartijn 	varbind[0].type = TYPE_ENDOFMIBVIEW;
3000096a942aSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, searchrange,
3001096a942aSmartijn 	    varbind, 1);
3002096a942aSmartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
3003096a942aSmartijn 
3004096a942aSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
3005096a942aSmartijn 	varbind[0].name = searchrange[0].end;
3006096a942aSmartijn 	varbind[0].type = TYPE_INTEGER;
3007096a942aSmartijn 	searchrange[0].start = searchrange[0].end;
3008096a942aSmartijn 	searchrange[0].start.include = 1;
3009096a942aSmartijn 	searchrange[0].end.subid[searchrange[0].end.n_subid - 1]++;
3010096a942aSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid2, searchrange,
3011096a942aSmartijn 	    varbind, 1);
3012096a942aSmartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
3013096a942aSmartijn 
3014096a942aSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
3015096a942aSmartijn 	    varbind, 1);
3016096a942aSmartijn }
3017096a942aSmartijn 
3018096a942aSmartijn void
backend_getnext_instance_below_region_on_instance(void)3019096a942aSmartijn backend_getnext_instance_below_region_on_instance(void)
3020096a942aSmartijn {
3021096a942aSmartijn 	struct sockaddr_storage ss;
3022096a942aSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
3023096a942aSmartijn 	socklen_t salen;
3024096a942aSmartijn 	int snmp_s, ax_s;
3025096a942aSmartijn 	uint32_t sessionid1, sessionid2;
3026096a942aSmartijn 	struct varbind varbind[] = {
3027096a942aSmartijn 		{
3028096a942aSmartijn 			.type = TYPE_NULL,
3029096a942aSmartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 28, 1, 0),
3030096a942aSmartijn 			.data.int32 = 1
3031096a942aSmartijn 		},
3032096a942aSmartijn 	};
3033096a942aSmartijn 	struct searchrange searchrange[] = {
3034096a942aSmartijn 		{
3035096a942aSmartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 28, 1, 1),
3036096a942aSmartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 29)
3037096a942aSmartijn 		},
3038096a942aSmartijn 	};
3039096a942aSmartijn 	int32_t requestid;
3040096a942aSmartijn 	char buf[1024];
3041096a942aSmartijn 	size_t n;
3042096a942aSmartijn 
3043096a942aSmartijn 	ax_s = agentx_connect(axsocket);
3044096a942aSmartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
3045096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 28, 1),
3046096a942aSmartijn 	    "backend_getnext_instance_below_region_on_instance.1");
3047096a942aSmartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
3048096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 28, 2),
3049096a942aSmartijn 	    "backend_getnext_instance_below_region_on_instance.2");
3050096a942aSmartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
3051096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 28), 0);
3052096a942aSmartijn 	agentx_register(ax_s, sessionid2, 1, 0, 127, 0,
3053096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 28, 1, 0), 0);
3054096a942aSmartijn 
3055096a942aSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
3056096a942aSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
3057096a942aSmartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 1);
3058096a942aSmartijn 
3059096a942aSmartijn 	searchrange[0].start.include = 1;
3060096a942aSmartijn 	varbind[0].name = searchrange[0].start;
3061096a942aSmartijn 	varbind[0].type = TYPE_INTEGER;
3062096a942aSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
3063096a942aSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, searchrange,
3064096a942aSmartijn 	    varbind, 1);
3065096a942aSmartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
3066096a942aSmartijn 
3067096a942aSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
3068096a942aSmartijn 	    varbind, 1);
3069096a942aSmartijn }
3070096a942aSmartijn 
3071096a942aSmartijn void
backend_getnext_instance_below_region_below_instance(void)3072096a942aSmartijn backend_getnext_instance_below_region_below_instance(void)
3073096a942aSmartijn {
3074096a942aSmartijn 	struct sockaddr_storage ss;
3075096a942aSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
3076096a942aSmartijn 	socklen_t salen;
3077096a942aSmartijn 	int snmp_s, ax_s;
3078096a942aSmartijn 	uint32_t sessionid1, sessionid2;
3079096a942aSmartijn 	struct varbind varbind[] = {
3080096a942aSmartijn 		{
3081096a942aSmartijn 			.type = TYPE_NULL,
3082096a942aSmartijn 			.name = OID_STRUCT(MIB_BACKEND_GETNEXT, 29, 1, 0, 1),
3083096a942aSmartijn 			.data.int32 = 1
3084096a942aSmartijn 		},
3085096a942aSmartijn 	};
3086096a942aSmartijn 	struct searchrange searchrange[] = {
3087096a942aSmartijn 		{
3088096a942aSmartijn 			.start = OID_STRUCT(MIB_BACKEND_GETNEXT, 29, 1, 1),
3089096a942aSmartijn 			.end = OID_STRUCT(MIB_BACKEND_GETNEXT, 30)
3090096a942aSmartijn 		},
3091096a942aSmartijn 	};
3092096a942aSmartijn 	int32_t requestid;
3093096a942aSmartijn 	char buf[1024];
3094096a942aSmartijn 	size_t n;
3095096a942aSmartijn 
3096096a942aSmartijn 	ax_s = agentx_connect(axsocket);
3097096a942aSmartijn 	sessionid1 = agentx_open(ax_s, 0, 0,
3098096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 29, 1),
3099096a942aSmartijn 	    "backend_getnext_instance_below_region_below_instance.1");
3100096a942aSmartijn 	sessionid2 = agentx_open(ax_s, 0, 0,
3101096a942aSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETNEXT, 29, 2),
3102096a942aSmartijn 	    "backend_getnext_instance_below_region_below_instance.2");
3103096a942aSmartijn 	agentx_register(ax_s, sessionid1, 0, 0, 127, 0,
3104096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 29), 0);
3105096a942aSmartijn 	agentx_register(ax_s, sessionid2, 1, 0, 127, 0,
3106096a942aSmartijn 	    OID_ARG(MIB_BACKEND_GETNEXT, 29, 1, 0), 0);
3107096a942aSmartijn 
3108096a942aSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
3109096a942aSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
3110096a942aSmartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, varbind, 1);
3111096a942aSmartijn 
3112096a942aSmartijn 	searchrange[0].start.include = 1;
3113096a942aSmartijn 	varbind[0].name = searchrange[0].start;
3114096a942aSmartijn 	varbind[0].type = TYPE_INTEGER;
3115096a942aSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
3116096a942aSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid1, searchrange,
3117096a942aSmartijn 	    varbind, 1);
3118096a942aSmartijn 	agentx_response(ax_s, buf, NOERROR, 0, varbind, 1);
3119096a942aSmartijn 
3120096a942aSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
3121096a942aSmartijn 	    varbind, 1);
3122096a942aSmartijn }
3123096a942aSmartijn 
3124096a942aSmartijn void
backend_getbulk_nonrep_zero_maxrep_one(void)312584417368Smartijn backend_getbulk_nonrep_zero_maxrep_one(void)
312684417368Smartijn {
312784417368Smartijn 	struct sockaddr_storage ss;
312884417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
312984417368Smartijn 	socklen_t salen;
313084417368Smartijn 	int snmp_s, ax_s;
313184417368Smartijn 	uint32_t sessionid;
313284417368Smartijn 	struct varbind request = {
313384417368Smartijn 		.type = TYPE_NULL,
313484417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETBULK, 1)
313584417368Smartijn 	}, ax_request[] = {
313684417368Smartijn 		{
313784417368Smartijn 			.type = TYPE_INTEGER,
313884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 1, 0),
313984417368Smartijn 			.data.int32 = 1
314084417368Smartijn 		}
314184417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
314284417368Smartijn 	int32_t requestid;
314384417368Smartijn 	char buf[1024];
314484417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
314584417368Smartijn 
314684417368Smartijn 	ax_s = agentx_connect(axsocket);
314784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
314884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 1), __func__);
314984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
315084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 1), 0);
315184417368Smartijn 
315284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
315384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
315484417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 1, &request, 1);
315584417368Smartijn 
315684417368Smartijn 	memcpy(response, ax_request, sizeof(ax_request));
315784417368Smartijn 	while (nvarbind > 0) {
315884417368Smartijn 		n = agentx_read(ax_s, buf, sizeof(buf), 1000);
315984417368Smartijn 		nout = agentx_getbulk_handle(__func__, buf, n, 0,
316084417368Smartijn 		    sessionid, ax_request, nvarbind, ax_response);
316184417368Smartijn 		agentx_response(ax_s, buf, NOERROR, 0, ax_response, nout);
316284417368Smartijn 		nvarbind -= nout;
316384417368Smartijn 	}
316484417368Smartijn 
316584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
316684417368Smartijn 	    response, nitems(response));
316784417368Smartijn }
316884417368Smartijn 
316984417368Smartijn void
backend_getbulk_nonrep_zero_maxrep_two(void)317084417368Smartijn backend_getbulk_nonrep_zero_maxrep_two(void)
317184417368Smartijn {
317284417368Smartijn 	struct sockaddr_storage ss;
317384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
317484417368Smartijn 	socklen_t salen;
317584417368Smartijn 	int snmp_s, ax_s;
317684417368Smartijn 	uint32_t sessionid;
317784417368Smartijn 	struct varbind request = {
317884417368Smartijn 		.type = TYPE_NULL,
317984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETBULK, 2)
318084417368Smartijn 	}, ax_request[] = {
318184417368Smartijn 		{
318284417368Smartijn 			.type = TYPE_INTEGER,
318384417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 2, 1),
318484417368Smartijn 			.data.int32 = 1
318584417368Smartijn 		},
318684417368Smartijn 		{
318784417368Smartijn 			.type = TYPE_INTEGER,
318884417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 2, 2),
318984417368Smartijn 			.data.int32 = 2
319084417368Smartijn 		}
319184417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
319284417368Smartijn 	int32_t requestid;
319384417368Smartijn 	char buf[1024];
319484417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
319584417368Smartijn 
319684417368Smartijn 	ax_s = agentx_connect(axsocket);
319784417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
319884417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 2), __func__);
319984417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
320084417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 2), 0);
320184417368Smartijn 
320284417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
320384417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
320484417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, &request, 1);
320584417368Smartijn 
320684417368Smartijn 	memcpy(response, ax_request, sizeof(ax_request));
320784417368Smartijn 	while (nvarbind > 0) {
320884417368Smartijn 		n = agentx_read(ax_s, buf, sizeof(buf), 1000);
320984417368Smartijn 		nout = agentx_getbulk_handle(__func__, buf, n, 0,
321084417368Smartijn 		    sessionid, ax_request, nvarbind, ax_response);
321184417368Smartijn 		agentx_response(ax_s, buf, NOERROR, 0, ax_response, nout);
321284417368Smartijn 		nvarbind -= nout;
321384417368Smartijn 	}
321484417368Smartijn 
321584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
321684417368Smartijn 	    response, nitems(response));
321784417368Smartijn }
321884417368Smartijn 
321984417368Smartijn void
backend_getbulk_nonrep_one_maxrep_one(void)322084417368Smartijn backend_getbulk_nonrep_one_maxrep_one(void)
322184417368Smartijn {
322284417368Smartijn 	struct sockaddr_storage ss;
322384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
322484417368Smartijn 	socklen_t salen;
322584417368Smartijn 	int snmp_s, ax_s;
322684417368Smartijn 	uint32_t sessionid;
322784417368Smartijn 	struct varbind request[] = {
322884417368Smartijn 		{
322984417368Smartijn 			.type = TYPE_NULL,
323084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 3, 1)
323184417368Smartijn 		},
323284417368Smartijn 		{
323384417368Smartijn 			.type = TYPE_NULL,
323484417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 3, 2)
323584417368Smartijn 		}
323684417368Smartijn 	}, ax_request[] = {
323784417368Smartijn 		{
323884417368Smartijn 			.type = TYPE_INTEGER,
323984417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 3, 1, 0),
324084417368Smartijn 			.data.int32 = 1
324184417368Smartijn 		},
324284417368Smartijn 		{
324384417368Smartijn 			.type = TYPE_INTEGER,
324484417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 3, 2, 0),
324584417368Smartijn 			.data.int32 = 2
324684417368Smartijn 		}
324784417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
324884417368Smartijn 	int32_t requestid;
324984417368Smartijn 	char buf[1024];
325084417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
325184417368Smartijn 
325284417368Smartijn 	ax_s = agentx_connect(axsocket);
325384417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
325484417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 3), __func__);
325584417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
325684417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 3), 0);
325784417368Smartijn 
325884417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
325984417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
326084417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 1, 1, request, 2);
326184417368Smartijn 
326284417368Smartijn 	memcpy(response, ax_request, sizeof(ax_request));
326384417368Smartijn 	while (nvarbind > 0) {
326484417368Smartijn 		n = agentx_read(ax_s, buf, sizeof(buf), 1000);
326584417368Smartijn 		nout = agentx_getbulk_handle(__func__, buf, n, 0,
326684417368Smartijn 		    sessionid, ax_request, nvarbind, ax_response);
326784417368Smartijn 		agentx_response(ax_s, buf, NOERROR, 0, ax_response, nout);
326884417368Smartijn 		nvarbind -= nout;
326984417368Smartijn 	}
327084417368Smartijn 
327184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
327284417368Smartijn 	    response, nitems(response));
327384417368Smartijn }
327484417368Smartijn 
327584417368Smartijn void
backend_getbulk_nonrep_one_maxrep_two(void)327684417368Smartijn backend_getbulk_nonrep_one_maxrep_two(void)
327784417368Smartijn {
327884417368Smartijn 	struct sockaddr_storage ss;
327984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
328084417368Smartijn 	socklen_t salen;
328184417368Smartijn 	int snmp_s, ax_s;
328284417368Smartijn 	uint32_t sessionid;
328384417368Smartijn 	struct varbind request[] = {
328484417368Smartijn 		{
328584417368Smartijn 			.type = TYPE_NULL,
328684417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 4, 1)
328784417368Smartijn 		},
328884417368Smartijn 		{
328984417368Smartijn 			.type = TYPE_NULL,
329084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 4, 2)
329184417368Smartijn 		}
329284417368Smartijn 	}, ax_request[] = {
329384417368Smartijn 		{
329484417368Smartijn 			.type = TYPE_INTEGER,
329584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 4, 1, 0),
329684417368Smartijn 			.data.int32 = 1
329784417368Smartijn 		},
329884417368Smartijn 		{
329984417368Smartijn 			.type = TYPE_INTEGER,
330084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 4, 2, 2),
330184417368Smartijn 			.data.int32 = 2
330284417368Smartijn 		},
330384417368Smartijn 		{
330484417368Smartijn 			.type = TYPE_INTEGER,
330584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 4, 2, 3),
330684417368Smartijn 			.data.int32 = 3
330784417368Smartijn 		}
330884417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
330984417368Smartijn 	int32_t requestid;
331084417368Smartijn 	char buf[1024];
331184417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
331284417368Smartijn 
331384417368Smartijn 	ax_s = agentx_connect(axsocket);
331484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
331584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 4), __func__);
331684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
331784417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 4), 0);
331884417368Smartijn 
331984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
332084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
332184417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 1, 2, request, 2);
332284417368Smartijn 
332384417368Smartijn 	memcpy(response, ax_request, sizeof(ax_request));
332484417368Smartijn 	while (nvarbind > 0) {
332584417368Smartijn 		n = agentx_read(ax_s, buf, sizeof(buf), 1000);
332684417368Smartijn 		nout = agentx_getbulk_handle(__func__, buf, n, 0,
332784417368Smartijn 		    sessionid, ax_request, nvarbind, ax_response);
332884417368Smartijn 		agentx_response(ax_s, buf, NOERROR, 0, ax_response, nout);
332984417368Smartijn 		nvarbind -= nout;
333084417368Smartijn 	}
333184417368Smartijn 
333284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
333384417368Smartijn 	    response, nitems(response));
333484417368Smartijn }
333584417368Smartijn 
333684417368Smartijn void
backend_getbulk_nonrep_two_maxrep_two(void)333784417368Smartijn backend_getbulk_nonrep_two_maxrep_two(void)
333884417368Smartijn {
333984417368Smartijn 	struct sockaddr_storage ss;
334084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
334184417368Smartijn 	socklen_t salen;
334284417368Smartijn 	int snmp_s, ax_s;
334384417368Smartijn 	uint32_t sessionid;
334484417368Smartijn 	struct varbind request[] = {
334584417368Smartijn 		{
334684417368Smartijn 			.type = TYPE_NULL,
334784417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 1)
334884417368Smartijn 		},
334984417368Smartijn 		{
335084417368Smartijn 			.type = TYPE_NULL,
335184417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 2)
335284417368Smartijn 		},
335384417368Smartijn 		{
335484417368Smartijn 			.type = TYPE_NULL,
335584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 3)
335684417368Smartijn 		}
335784417368Smartijn 	}, ax_request[] = {
335884417368Smartijn 		{
335984417368Smartijn 			.type = TYPE_INTEGER,
336084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 1, 0),
336184417368Smartijn 			.data.int32 = 1
336284417368Smartijn 		},
336384417368Smartijn 		{
336484417368Smartijn 			.type = TYPE_INTEGER,
336584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 2, 0),
336684417368Smartijn 			.data.int32 = 2
336784417368Smartijn 		},
336884417368Smartijn 		{
336984417368Smartijn 			.type = TYPE_INTEGER,
337084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 3, 3),
337184417368Smartijn 			.data.int32 = 3
337284417368Smartijn 		},
337384417368Smartijn 		{
337484417368Smartijn 			.type = TYPE_INTEGER,
337584417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 5, 3, 4),
337684417368Smartijn 			.data.int32 = 4
337784417368Smartijn 		}
337884417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
337984417368Smartijn 	int32_t requestid;
338084417368Smartijn 	char buf[1024];
338184417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
338284417368Smartijn 
338384417368Smartijn 	ax_s = agentx_connect(axsocket);
338484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
338584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 5), __func__);
338684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
338784417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 5), 0);
338884417368Smartijn 
338984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
339084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
339184417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 2, 2, request, 3);
339284417368Smartijn 
339384417368Smartijn 	memcpy(response, ax_request, sizeof(ax_request));
339484417368Smartijn 	while (nvarbind > 0) {
339584417368Smartijn 		n = agentx_read(ax_s, buf, sizeof(buf), 1000);
339684417368Smartijn 		nout = agentx_getbulk_handle(__func__, buf, n, 0,
339784417368Smartijn 		    sessionid, ax_request, nvarbind, ax_response);
339884417368Smartijn 		agentx_response(ax_s, buf, NOERROR, 0, ax_response, nout);
339984417368Smartijn 		nvarbind -= nout;
340084417368Smartijn 	}
340184417368Smartijn 
340284417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
340384417368Smartijn 	    response, nitems(response));
340484417368Smartijn }
340584417368Smartijn 
340684417368Smartijn void
backend_getbulk_nonrep_negative(void)340784417368Smartijn backend_getbulk_nonrep_negative(void)
340884417368Smartijn {
340984417368Smartijn 	struct sockaddr_storage ss;
341084417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
341184417368Smartijn 	socklen_t salen;
341284417368Smartijn 	int snmp_s, ax_s;
341384417368Smartijn 	uint32_t sessionid;
341484417368Smartijn 	struct varbind request = {
341584417368Smartijn 		.type = TYPE_NULL,
341684417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_GETBULK, 6)
341784417368Smartijn 	}, ax_request[] = {
341884417368Smartijn 		{
341984417368Smartijn 			.type = TYPE_INTEGER,
342084417368Smartijn 			.name = OID_STRUCT(MIB_BACKEND_GETBULK, 6),
342184417368Smartijn 			.data.int32 = 1
342284417368Smartijn 		}
342384417368Smartijn 	}, ax_response[nitems(ax_request)], response[nitems(ax_request)];
342484417368Smartijn 	int32_t requestid;
342584417368Smartijn 	char buf[1024];
342684417368Smartijn 	size_t n, nvarbind = nitems(ax_request), nout;
342784417368Smartijn 
342884417368Smartijn 	ax_s = agentx_connect(axsocket);
342984417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
343084417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 6), __func__);
343184417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
343284417368Smartijn 	    OID_ARG(MIB_BACKEND_GETBULK, 6), 0);
343384417368Smartijn 
343484417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
343584417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
343684417368Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, -1, 1, &request, 1);
343784417368Smartijn 
343884417368Smartijn 	agentx_timeout(ax_s, 1000);
343984417368Smartijn 	snmp_timeout(snmp_s, 1);
344084417368Smartijn }
344184417368Smartijn 
34422ccef039Smartijn /* Assume that everything is registered under 1.3.* */
34432ccef039Smartijn void
backend_getbulk_endofmibview(void)34442ccef039Smartijn backend_getbulk_endofmibview(void)
34452ccef039Smartijn {
34462ccef039Smartijn 	struct sockaddr_storage ss;
34472ccef039Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
34482ccef039Smartijn 	socklen_t salen;
34492ccef039Smartijn 	int snmp_s, ax_s;
34502ccef039Smartijn 	uint32_t sessionid;
34512ccef039Smartijn 	struct varbind varbind = {
34522ccef039Smartijn 		.type = TYPE_NULL,
34532ccef039Smartijn 		.name = OID_STRUCT(2, 0),
34542ccef039Smartijn 	};
34552ccef039Smartijn 	struct searchrange searchrange = {
34562ccef039Smartijn 		.start = OID_STRUCT(2, 0),
34572ccef039Smartijn 		.end = OID_STRUCT(2, 1)
34582ccef039Smartijn 	};
34592ccef039Smartijn 	int32_t requestid;
34602ccef039Smartijn 	char buf[1024];
34612ccef039Smartijn 	size_t n;
34622ccef039Smartijn 
34632ccef039Smartijn 	ax_s = agentx_connect(axsocket);
34642ccef039Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
34652ccef039Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 7), __func__);
34662ccef039Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
34672ccef039Smartijn 	    OID_ARG(2, 0), 0);
34682ccef039Smartijn 
34692ccef039Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
34702ccef039Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
34712ccef039Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, &varbind, 1);
34722ccef039Smartijn 
34732ccef039Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
34742ccef039Smartijn 	varbind.type = TYPE_ENDOFMIBVIEW;
34752ccef039Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
34762ccef039Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
34772ccef039Smartijn 	    &varbind, 1);
34782ccef039Smartijn 	varbind.name.n_subid--;
34792ccef039Smartijn 
34802ccef039Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &varbind, 1);
34812ccef039Smartijn 
34822ccef039Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
34832ccef039Smartijn 	    &varbind, 1);
34842ccef039Smartijn }
34852ccef039Smartijn 
34862ccef039Smartijn void
backend_getbulk_endofmibview_second_rep(void)34872ccef039Smartijn backend_getbulk_endofmibview_second_rep(void)
34882ccef039Smartijn {
34892ccef039Smartijn 	struct sockaddr_storage ss;
34902ccef039Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
34912ccef039Smartijn 	socklen_t salen;
34922ccef039Smartijn 	int snmp_s, ax_s;
34932ccef039Smartijn 	uint32_t sessionid;
34942ccef039Smartijn 	struct varbind request[] = {
34952ccef039Smartijn 		{
34962ccef039Smartijn 			.type = TYPE_NULL,
34972ccef039Smartijn 			.name = OID_STRUCT(2 ,0),
34982ccef039Smartijn 			.data.int32 = 1
34992ccef039Smartijn 		},
35002ccef039Smartijn 		{
35012ccef039Smartijn 			.type = TYPE_ENDOFMIBVIEW,
35022ccef039Smartijn 			.name = OID_STRUCT(2, 0, 0),
35032ccef039Smartijn 		}
35042ccef039Smartijn 	};
35052ccef039Smartijn 	struct searchrange searchrange = {
35062ccef039Smartijn 		.start = OID_STRUCT(2, 0),
35072ccef039Smartijn 		.end = OID_STRUCT(2, 1)
35082ccef039Smartijn 	};
35092ccef039Smartijn 	int32_t requestid;
35102ccef039Smartijn 	char buf[1024];
35112ccef039Smartijn 	size_t n;
35122ccef039Smartijn 
35132ccef039Smartijn 	ax_s = agentx_connect(axsocket);
35142ccef039Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
35152ccef039Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 8), __func__);
35162ccef039Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
35172ccef039Smartijn 	    OID_ARG(2, 0), 0);
35182ccef039Smartijn 
35192ccef039Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
35202ccef039Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
35212ccef039Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, request, 1);
35222ccef039Smartijn 
35232ccef039Smartijn 	request[0].name.subid[request[0].name.n_subid++] = 0;
35242ccef039Smartijn 	request[0].type = TYPE_INTEGER;
35252ccef039Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
35262ccef039Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
35272ccef039Smartijn 	    request, 1);
35282ccef039Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, request, 1);
35292ccef039Smartijn 
35302ccef039Smartijn 	searchrange.start = request[0].name;
35312ccef039Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
35322ccef039Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange,
35332ccef039Smartijn 	    &request[1], 1);
35342ccef039Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &request[1], 1);
35352ccef039Smartijn 
35362ccef039Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
35372ccef039Smartijn 	    request, 2);
35382ccef039Smartijn }
35392ccef039Smartijn 
35402ccef039Smartijn void
backend_getbulk_endofmibview_two_varbinds(void)35412ccef039Smartijn backend_getbulk_endofmibview_two_varbinds(void)
35422ccef039Smartijn {
35432ccef039Smartijn 	struct sockaddr_storage ss;
35442ccef039Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
35452ccef039Smartijn 	socklen_t salen;
35462ccef039Smartijn 	int snmp_s, ax_s;
35472ccef039Smartijn 	uint32_t sessionid;
35482ccef039Smartijn 	struct varbind request[] = {
35492ccef039Smartijn 		{
35502ccef039Smartijn 			.type = TYPE_NULL,
35512ccef039Smartijn 			.name = OID_STRUCT(2 ,0),
35522ccef039Smartijn 			.data.int32 = 1
35532ccef039Smartijn 		},
35542ccef039Smartijn 		{
35552ccef039Smartijn 			.type = TYPE_NULL,
35562ccef039Smartijn 			.name = OID_STRUCT(2, 0, 0),
35572ccef039Smartijn 		},
35582ccef039Smartijn 		{
35592ccef039Smartijn 			.type = TYPE_ENDOFMIBVIEW,
35602ccef039Smartijn 			.name = OID_STRUCT(2, 0, 0),
35612ccef039Smartijn 		},
35622ccef039Smartijn 		{
35632ccef039Smartijn 			.type = TYPE_ENDOFMIBVIEW,
35642ccef039Smartijn 			.name = OID_STRUCT(2, 0, 0),
35652ccef039Smartijn 		}
35662ccef039Smartijn 	};
35672ccef039Smartijn 	struct searchrange searchrange[] = {
35682ccef039Smartijn 		{
35692ccef039Smartijn 			.start = OID_STRUCT(2, 0),
35702ccef039Smartijn 			.end = OID_STRUCT(2, 1)
35712ccef039Smartijn 		},
35722ccef039Smartijn 		{
35732ccef039Smartijn 			.start = OID_STRUCT(2, 0, 0),
35742ccef039Smartijn 			.end = OID_STRUCT(2, 1)
35752ccef039Smartijn 		},
35762ccef039Smartijn 	};
35772ccef039Smartijn 	int32_t requestid;
35782ccef039Smartijn 	char buf[1024];
35792ccef039Smartijn 	size_t n;
35802ccef039Smartijn 
35812ccef039Smartijn 	ax_s = agentx_connect(axsocket);
35822ccef039Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
35832ccef039Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_GETBULK, 9), __func__);
35842ccef039Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
35852ccef039Smartijn 	    OID_ARG(2, 0), 0);
35862ccef039Smartijn 
35872ccef039Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
35882ccef039Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
35892ccef039Smartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, request, 2);
35902ccef039Smartijn 
35912ccef039Smartijn 	request[0].name.subid[request[0].name.n_subid++] = 0;
35922ccef039Smartijn 	request[0].type = TYPE_INTEGER;
35932ccef039Smartijn 	request[1].type = TYPE_ENDOFMIBVIEW;
35942ccef039Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
35952ccef039Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, searchrange,
35962ccef039Smartijn 	    request, 2);
35972ccef039Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, request, 2);
35982ccef039Smartijn 
35992ccef039Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
36002ccef039Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, &searchrange[1],
36012ccef039Smartijn 	    &request[1], 1);
36022ccef039Smartijn 	agentx_response(ax_s, buf, NOERROR, 0, &request[1], 1);
36032ccef039Smartijn 
36042ccef039Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOERROR, 0,
36052ccef039Smartijn 	    request, 4);
36062ccef039Smartijn }
36072ccef039Smartijn 
360884417368Smartijn void
backend_error_get_toobig(void)360984417368Smartijn backend_error_get_toobig(void)
361084417368Smartijn {
361184417368Smartijn 	struct sockaddr_storage ss;
361284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
361384417368Smartijn 	socklen_t salen;
361484417368Smartijn 	int snmp_s, ax_s;
361584417368Smartijn 	uint32_t sessionid;
361684417368Smartijn 	struct varbind varbind = {
361784417368Smartijn 		.type = TYPE_NULL,
361884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 1, 0),
361984417368Smartijn 	};
362084417368Smartijn 	int32_t requestid;
362184417368Smartijn 	char buf[1024];
362284417368Smartijn 	size_t n;
362384417368Smartijn 
362484417368Smartijn 	ax_s = agentx_connect(axsocket);
362584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
362684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 1), __func__);
362784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
362884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 1), 0);
362984417368Smartijn 
363084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
363184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
363284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
363384417368Smartijn 
363484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
363584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
363684417368Smartijn 
363784417368Smartijn 	agentx_response(ax_s, buf, TOOBIG, 1, &varbind, 1);
363884417368Smartijn 
363984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, TOOBIG, 1,
364084417368Smartijn 	    &varbind, 1);
364184417368Smartijn }
364284417368Smartijn 
364384417368Smartijn void
backend_error_get_nosuchname(void)364484417368Smartijn backend_error_get_nosuchname(void)
364584417368Smartijn {
364684417368Smartijn 	struct sockaddr_storage ss;
364784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
364884417368Smartijn 	socklen_t salen;
364984417368Smartijn 	int snmp_s, ax_s;
365084417368Smartijn 	uint32_t sessionid;
365184417368Smartijn 	struct varbind varbind = {
365284417368Smartijn 		.type = TYPE_NULL,
365384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 2, 0),
365484417368Smartijn 	};
365584417368Smartijn 	int32_t requestid;
365684417368Smartijn 	char buf[1024];
365784417368Smartijn 	size_t n;
365884417368Smartijn 
365984417368Smartijn 	ax_s = agentx_connect(axsocket);
366084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
366184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 2), __func__);
366284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
366384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 2), 0);
366484417368Smartijn 
366584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
366684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
366784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
366884417368Smartijn 
366984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
367084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
367184417368Smartijn 
367284417368Smartijn 	agentx_response(ax_s, buf, NOSUCHNAME, 1, &varbind, 1);
367384417368Smartijn 
367484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOSUCHNAME, 1,
367584417368Smartijn 	    &varbind, 1);
367684417368Smartijn }
367784417368Smartijn 
367884417368Smartijn void
backend_error_get_badvalue(void)367984417368Smartijn backend_error_get_badvalue(void)
368084417368Smartijn {
368184417368Smartijn 	struct sockaddr_storage ss;
368284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
368384417368Smartijn 	socklen_t salen;
368484417368Smartijn 	int snmp_s, ax_s;
368584417368Smartijn 	uint32_t sessionid;
368684417368Smartijn 	struct varbind varbind = {
368784417368Smartijn 		.type = TYPE_NULL,
368884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 3, 0),
368984417368Smartijn 	};
369084417368Smartijn 	int32_t requestid;
369184417368Smartijn 	char buf[1024];
369284417368Smartijn 	size_t n;
369384417368Smartijn 
369484417368Smartijn 	ax_s = agentx_connect(axsocket);
369584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
369684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 3), __func__);
369784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
369884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 3), 0);
369984417368Smartijn 
370084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
370184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
370284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
370384417368Smartijn 
370484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
370584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
370684417368Smartijn 
370784417368Smartijn 	agentx_response(ax_s, buf, BADVALUE, 1, &varbind, 1);
370884417368Smartijn 
370984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
371084417368Smartijn 	    &varbind, 1);
371184417368Smartijn }
371284417368Smartijn 
371384417368Smartijn void
backend_error_get_readonly(void)371484417368Smartijn backend_error_get_readonly(void)
371584417368Smartijn {
371684417368Smartijn 	struct sockaddr_storage ss;
371784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
371884417368Smartijn 	socklen_t salen;
371984417368Smartijn 	int snmp_s, ax_s;
372084417368Smartijn 	uint32_t sessionid;
372184417368Smartijn 	struct varbind varbind = {
372284417368Smartijn 		.type = TYPE_NULL,
372384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 4, 0),
372484417368Smartijn 	};
372584417368Smartijn 	int32_t requestid;
372684417368Smartijn 	char buf[1024];
372784417368Smartijn 	size_t n;
372884417368Smartijn 
372984417368Smartijn 	ax_s = agentx_connect(axsocket);
373084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
373184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 4), __func__);
373284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
373384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 4), 0);
373484417368Smartijn 
373584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
373684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
373784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
373884417368Smartijn 
373984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
374084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
374184417368Smartijn 
374284417368Smartijn 	agentx_response(ax_s, buf, READONLY, 1, &varbind, 1);
374384417368Smartijn 
374484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
374584417368Smartijn 	    &varbind, 1);
374684417368Smartijn }
374784417368Smartijn 
374884417368Smartijn void
backend_error_get_generr(void)374984417368Smartijn backend_error_get_generr(void)
375084417368Smartijn {
375184417368Smartijn 	struct sockaddr_storage ss;
375284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
375384417368Smartijn 	socklen_t salen;
375484417368Smartijn 	int snmp_s, ax_s;
375584417368Smartijn 	uint32_t sessionid;
375684417368Smartijn 	struct varbind varbind = {
375784417368Smartijn 		.type = TYPE_NULL,
375884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 5, 0),
375984417368Smartijn 	};
376084417368Smartijn 	int32_t requestid;
376184417368Smartijn 	char buf[1024];
376284417368Smartijn 	size_t n;
376384417368Smartijn 
376484417368Smartijn 	ax_s = agentx_connect(axsocket);
376584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
376684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 5), __func__);
376784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
376884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 5), 0);
376984417368Smartijn 
377084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
377184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
377284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
377384417368Smartijn 
377484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
377584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
377684417368Smartijn 
377784417368Smartijn 	agentx_response(ax_s, buf, GENERR, 1, &varbind, 1);
377884417368Smartijn 
377984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
378084417368Smartijn 	    &varbind, 1);
378184417368Smartijn }
378284417368Smartijn 
378384417368Smartijn void
backend_error_get_noaccess(void)378484417368Smartijn backend_error_get_noaccess(void)
378584417368Smartijn {
378684417368Smartijn 	struct sockaddr_storage ss;
378784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
378884417368Smartijn 	socklen_t salen;
378984417368Smartijn 	int snmp_s, ax_s;
379084417368Smartijn 	uint32_t sessionid;
379184417368Smartijn 	struct varbind varbind = {
379284417368Smartijn 		.type = TYPE_NULL,
379384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 6, 0),
379484417368Smartijn 	};
379584417368Smartijn 	int32_t requestid;
379684417368Smartijn 	char buf[1024];
379784417368Smartijn 	size_t n;
379884417368Smartijn 
379984417368Smartijn 	ax_s = agentx_connect(axsocket);
380084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
380184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 6), __func__);
380284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
380384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 5), 0);
380484417368Smartijn 
380584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
380684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
380784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
380884417368Smartijn 
380984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
381084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
381184417368Smartijn 
381284417368Smartijn 	agentx_response(ax_s, buf, NOACCESS, 1, &varbind, 1);
381384417368Smartijn 
381484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
381584417368Smartijn 	    &varbind, 1);
381684417368Smartijn }
381784417368Smartijn 
381884417368Smartijn void
backend_error_get_wrongtype(void)381984417368Smartijn backend_error_get_wrongtype(void)
382084417368Smartijn {
382184417368Smartijn 	struct sockaddr_storage ss;
382284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
382384417368Smartijn 	socklen_t salen;
382484417368Smartijn 	int snmp_s, ax_s;
382584417368Smartijn 	uint32_t sessionid;
382684417368Smartijn 	struct varbind varbind = {
382784417368Smartijn 		.type = TYPE_NULL,
382884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 7, 0),
382984417368Smartijn 	};
383084417368Smartijn 	int32_t requestid;
383184417368Smartijn 	char buf[1024];
383284417368Smartijn 	size_t n;
383384417368Smartijn 
383484417368Smartijn 	ax_s = agentx_connect(axsocket);
383584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
383684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 7), __func__);
383784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
383884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 7), 0);
383984417368Smartijn 
384084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
384184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
384284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
384384417368Smartijn 
384484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
384584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
384684417368Smartijn 
384784417368Smartijn 	agentx_response(ax_s, buf, WRONGTYPE, 1, &varbind, 1);
384884417368Smartijn 
384984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
385084417368Smartijn 	    &varbind, 1);
385184417368Smartijn }
385284417368Smartijn 
385384417368Smartijn void
backend_error_get_wronglength(void)385484417368Smartijn backend_error_get_wronglength(void)
385584417368Smartijn {
385684417368Smartijn 	struct sockaddr_storage ss;
385784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
385884417368Smartijn 	socklen_t salen;
385984417368Smartijn 	int snmp_s, ax_s;
386084417368Smartijn 	uint32_t sessionid;
386184417368Smartijn 	struct varbind varbind = {
386284417368Smartijn 		.type = TYPE_NULL,
386384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 8, 0),
386484417368Smartijn 	};
386584417368Smartijn 	int32_t requestid;
386684417368Smartijn 	char buf[1024];
386784417368Smartijn 	size_t n;
386884417368Smartijn 
386984417368Smartijn 	ax_s = agentx_connect(axsocket);
387084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
387184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 8), __func__);
387284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
387384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 8), 0);
387484417368Smartijn 
387584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
387684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
387784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
387884417368Smartijn 
387984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
388084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
388184417368Smartijn 
388284417368Smartijn 	agentx_response(ax_s, buf, WRONGLENGTH, 1, &varbind, 1);
388384417368Smartijn 
388484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
388584417368Smartijn 	    &varbind, 1);
388684417368Smartijn }
388784417368Smartijn 
388884417368Smartijn void
backend_error_get_wrongencoding(void)388984417368Smartijn backend_error_get_wrongencoding(void)
389084417368Smartijn {
389184417368Smartijn 	struct sockaddr_storage ss;
389284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
389384417368Smartijn 	socklen_t salen;
389484417368Smartijn 	int snmp_s, ax_s;
389584417368Smartijn 	uint32_t sessionid;
389684417368Smartijn 	struct varbind varbind = {
389784417368Smartijn 		.type = TYPE_NULL,
389884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 9, 0),
389984417368Smartijn 	};
390084417368Smartijn 	int32_t requestid;
390184417368Smartijn 	char buf[1024];
390284417368Smartijn 	size_t n;
390384417368Smartijn 
390484417368Smartijn 	ax_s = agentx_connect(axsocket);
390584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
390684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 9), __func__);
390784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
390884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 9), 0);
390984417368Smartijn 
391084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
391184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
391284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
391384417368Smartijn 
391484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
391584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
391684417368Smartijn 
391784417368Smartijn 	agentx_response(ax_s, buf, WRONGENCODING, 1, &varbind, 1);
391884417368Smartijn 
391984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
392084417368Smartijn 	    &varbind, 1);
392184417368Smartijn }
392284417368Smartijn 
392384417368Smartijn void
backend_error_get_wrongvalue(void)392484417368Smartijn backend_error_get_wrongvalue(void)
392584417368Smartijn {
392684417368Smartijn 	struct sockaddr_storage ss;
392784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
392884417368Smartijn 	socklen_t salen;
392984417368Smartijn 	int snmp_s, ax_s;
393084417368Smartijn 	uint32_t sessionid;
393184417368Smartijn 	struct varbind varbind = {
393284417368Smartijn 		.type = TYPE_NULL,
393384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 10, 0),
393484417368Smartijn 	};
393584417368Smartijn 	int32_t requestid;
393684417368Smartijn 	char buf[1024];
393784417368Smartijn 	size_t n;
393884417368Smartijn 
393984417368Smartijn 	ax_s = agentx_connect(axsocket);
394084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
394184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 10), __func__);
394284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
394384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 10), 0);
394484417368Smartijn 
394584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
394684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
394784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
394884417368Smartijn 
394984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
395084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
395184417368Smartijn 
395284417368Smartijn 	agentx_response(ax_s, buf, WRONGVALUE, 1, &varbind, 1);
395384417368Smartijn 
395484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
395584417368Smartijn 	    &varbind, 1);
395684417368Smartijn }
395784417368Smartijn 
395884417368Smartijn void
backend_error_get_nocreation(void)395984417368Smartijn backend_error_get_nocreation(void)
396084417368Smartijn {
396184417368Smartijn 	struct sockaddr_storage ss;
396284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
396384417368Smartijn 	socklen_t salen;
396484417368Smartijn 	int snmp_s, ax_s;
396584417368Smartijn 	uint32_t sessionid;
396684417368Smartijn 	struct varbind varbind = {
396784417368Smartijn 		.type = TYPE_NULL,
396884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 11, 0),
396984417368Smartijn 	};
397084417368Smartijn 	int32_t requestid;
397184417368Smartijn 	char buf[1024];
397284417368Smartijn 	size_t n;
397384417368Smartijn 
397484417368Smartijn 	ax_s = agentx_connect(axsocket);
397584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
397684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 11), __func__);
397784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
397884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 11), 0);
397984417368Smartijn 
398084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
398184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
398284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
398384417368Smartijn 
398484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
398584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
398684417368Smartijn 
398784417368Smartijn 	agentx_response(ax_s, buf, NOCREATION, 1, &varbind, 1);
398884417368Smartijn 
398984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
399084417368Smartijn 	    &varbind, 1);
399184417368Smartijn }
399284417368Smartijn 
399384417368Smartijn void
backend_error_get_inconsistentvalue(void)399484417368Smartijn backend_error_get_inconsistentvalue(void)
399584417368Smartijn {
399684417368Smartijn 	struct sockaddr_storage ss;
399784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
399884417368Smartijn 	socklen_t salen;
399984417368Smartijn 	int snmp_s, ax_s;
400084417368Smartijn 	uint32_t sessionid;
400184417368Smartijn 	struct varbind varbind = {
400284417368Smartijn 		.type = TYPE_NULL,
400384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 12, 0),
400484417368Smartijn 	};
400584417368Smartijn 	int32_t requestid;
400684417368Smartijn 	char buf[1024];
400784417368Smartijn 	size_t n;
400884417368Smartijn 
400984417368Smartijn 	ax_s = agentx_connect(axsocket);
401084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
401184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 12), __func__);
401284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
401384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 12), 0);
401484417368Smartijn 
401584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
401684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
401784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
401884417368Smartijn 
401984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
402084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
402184417368Smartijn 
402284417368Smartijn 	agentx_response(ax_s, buf, INCONSISTENTVALUE, 1, &varbind, 1);
402384417368Smartijn 
402484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
402584417368Smartijn 	    &varbind, 1);
402684417368Smartijn }
402784417368Smartijn 
402884417368Smartijn void
backend_error_get_resourceunavailable(void)402984417368Smartijn backend_error_get_resourceunavailable(void)
403084417368Smartijn {
403184417368Smartijn 	struct sockaddr_storage ss;
403284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
403384417368Smartijn 	socklen_t salen;
403484417368Smartijn 	int snmp_s, ax_s;
403584417368Smartijn 	uint32_t sessionid;
403684417368Smartijn 	struct varbind varbind = {
403784417368Smartijn 		.type = TYPE_NULL,
403884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 13, 0),
403984417368Smartijn 	};
404084417368Smartijn 	int32_t requestid;
404184417368Smartijn 	char buf[1024];
404284417368Smartijn 	size_t n;
404384417368Smartijn 
404484417368Smartijn 	ax_s = agentx_connect(axsocket);
404584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
404684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 13), __func__);
404784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
404884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 13), 0);
404984417368Smartijn 
405084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
405184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
405284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
405384417368Smartijn 
405484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
405584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
405684417368Smartijn 
405784417368Smartijn 	agentx_response(ax_s, buf, WRONGVALUE, 1, &varbind, 1);
405884417368Smartijn 
405984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
406084417368Smartijn 	    &varbind, 1);
406184417368Smartijn }
406284417368Smartijn 
406384417368Smartijn void
backend_error_get_commitfailed(void)406484417368Smartijn backend_error_get_commitfailed(void)
406584417368Smartijn {
406684417368Smartijn 	struct sockaddr_storage ss;
406784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
406884417368Smartijn 	socklen_t salen;
406984417368Smartijn 	int snmp_s, ax_s;
407084417368Smartijn 	uint32_t sessionid;
407184417368Smartijn 	struct varbind varbind = {
407284417368Smartijn 		.type = TYPE_NULL,
407384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 14, 0),
407484417368Smartijn 	};
407584417368Smartijn 	int32_t requestid;
407684417368Smartijn 	char buf[1024];
407784417368Smartijn 	size_t n;
407884417368Smartijn 
407984417368Smartijn 	ax_s = agentx_connect(axsocket);
408084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
408184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 14), __func__);
408284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
408384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 14), 0);
408484417368Smartijn 
408584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
408684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
408784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
408884417368Smartijn 
408984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
409084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
409184417368Smartijn 
409284417368Smartijn 	agentx_response(ax_s, buf, COMMITFAILED, 1, &varbind, 1);
409384417368Smartijn 
409484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
409584417368Smartijn 	    &varbind, 1);
409684417368Smartijn }
409784417368Smartijn 
409884417368Smartijn void
backend_error_get_undofailed(void)409984417368Smartijn backend_error_get_undofailed(void)
410084417368Smartijn {
410184417368Smartijn 	struct sockaddr_storage ss;
410284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
410384417368Smartijn 	socklen_t salen;
410484417368Smartijn 	int snmp_s, ax_s;
410584417368Smartijn 	uint32_t sessionid;
410684417368Smartijn 	struct varbind varbind = {
410784417368Smartijn 		.type = TYPE_NULL,
410884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 15, 0),
410984417368Smartijn 	};
411084417368Smartijn 	int32_t requestid;
411184417368Smartijn 	char buf[1024];
411284417368Smartijn 	size_t n;
411384417368Smartijn 
411484417368Smartijn 	ax_s = agentx_connect(axsocket);
411584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
411684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 15), __func__);
411784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
411884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 15), 0);
411984417368Smartijn 
412084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
412184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
412284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
412384417368Smartijn 
412484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
412584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
412684417368Smartijn 
412784417368Smartijn 	agentx_response(ax_s, buf, UNDOFAILED, 1, &varbind, 1);
412884417368Smartijn 
412984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
413084417368Smartijn 	    &varbind, 1);
413184417368Smartijn }
413284417368Smartijn 
413384417368Smartijn void
backend_error_get_authorizationerror(void)413484417368Smartijn backend_error_get_authorizationerror(void)
413584417368Smartijn {
413684417368Smartijn 	struct sockaddr_storage ss;
413784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
413884417368Smartijn 	socklen_t salen;
413984417368Smartijn 	int snmp_s, ax_s;
414084417368Smartijn 	uint32_t sessionid;
414184417368Smartijn 	struct varbind varbind = {
414284417368Smartijn 		.type = TYPE_NULL,
414384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 16, 0),
414484417368Smartijn 	};
414584417368Smartijn 	int32_t requestid;
414684417368Smartijn 	char buf[1024];
414784417368Smartijn 	size_t n;
414884417368Smartijn 
414984417368Smartijn 	ax_s = agentx_connect(axsocket);
415084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
415184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 16), __func__);
415284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
415384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 16), 0);
415484417368Smartijn 
415584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
415684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
415784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
415884417368Smartijn 
415984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
416084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
416184417368Smartijn 
416284417368Smartijn 	agentx_response(ax_s, buf, AUTHORIZATIONERROR, 1, &varbind, 1);
416384417368Smartijn 
416484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, AUTHORIZATIONERROR, 1,
416584417368Smartijn 	    &varbind, 1);
416684417368Smartijn }
416784417368Smartijn 
416884417368Smartijn void
backend_error_get_notwritable(void)416984417368Smartijn backend_error_get_notwritable(void)
417084417368Smartijn {
417184417368Smartijn 	struct sockaddr_storage ss;
417284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
417384417368Smartijn 	socklen_t salen;
417484417368Smartijn 	int snmp_s, ax_s;
417584417368Smartijn 	uint32_t sessionid;
417684417368Smartijn 	struct varbind varbind = {
417784417368Smartijn 		.type = TYPE_NULL,
417884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 17, 0),
417984417368Smartijn 	};
418084417368Smartijn 	int32_t requestid;
418184417368Smartijn 	char buf[1024];
418284417368Smartijn 	size_t n;
418384417368Smartijn 
418484417368Smartijn 	ax_s = agentx_connect(axsocket);
418584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
418684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 17), __func__);
418784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
418884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 17), 0);
418984417368Smartijn 
419084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
419184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
419284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
419384417368Smartijn 
419484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
419584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
419684417368Smartijn 
419784417368Smartijn 	agentx_response(ax_s, buf, NOTWRITABLE, 1, &varbind, 1);
419884417368Smartijn 
419984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
420084417368Smartijn 	    &varbind, 1);
420184417368Smartijn }
420284417368Smartijn 
420384417368Smartijn void
backend_error_get_inconsistentname(void)420484417368Smartijn backend_error_get_inconsistentname(void)
420584417368Smartijn {
420684417368Smartijn 	struct sockaddr_storage ss;
420784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
420884417368Smartijn 	socklen_t salen;
420984417368Smartijn 	int snmp_s, ax_s;
421084417368Smartijn 	uint32_t sessionid;
421184417368Smartijn 	struct varbind varbind = {
421284417368Smartijn 		.type = TYPE_NULL,
421384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 18, 0),
421484417368Smartijn 	};
421584417368Smartijn 	int32_t requestid;
421684417368Smartijn 	char buf[1024];
421784417368Smartijn 	size_t n;
421884417368Smartijn 
421984417368Smartijn 	ax_s = agentx_connect(axsocket);
422084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
422184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 18), __func__);
422284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
422384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 18), 0);
422484417368Smartijn 
422584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
422684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
422784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
422884417368Smartijn 
422984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
423084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
423184417368Smartijn 
423284417368Smartijn 	agentx_response(ax_s, buf, INCONSISTENTNAME, 1, &varbind, 1);
423384417368Smartijn 
423484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
423584417368Smartijn 	    &varbind, 1);
423684417368Smartijn }
423784417368Smartijn 
423884417368Smartijn void
backend_error_get_openfailed(void)423984417368Smartijn backend_error_get_openfailed(void)
424084417368Smartijn {
424184417368Smartijn 	struct sockaddr_storage ss;
424284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
424384417368Smartijn 	socklen_t salen;
424484417368Smartijn 	int snmp_s, ax_s;
424584417368Smartijn 	uint32_t sessionid;
424684417368Smartijn 	struct varbind varbind = {
424784417368Smartijn 		.type = TYPE_NULL,
424884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 19, 0),
424984417368Smartijn 	};
425084417368Smartijn 	int32_t requestid;
425184417368Smartijn 	char buf[1024];
425284417368Smartijn 	size_t n;
425384417368Smartijn 
425484417368Smartijn 	ax_s = agentx_connect(axsocket);
425584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
425684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 19), __func__);
425784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
425884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 19), 0);
425984417368Smartijn 
426084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
426184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
426284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
426384417368Smartijn 
426484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
426584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
426684417368Smartijn 
426784417368Smartijn 	agentx_response(ax_s, buf, OPENFAILED, 1, &varbind, 1);
426884417368Smartijn 
426984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
427084417368Smartijn 	    &varbind, 1);
427184417368Smartijn }
427284417368Smartijn 
427384417368Smartijn void
backend_error_get_notopen(void)427484417368Smartijn backend_error_get_notopen(void)
427584417368Smartijn {
427684417368Smartijn 	struct sockaddr_storage ss;
427784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
427884417368Smartijn 	socklen_t salen;
427984417368Smartijn 	int snmp_s, ax_s;
428084417368Smartijn 	uint32_t sessionid;
428184417368Smartijn 	struct varbind varbind = {
428284417368Smartijn 		.type = TYPE_NULL,
428384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 20, 0),
428484417368Smartijn 	};
428584417368Smartijn 	int32_t requestid;
428684417368Smartijn 	char buf[1024];
428784417368Smartijn 	size_t n;
428884417368Smartijn 
428984417368Smartijn 	ax_s = agentx_connect(axsocket);
429084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
429184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 20), __func__);
429284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
429384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 20), 0);
429484417368Smartijn 
429584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
429684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
429784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
429884417368Smartijn 
429984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
430084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
430184417368Smartijn 
430284417368Smartijn 	agentx_response(ax_s, buf, NOTOPEN, 1, &varbind, 1);
430384417368Smartijn 
430484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
430584417368Smartijn 	    &varbind, 1);
430684417368Smartijn }
430784417368Smartijn 
430884417368Smartijn void
backend_error_get_indexwrongtype(void)430984417368Smartijn backend_error_get_indexwrongtype(void)
431084417368Smartijn {
431184417368Smartijn 	struct sockaddr_storage ss;
431284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
431384417368Smartijn 	socklen_t salen;
431484417368Smartijn 	int snmp_s, ax_s;
431584417368Smartijn 	uint32_t sessionid;
431684417368Smartijn 	struct varbind varbind = {
431784417368Smartijn 		.type = TYPE_NULL,
431884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 21, 0),
431984417368Smartijn 	};
432084417368Smartijn 	int32_t requestid;
432184417368Smartijn 	char buf[1024];
432284417368Smartijn 	size_t n;
432384417368Smartijn 
432484417368Smartijn 	ax_s = agentx_connect(axsocket);
432584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
432684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 21), __func__);
432784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
432884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 21), 0);
432984417368Smartijn 
433084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
433184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
433284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
433384417368Smartijn 
433484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
433584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
433684417368Smartijn 
433784417368Smartijn 	agentx_response(ax_s, buf, INDEXWRONGTYPE, 1, &varbind, 1);
433884417368Smartijn 
433984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
434084417368Smartijn 	    &varbind, 1);
434184417368Smartijn }
434284417368Smartijn 
434384417368Smartijn void
backend_error_get_indexalreadyallocated(void)434484417368Smartijn backend_error_get_indexalreadyallocated(void)
434584417368Smartijn {
434684417368Smartijn 	struct sockaddr_storage ss;
434784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
434884417368Smartijn 	socklen_t salen;
434984417368Smartijn 	int snmp_s, ax_s;
435084417368Smartijn 	uint32_t sessionid;
435184417368Smartijn 	struct varbind varbind = {
435284417368Smartijn 		.type = TYPE_NULL,
435384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 22, 0),
435484417368Smartijn 	};
435584417368Smartijn 	int32_t requestid;
435684417368Smartijn 	char buf[1024];
435784417368Smartijn 	size_t n;
435884417368Smartijn 
435984417368Smartijn 	ax_s = agentx_connect(axsocket);
436084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
436184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 22), __func__);
436284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
436384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 22), 0);
436484417368Smartijn 
436584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
436684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
436784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
436884417368Smartijn 
436984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
437084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
437184417368Smartijn 
437284417368Smartijn 	agentx_response(ax_s, buf, INDEXALREADYALLOCATED, 1, &varbind, 1);
437384417368Smartijn 
437484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
437584417368Smartijn 	    &varbind, 1);
437684417368Smartijn }
437784417368Smartijn 
437884417368Smartijn void
backend_error_get_indexnonavailable(void)437984417368Smartijn backend_error_get_indexnonavailable(void)
438084417368Smartijn {
438184417368Smartijn 	struct sockaddr_storage ss;
438284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
438384417368Smartijn 	socklen_t salen;
438484417368Smartijn 	int snmp_s, ax_s;
438584417368Smartijn 	uint32_t sessionid;
438684417368Smartijn 	struct varbind varbind = {
438784417368Smartijn 		.type = TYPE_NULL,
438884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 23, 0),
438984417368Smartijn 	};
439084417368Smartijn 	int32_t requestid;
439184417368Smartijn 	char buf[1024];
439284417368Smartijn 	size_t n;
439384417368Smartijn 
439484417368Smartijn 	ax_s = agentx_connect(axsocket);
439584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
439684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 23), __func__);
439784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
439884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 23), 0);
439984417368Smartijn 
440084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
440184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
440284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
440384417368Smartijn 
440484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
440584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
440684417368Smartijn 
440784417368Smartijn 	agentx_response(ax_s, buf, INDEXNONEAVAILABLE, 1, &varbind, 1);
440884417368Smartijn 
440984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
441084417368Smartijn 	    &varbind, 1);
441184417368Smartijn }
441284417368Smartijn 
441384417368Smartijn void
backend_error_get_indexnotallocated(void)441484417368Smartijn backend_error_get_indexnotallocated(void)
441584417368Smartijn {
441684417368Smartijn 	struct sockaddr_storage ss;
441784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
441884417368Smartijn 	socklen_t salen;
441984417368Smartijn 	int snmp_s, ax_s;
442084417368Smartijn 	uint32_t sessionid;
442184417368Smartijn 	struct varbind varbind = {
442284417368Smartijn 		.type = TYPE_NULL,
442384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 24, 0),
442484417368Smartijn 	};
442584417368Smartijn 	int32_t requestid;
442684417368Smartijn 	char buf[1024];
442784417368Smartijn 	size_t n;
442884417368Smartijn 
442984417368Smartijn 	ax_s = agentx_connect(axsocket);
443084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
443184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 24), __func__);
443284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
443384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 24), 0);
443484417368Smartijn 
443584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
443684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
443784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
443884417368Smartijn 
443984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
444084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
444184417368Smartijn 
444284417368Smartijn 	agentx_response(ax_s, buf, INDEXNOTALLOCATED, 1, &varbind, 1);
444384417368Smartijn 
444484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
444584417368Smartijn 	    &varbind, 1);
444684417368Smartijn }
444784417368Smartijn 
444884417368Smartijn void
backend_error_get_unsupportedcontext(void)444984417368Smartijn backend_error_get_unsupportedcontext(void)
445084417368Smartijn {
445184417368Smartijn 	struct sockaddr_storage ss;
445284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
445384417368Smartijn 	socklen_t salen;
445484417368Smartijn 	int snmp_s, ax_s;
445584417368Smartijn 	uint32_t sessionid;
445684417368Smartijn 	struct varbind varbind = {
445784417368Smartijn 		.type = TYPE_NULL,
445884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 25, 0),
445984417368Smartijn 	};
446084417368Smartijn 	int32_t requestid;
446184417368Smartijn 	char buf[1024];
446284417368Smartijn 	size_t n;
446384417368Smartijn 
446484417368Smartijn 	ax_s = agentx_connect(axsocket);
446584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
446684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 25), __func__);
446784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
446884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 25), 0);
446984417368Smartijn 
447084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
447184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
447284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
447384417368Smartijn 
447484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
447584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
447684417368Smartijn 
447784417368Smartijn 	agentx_response(ax_s, buf, UNSUPPORTEDCONTEXT, 1, &varbind, 1);
447884417368Smartijn 
447984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
448084417368Smartijn 	    &varbind, 1);
448184417368Smartijn }
448284417368Smartijn 
448384417368Smartijn void
backend_error_get_duplicateregistration(void)448484417368Smartijn backend_error_get_duplicateregistration(void)
448584417368Smartijn {
448684417368Smartijn 	struct sockaddr_storage ss;
448784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
448884417368Smartijn 	socklen_t salen;
448984417368Smartijn 	int snmp_s, ax_s;
449084417368Smartijn 	uint32_t sessionid;
449184417368Smartijn 	struct varbind varbind = {
449284417368Smartijn 		.type = TYPE_NULL,
449384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 26, 0),
449484417368Smartijn 	};
449584417368Smartijn 	int32_t requestid;
449684417368Smartijn 	char buf[1024];
449784417368Smartijn 	size_t n;
449884417368Smartijn 
449984417368Smartijn 	ax_s = agentx_connect(axsocket);
450084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
450184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 26), __func__);
450284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
450384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 26), 0);
450484417368Smartijn 
450584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
450684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
450784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
450884417368Smartijn 
450984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
451084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
451184417368Smartijn 
451284417368Smartijn 	agentx_response(ax_s, buf, DUPLICATEREGISTRATION, 1, &varbind, 1);
451384417368Smartijn 
451484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
451584417368Smartijn 	    &varbind, 1);
451684417368Smartijn }
451784417368Smartijn 
451884417368Smartijn void
backend_error_get_unknownregistration(void)451984417368Smartijn backend_error_get_unknownregistration(void)
452084417368Smartijn {
452184417368Smartijn 	struct sockaddr_storage ss;
452284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
452384417368Smartijn 	socklen_t salen;
452484417368Smartijn 	int snmp_s, ax_s;
452584417368Smartijn 	uint32_t sessionid;
452684417368Smartijn 	struct varbind varbind = {
452784417368Smartijn 		.type = TYPE_NULL,
452884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 27, 0),
452984417368Smartijn 	};
453084417368Smartijn 	int32_t requestid;
453184417368Smartijn 	char buf[1024];
453284417368Smartijn 	size_t n;
453384417368Smartijn 
453484417368Smartijn 	ax_s = agentx_connect(axsocket);
453584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
453684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 27), __func__);
453784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
453884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 27), 0);
453984417368Smartijn 
454084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
454184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
454284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
454384417368Smartijn 
454484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
454584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
454684417368Smartijn 
454784417368Smartijn 	agentx_response(ax_s, buf, UNKNOWNREGISTRATION, 1, &varbind, 1);
454884417368Smartijn 
454984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
455084417368Smartijn 	    &varbind, 1);
455184417368Smartijn }
455284417368Smartijn 
455384417368Smartijn void
backend_error_get_parseerror(void)455484417368Smartijn backend_error_get_parseerror(void)
455584417368Smartijn {
455684417368Smartijn 	struct sockaddr_storage ss;
455784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
455884417368Smartijn 	socklen_t salen;
455984417368Smartijn 	int snmp_s, ax_s;
456084417368Smartijn 	uint32_t sessionid;
456184417368Smartijn 	struct varbind varbind = {
456284417368Smartijn 		.type = TYPE_NULL,
456384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 28, 0),
456484417368Smartijn 	};
456584417368Smartijn 	int32_t requestid;
456684417368Smartijn 	char buf[1024];
456784417368Smartijn 	size_t n;
456884417368Smartijn 
456984417368Smartijn 	ax_s = agentx_connect(axsocket);
457084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
457184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 28), __func__);
457284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
457384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 28), 0);
457484417368Smartijn 
457584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
457684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
457784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
457884417368Smartijn 
457984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
458084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
458184417368Smartijn 
458284417368Smartijn 	agentx_response(ax_s, buf, PARSEERROR, 1, &varbind, 1);
458384417368Smartijn 
458484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
458584417368Smartijn 	    &varbind, 1);
458684417368Smartijn }
458784417368Smartijn 
458884417368Smartijn void
backend_error_get_requestdenied(void)458984417368Smartijn backend_error_get_requestdenied(void)
459084417368Smartijn {
459184417368Smartijn 	struct sockaddr_storage ss;
459284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
459384417368Smartijn 	socklen_t salen;
459484417368Smartijn 	int snmp_s, ax_s;
459584417368Smartijn 	uint32_t sessionid;
459684417368Smartijn 	struct varbind varbind = {
459784417368Smartijn 		.type = TYPE_NULL,
459884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 29, 0),
459984417368Smartijn 	};
460084417368Smartijn 	int32_t requestid;
460184417368Smartijn 	char buf[1024];
460284417368Smartijn 	size_t n;
460384417368Smartijn 
460484417368Smartijn 	ax_s = agentx_connect(axsocket);
460584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
460684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 29), __func__);
460784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
460884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 29), 0);
460984417368Smartijn 
461084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
461184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
461284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
461384417368Smartijn 
461484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
461584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
461684417368Smartijn 
461784417368Smartijn 	agentx_response(ax_s, buf, REQUESTDENIED, 1, &varbind, 1);
461884417368Smartijn 
461984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
462084417368Smartijn 	    &varbind, 1);
462184417368Smartijn }
462284417368Smartijn 
462384417368Smartijn void
backend_error_get_processingerror(void)462484417368Smartijn backend_error_get_processingerror(void)
462584417368Smartijn {
462684417368Smartijn 	struct sockaddr_storage ss;
462784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
462884417368Smartijn 	socklen_t salen;
462984417368Smartijn 	int snmp_s, ax_s;
463084417368Smartijn 	uint32_t sessionid;
463184417368Smartijn 	struct varbind varbind = {
463284417368Smartijn 		.type = TYPE_NULL,
463384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 30, 0),
463484417368Smartijn 	};
463584417368Smartijn 	int32_t requestid;
463684417368Smartijn 	char buf[1024];
463784417368Smartijn 	size_t n;
463884417368Smartijn 
463984417368Smartijn 	ax_s = agentx_connect(axsocket);
464084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
464184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 30), __func__);
464284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
464384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 30), 0);
464484417368Smartijn 
464584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
464684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
464784417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
464884417368Smartijn 
464984417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
465084417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
465184417368Smartijn 
465284417368Smartijn 	agentx_response(ax_s, buf, PROCESSINGERROR, 1, &varbind, 1);
465384417368Smartijn 
465484417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
465584417368Smartijn 	    &varbind, 1);
465684417368Smartijn }
465784417368Smartijn 
465884417368Smartijn void
backend_error_get_nonstandard(void)465984417368Smartijn backend_error_get_nonstandard(void)
466084417368Smartijn {
466184417368Smartijn 	struct sockaddr_storage ss;
466284417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
466384417368Smartijn 	socklen_t salen;
466484417368Smartijn 	int snmp_s, ax_s;
466584417368Smartijn 	uint32_t sessionid;
466684417368Smartijn 	struct varbind varbind = {
466784417368Smartijn 		.type = TYPE_NULL,
466884417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 31, 0),
466984417368Smartijn 	};
467084417368Smartijn 	int32_t requestid;
467184417368Smartijn 	char buf[1024];
467284417368Smartijn 	size_t n;
467384417368Smartijn 
467484417368Smartijn 	ax_s = agentx_connect(axsocket);
467584417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
467684417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 31), __func__);
467784417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
467884417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 31), 0);
467984417368Smartijn 
468084417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
468184417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
468284417368Smartijn 	requestid = snmpv2_get(snmp_s, community, 0, &varbind, 1);
468384417368Smartijn 
468484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
468584417368Smartijn 	agentx_get_handle(__func__, buf, n, 0, sessionid, &varbind, 1);
468684417368Smartijn 
468784417368Smartijn 	agentx_response(ax_s, buf, 0xFFFF, 1, &varbind, 1);
468884417368Smartijn 
468984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
469084417368Smartijn 	    &varbind, 1);
469184417368Smartijn }
469284417368Smartijn 
469384417368Smartijn void
backend_error_getnext_toobig(void)469484417368Smartijn backend_error_getnext_toobig(void)
469584417368Smartijn {
469684417368Smartijn 	struct sockaddr_storage ss;
469784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
469884417368Smartijn 	socklen_t salen;
469984417368Smartijn 	int snmp_s, ax_s;
470084417368Smartijn 	uint32_t sessionid;
470184417368Smartijn 	struct varbind varbind = {
470284417368Smartijn 		.type = TYPE_NULL,
470384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 32),
470484417368Smartijn 	};
470584417368Smartijn 	int32_t requestid;
470684417368Smartijn 	char buf[1024];
470784417368Smartijn 	size_t n;
470884417368Smartijn 
470984417368Smartijn 	ax_s = agentx_connect(axsocket);
471084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
471184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 32), __func__);
471284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
471384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 32), 0);
471484417368Smartijn 
471584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
471684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
471784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
471884417368Smartijn 
471984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
472084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
472184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
472284417368Smartijn 	varbind.name.n_subid--;
472384417368Smartijn 	agentx_response(ax_s, buf, TOOBIG, 1, &varbind, 1);
472484417368Smartijn 
472584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, TOOBIG, 1,
472684417368Smartijn 	    &varbind, 1);
472784417368Smartijn }
472884417368Smartijn 
472984417368Smartijn void
backend_error_getnext_nosuchname(void)473084417368Smartijn backend_error_getnext_nosuchname(void)
473184417368Smartijn {
473284417368Smartijn 	struct sockaddr_storage ss;
473384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
473484417368Smartijn 	socklen_t salen;
473584417368Smartijn 	int snmp_s, ax_s;
473684417368Smartijn 	uint32_t sessionid;
473784417368Smartijn 	struct varbind varbind = {
473884417368Smartijn 		.type = TYPE_NULL,
473984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 33),
474084417368Smartijn 	};
474184417368Smartijn 	int32_t requestid;
474284417368Smartijn 	char buf[1024];
474384417368Smartijn 	size_t n;
474484417368Smartijn 
474584417368Smartijn 	ax_s = agentx_connect(axsocket);
474684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
474784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 33), __func__);
474884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
474984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 33), 0);
475084417368Smartijn 
475184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
475284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
475384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
475484417368Smartijn 
475584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
475684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
475784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
475884417368Smartijn 	varbind.name.n_subid--;
475984417368Smartijn 	agentx_response(ax_s, buf, NOSUCHNAME, 1, &varbind, 1);
476084417368Smartijn 
476184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, NOSUCHNAME, 1,
476284417368Smartijn 	    &varbind, 1);
476384417368Smartijn }
476484417368Smartijn 
476584417368Smartijn void
backend_error_getnext_badvalue(void)476684417368Smartijn backend_error_getnext_badvalue(void)
476784417368Smartijn {
476884417368Smartijn 	struct sockaddr_storage ss;
476984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
477084417368Smartijn 	socklen_t salen;
477184417368Smartijn 	int snmp_s, ax_s;
477284417368Smartijn 	uint32_t sessionid;
477384417368Smartijn 	struct varbind varbind = {
477484417368Smartijn 		.type = TYPE_NULL,
477584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 34),
477684417368Smartijn 	};
477784417368Smartijn 	int32_t requestid;
477884417368Smartijn 	char buf[1024];
477984417368Smartijn 	size_t n;
478084417368Smartijn 
478184417368Smartijn 	ax_s = agentx_connect(axsocket);
478284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
478384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 34), __func__);
478484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
478584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 34), 0);
478684417368Smartijn 
478784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
478884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
478984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
479084417368Smartijn 
479184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
479284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
479384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
479484417368Smartijn 	varbind.name.n_subid--;
479584417368Smartijn 	agentx_response(ax_s, buf, BADVALUE, 1, &varbind, 1);
479684417368Smartijn 
479784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
479884417368Smartijn 	    &varbind, 1);
479984417368Smartijn }
480084417368Smartijn 
480184417368Smartijn void
backend_error_getnext_readonly(void)480284417368Smartijn backend_error_getnext_readonly(void)
480384417368Smartijn {
480484417368Smartijn 	struct sockaddr_storage ss;
480584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
480684417368Smartijn 	socklen_t salen;
480784417368Smartijn 	int snmp_s, ax_s;
480884417368Smartijn 	uint32_t sessionid;
480984417368Smartijn 	struct varbind varbind = {
481084417368Smartijn 		.type = TYPE_NULL,
481184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 35),
481284417368Smartijn 	};
481384417368Smartijn 	int32_t requestid;
481484417368Smartijn 	char buf[1024];
481584417368Smartijn 	size_t n;
481684417368Smartijn 
481784417368Smartijn 	ax_s = agentx_connect(axsocket);
481884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
481984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 35), __func__);
482084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
482184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 35), 0);
482284417368Smartijn 
482384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
482484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
482584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
482684417368Smartijn 
482784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
482884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
482984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
483084417368Smartijn 	varbind.name.n_subid--;
483184417368Smartijn 	agentx_response(ax_s, buf, READONLY, 1, &varbind, 1);
483284417368Smartijn 
483384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
483484417368Smartijn 	    &varbind, 1);
483584417368Smartijn }
483684417368Smartijn 
483784417368Smartijn void
backend_error_getnext_generr(void)483884417368Smartijn backend_error_getnext_generr(void)
483984417368Smartijn {
484084417368Smartijn 	struct sockaddr_storage ss;
484184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
484284417368Smartijn 	socklen_t salen;
484384417368Smartijn 	int snmp_s, ax_s;
484484417368Smartijn 	uint32_t sessionid;
484584417368Smartijn 	struct varbind varbind = {
484684417368Smartijn 		.type = TYPE_NULL,
484784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 36),
484884417368Smartijn 	};
484984417368Smartijn 	int32_t requestid;
485084417368Smartijn 	char buf[1024];
485184417368Smartijn 	size_t n;
485284417368Smartijn 
485384417368Smartijn 	ax_s = agentx_connect(axsocket);
485484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
485584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 36), __func__);
485684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
485784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 36), 0);
485884417368Smartijn 
485984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
486084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
486184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
486284417368Smartijn 
486384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
486484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
486584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
486684417368Smartijn 	varbind.name.n_subid--;
486784417368Smartijn 	agentx_response(ax_s, buf, GENERR, 1, &varbind, 1);
486884417368Smartijn 
486984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
487084417368Smartijn 	    &varbind, 1);
487184417368Smartijn }
487284417368Smartijn 
487384417368Smartijn void
backend_error_getnext_noaccess(void)487484417368Smartijn backend_error_getnext_noaccess(void)
487584417368Smartijn {
487684417368Smartijn 	struct sockaddr_storage ss;
487784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
487884417368Smartijn 	socklen_t salen;
487984417368Smartijn 	int snmp_s, ax_s;
488084417368Smartijn 	uint32_t sessionid;
488184417368Smartijn 	struct varbind varbind = {
488284417368Smartijn 		.type = TYPE_NULL,
488384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 37),
488484417368Smartijn 	};
488584417368Smartijn 	int32_t requestid;
488684417368Smartijn 	char buf[1024];
488784417368Smartijn 	size_t n;
488884417368Smartijn 
488984417368Smartijn 	ax_s = agentx_connect(axsocket);
489084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
489184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 37), __func__);
489284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
489384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 37), 0);
489484417368Smartijn 
489584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
489684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
489784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
489884417368Smartijn 
489984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
490084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
490184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
490284417368Smartijn 	varbind.name.n_subid--;
490384417368Smartijn 	agentx_response(ax_s, buf, NOACCESS, 1, &varbind, 1);
490484417368Smartijn 
490584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
490684417368Smartijn 	    &varbind, 1);
490784417368Smartijn }
490884417368Smartijn 
490984417368Smartijn void
backend_error_getnext_wrongtype(void)491084417368Smartijn backend_error_getnext_wrongtype(void)
491184417368Smartijn {
491284417368Smartijn 	struct sockaddr_storage ss;
491384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
491484417368Smartijn 	socklen_t salen;
491584417368Smartijn 	int snmp_s, ax_s;
491684417368Smartijn 	uint32_t sessionid;
491784417368Smartijn 	struct varbind varbind = {
491884417368Smartijn 		.type = TYPE_NULL,
491984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 38),
492084417368Smartijn 	};
492184417368Smartijn 	int32_t requestid;
492284417368Smartijn 	char buf[1024];
492384417368Smartijn 	size_t n;
492484417368Smartijn 
492584417368Smartijn 	ax_s = agentx_connect(axsocket);
492684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
492784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 38), __func__);
492884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
492984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 38), 0);
493084417368Smartijn 
493184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
493284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
493384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
493484417368Smartijn 
493584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
493684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
493784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
493884417368Smartijn 	varbind.name.n_subid--;
493984417368Smartijn 	agentx_response(ax_s, buf, WRONGTYPE, 1, &varbind, 1);
494084417368Smartijn 
494184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
494284417368Smartijn 	    &varbind, 1);
494384417368Smartijn }
494484417368Smartijn 
494584417368Smartijn void
backend_error_getnext_wronglength(void)494684417368Smartijn backend_error_getnext_wronglength(void)
494784417368Smartijn {
494884417368Smartijn 	struct sockaddr_storage ss;
494984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
495084417368Smartijn 	socklen_t salen;
495184417368Smartijn 	int snmp_s, ax_s;
495284417368Smartijn 	uint32_t sessionid;
495384417368Smartijn 	struct varbind varbind = {
495484417368Smartijn 		.type = TYPE_NULL,
495584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 39),
495684417368Smartijn 	};
495784417368Smartijn 	int32_t requestid;
495884417368Smartijn 	char buf[1024];
495984417368Smartijn 	size_t n;
496084417368Smartijn 
496184417368Smartijn 	ax_s = agentx_connect(axsocket);
496284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
496384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 39), __func__);
496484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
496584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 39), 0);
496684417368Smartijn 
496784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
496884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
496984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
497084417368Smartijn 
497184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
497284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
497384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
497484417368Smartijn 	varbind.name.n_subid--;
497584417368Smartijn 	agentx_response(ax_s, buf, WRONGLENGTH, 1, &varbind, 1);
497684417368Smartijn 
497784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
497884417368Smartijn 	    &varbind, 1);
497984417368Smartijn }
498084417368Smartijn 
498184417368Smartijn void
backend_error_getnext_wrongencoding(void)498284417368Smartijn backend_error_getnext_wrongencoding(void)
498384417368Smartijn {
498484417368Smartijn 	struct sockaddr_storage ss;
498584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
498684417368Smartijn 	socklen_t salen;
498784417368Smartijn 	int snmp_s, ax_s;
498884417368Smartijn 	uint32_t sessionid;
498984417368Smartijn 	struct varbind varbind = {
499084417368Smartijn 		.type = TYPE_NULL,
499184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 40),
499284417368Smartijn 	};
499384417368Smartijn 	int32_t requestid;
499484417368Smartijn 	char buf[1024];
499584417368Smartijn 	size_t n;
499684417368Smartijn 
499784417368Smartijn 	ax_s = agentx_connect(axsocket);
499884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
499984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 40), __func__);
500084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
500184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 40), 0);
500284417368Smartijn 
500384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
500484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
500584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
500684417368Smartijn 
500784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
500884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
500984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
501084417368Smartijn 	varbind.name.n_subid--;
501184417368Smartijn 	agentx_response(ax_s, buf, WRONGENCODING, 1, &varbind, 1);
501284417368Smartijn 
501384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
501484417368Smartijn 	    &varbind, 1);
501584417368Smartijn }
501684417368Smartijn 
501784417368Smartijn void
backend_error_getnext_wrongvalue(void)501884417368Smartijn backend_error_getnext_wrongvalue(void)
501984417368Smartijn {
502084417368Smartijn 	struct sockaddr_storage ss;
502184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
502284417368Smartijn 	socklen_t salen;
502384417368Smartijn 	int snmp_s, ax_s;
502484417368Smartijn 	uint32_t sessionid;
502584417368Smartijn 	struct varbind varbind = {
502684417368Smartijn 		.type = TYPE_NULL,
502784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 41),
502884417368Smartijn 	};
502984417368Smartijn 	int32_t requestid;
503084417368Smartijn 	char buf[1024];
503184417368Smartijn 	size_t n;
503284417368Smartijn 
503384417368Smartijn 	ax_s = agentx_connect(axsocket);
503484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
503584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 41), __func__);
503684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
503784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 41), 0);
503884417368Smartijn 
503984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
504084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
504184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
504284417368Smartijn 
504384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
504484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
504584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
504684417368Smartijn 	varbind.name.n_subid--;
504784417368Smartijn 	agentx_response(ax_s, buf, WRONGVALUE, 1, &varbind, 1);
504884417368Smartijn 
504984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
505084417368Smartijn 	    &varbind, 1);
505184417368Smartijn }
505284417368Smartijn 
505384417368Smartijn void
backend_error_getnext_nocreation(void)505484417368Smartijn backend_error_getnext_nocreation(void)
505584417368Smartijn {
505684417368Smartijn 	struct sockaddr_storage ss;
505784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
505884417368Smartijn 	socklen_t salen;
505984417368Smartijn 	int snmp_s, ax_s;
506084417368Smartijn 	uint32_t sessionid;
506184417368Smartijn 	struct varbind varbind = {
506284417368Smartijn 		.type = TYPE_NULL,
506384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 42),
506484417368Smartijn 	};
506584417368Smartijn 	int32_t requestid;
506684417368Smartijn 	char buf[1024];
506784417368Smartijn 	size_t n;
506884417368Smartijn 
506984417368Smartijn 	ax_s = agentx_connect(axsocket);
507084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
507184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 42), __func__);
507284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
507384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 42), 0);
507484417368Smartijn 
507584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
507684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
507784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
507884417368Smartijn 
507984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
508084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
508184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
508284417368Smartijn 	varbind.name.n_subid--;
508384417368Smartijn 	agentx_response(ax_s, buf, NOCREATION, 1, &varbind, 1);
508484417368Smartijn 
508584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
508684417368Smartijn 	    &varbind, 1);
508784417368Smartijn }
508884417368Smartijn 
508984417368Smartijn void
backend_error_getnext_inconsistentvalue(void)509084417368Smartijn backend_error_getnext_inconsistentvalue(void)
509184417368Smartijn {
509284417368Smartijn 	struct sockaddr_storage ss;
509384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
509484417368Smartijn 	socklen_t salen;
509584417368Smartijn 	int snmp_s, ax_s;
509684417368Smartijn 	uint32_t sessionid;
509784417368Smartijn 	struct varbind varbind = {
509884417368Smartijn 		.type = TYPE_NULL,
509984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 43),
510084417368Smartijn 	};
510184417368Smartijn 	int32_t requestid;
510284417368Smartijn 	char buf[1024];
510384417368Smartijn 	size_t n;
510484417368Smartijn 
510584417368Smartijn 	ax_s = agentx_connect(axsocket);
510684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
510784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 43), __func__);
510884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
510984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 43), 0);
511084417368Smartijn 
511184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
511284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
511384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
511484417368Smartijn 
511584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
511684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
511784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
511884417368Smartijn 	varbind.name.n_subid--;
511984417368Smartijn 	agentx_response(ax_s, buf, INCONSISTENTVALUE, 1, &varbind, 1);
512084417368Smartijn 
512184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
512284417368Smartijn 	    &varbind, 1);
512384417368Smartijn }
512484417368Smartijn 
512584417368Smartijn void
backend_error_getnext_resourceunavailable(void)512684417368Smartijn backend_error_getnext_resourceunavailable(void)
512784417368Smartijn {
512884417368Smartijn 	struct sockaddr_storage ss;
512984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
513084417368Smartijn 	socklen_t salen;
513184417368Smartijn 	int snmp_s, ax_s;
513284417368Smartijn 	uint32_t sessionid;
513384417368Smartijn 	struct varbind varbind = {
513484417368Smartijn 		.type = TYPE_NULL,
513584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 44),
513684417368Smartijn 	};
513784417368Smartijn 	int32_t requestid;
513884417368Smartijn 	char buf[1024];
513984417368Smartijn 	size_t n;
514084417368Smartijn 
514184417368Smartijn 	ax_s = agentx_connect(axsocket);
514284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
514384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 44), __func__);
514484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
514584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 44), 0);
514684417368Smartijn 
514784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
514884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
514984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
515084417368Smartijn 
515184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
515284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
515384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
515484417368Smartijn 	varbind.name.n_subid--;
515584417368Smartijn 	agentx_response(ax_s, buf, RESOURCEUNAVAILABLE, 1, &varbind, 1);
515684417368Smartijn 
515784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
515884417368Smartijn 	    &varbind, 1);
515984417368Smartijn }
516084417368Smartijn 
516184417368Smartijn void
backend_error_getnext_commitfailed(void)516284417368Smartijn backend_error_getnext_commitfailed(void)
516384417368Smartijn {
516484417368Smartijn 	struct sockaddr_storage ss;
516584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
516684417368Smartijn 	socklen_t salen;
516784417368Smartijn 	int snmp_s, ax_s;
516884417368Smartijn 	uint32_t sessionid;
516984417368Smartijn 	struct varbind varbind = {
517084417368Smartijn 		.type = TYPE_NULL,
517184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 45),
517284417368Smartijn 	};
517384417368Smartijn 	int32_t requestid;
517484417368Smartijn 	char buf[1024];
517584417368Smartijn 	size_t n;
517684417368Smartijn 
517784417368Smartijn 	ax_s = agentx_connect(axsocket);
517884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
517984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 45), __func__);
518084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
518184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 45), 0);
518284417368Smartijn 
518384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
518484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
518584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
518684417368Smartijn 
518784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
518884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
518984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
519084417368Smartijn 	varbind.name.n_subid--;
519184417368Smartijn 	agentx_response(ax_s, buf, COMMITFAILED, 1, &varbind, 1);
519284417368Smartijn 
519384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
519484417368Smartijn 	    &varbind, 1);
519584417368Smartijn }
519684417368Smartijn 
519784417368Smartijn void
backend_error_getnext_undofailed(void)519884417368Smartijn backend_error_getnext_undofailed(void)
519984417368Smartijn {
520084417368Smartijn 	struct sockaddr_storage ss;
520184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
520284417368Smartijn 	socklen_t salen;
520384417368Smartijn 	int snmp_s, ax_s;
520484417368Smartijn 	uint32_t sessionid;
520584417368Smartijn 	struct varbind varbind = {
520684417368Smartijn 		.type = TYPE_NULL,
520784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 46),
520884417368Smartijn 	};
520984417368Smartijn 	int32_t requestid;
521084417368Smartijn 	char buf[1024];
521184417368Smartijn 	size_t n;
521284417368Smartijn 
521384417368Smartijn 	ax_s = agentx_connect(axsocket);
521484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
521584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 46), __func__);
521684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
521784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 46), 0);
521884417368Smartijn 
521984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
522084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
522184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
522284417368Smartijn 
522384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
522484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
522584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
522684417368Smartijn 	varbind.name.n_subid--;
522784417368Smartijn 	agentx_response(ax_s, buf, UNDOFAILED, 1, &varbind, 1);
522884417368Smartijn 
522984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
523084417368Smartijn 	    &varbind, 1);
523184417368Smartijn }
523284417368Smartijn 
523384417368Smartijn void
backend_error_getnext_authorizationerror(void)523484417368Smartijn backend_error_getnext_authorizationerror(void)
523584417368Smartijn {
523684417368Smartijn 	struct sockaddr_storage ss;
523784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
523884417368Smartijn 	socklen_t salen;
523984417368Smartijn 	int snmp_s, ax_s;
524084417368Smartijn 	uint32_t sessionid;
524184417368Smartijn 	struct varbind varbind = {
524284417368Smartijn 		.type = TYPE_NULL,
524384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 47),
524484417368Smartijn 	};
524584417368Smartijn 	int32_t requestid;
524684417368Smartijn 	char buf[1024];
524784417368Smartijn 	size_t n;
524884417368Smartijn 
524984417368Smartijn 	ax_s = agentx_connect(axsocket);
525084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
525184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 47), __func__);
525284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
525384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 47), 0);
525484417368Smartijn 
525584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
525684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
525784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
525884417368Smartijn 
525984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
526084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
526184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
526284417368Smartijn 	varbind.name.n_subid--;
526384417368Smartijn 	agentx_response(ax_s, buf, AUTHORIZATIONERROR, 1, &varbind, 1);
526484417368Smartijn 
526584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
526684417368Smartijn 	    &varbind, 1);
526784417368Smartijn }
526884417368Smartijn 
526984417368Smartijn void
backend_error_getnext_notwritable(void)527084417368Smartijn backend_error_getnext_notwritable(void)
527184417368Smartijn {
527284417368Smartijn 	struct sockaddr_storage ss;
527384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
527484417368Smartijn 	socklen_t salen;
527584417368Smartijn 	int snmp_s, ax_s;
527684417368Smartijn 	uint32_t sessionid;
527784417368Smartijn 	struct varbind varbind = {
527884417368Smartijn 		.type = TYPE_NULL,
527984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 48),
528084417368Smartijn 	};
528184417368Smartijn 	int32_t requestid;
528284417368Smartijn 	char buf[1024];
528384417368Smartijn 	size_t n;
528484417368Smartijn 
528584417368Smartijn 	ax_s = agentx_connect(axsocket);
528684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
528784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 48), __func__);
528884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
528984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 48), 0);
529084417368Smartijn 
529184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
529284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
529384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
529484417368Smartijn 
529584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
529684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
529784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
529884417368Smartijn 	varbind.name.n_subid--;
529984417368Smartijn 	agentx_response(ax_s, buf, NOTWRITABLE, 1, &varbind, 1);
530084417368Smartijn 
530184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
530284417368Smartijn 	    &varbind, 1);
530384417368Smartijn }
530484417368Smartijn 
530584417368Smartijn void
backend_error_getnext_inconsistentname(void)530684417368Smartijn backend_error_getnext_inconsistentname(void)
530784417368Smartijn {
530884417368Smartijn 	struct sockaddr_storage ss;
530984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
531084417368Smartijn 	socklen_t salen;
531184417368Smartijn 	int snmp_s, ax_s;
531284417368Smartijn 	uint32_t sessionid;
531384417368Smartijn 	struct varbind varbind = {
531484417368Smartijn 		.type = TYPE_NULL,
531584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 49),
531684417368Smartijn 	};
531784417368Smartijn 	int32_t requestid;
531884417368Smartijn 	char buf[1024];
531984417368Smartijn 	size_t n;
532084417368Smartijn 
532184417368Smartijn 	ax_s = agentx_connect(axsocket);
532284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
532384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 49), __func__);
532484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
532584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 49), 0);
532684417368Smartijn 
532784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
532884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
532984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
533084417368Smartijn 
533184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
533284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
533384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
533484417368Smartijn 	varbind.name.n_subid--;
533584417368Smartijn 	agentx_response(ax_s, buf, INCONSISTENTNAME, 1, &varbind, 1);
533684417368Smartijn 
533784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
533884417368Smartijn 	    &varbind, 1);
533984417368Smartijn }
534084417368Smartijn 
534184417368Smartijn void
backend_error_getnext_openfailed(void)534284417368Smartijn backend_error_getnext_openfailed(void)
534384417368Smartijn {
534484417368Smartijn 	struct sockaddr_storage ss;
534584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
534684417368Smartijn 	socklen_t salen;
534784417368Smartijn 	int snmp_s, ax_s;
534884417368Smartijn 	uint32_t sessionid;
534984417368Smartijn 	struct varbind varbind = {
535084417368Smartijn 		.type = TYPE_NULL,
535184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 50),
535284417368Smartijn 	};
535384417368Smartijn 	int32_t requestid;
535484417368Smartijn 	char buf[1024];
535584417368Smartijn 	size_t n;
535684417368Smartijn 
535784417368Smartijn 	ax_s = agentx_connect(axsocket);
535884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
535984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 50), __func__);
536084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
536184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 50), 0);
536284417368Smartijn 
536384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
536484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
536584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
536684417368Smartijn 
536784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
536884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
536984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
537084417368Smartijn 	varbind.name.n_subid--;
537184417368Smartijn 	agentx_response(ax_s, buf, OPENFAILED, 1, &varbind, 1);
537284417368Smartijn 
537384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
537484417368Smartijn 	    &varbind, 1);
537584417368Smartijn }
537684417368Smartijn 
537784417368Smartijn void
backend_error_getnext_notopen(void)537884417368Smartijn backend_error_getnext_notopen(void)
537984417368Smartijn {
538084417368Smartijn 	struct sockaddr_storage ss;
538184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
538284417368Smartijn 	socklen_t salen;
538384417368Smartijn 	int snmp_s, ax_s;
538484417368Smartijn 	uint32_t sessionid;
538584417368Smartijn 	struct varbind varbind = {
538684417368Smartijn 		.type = TYPE_NULL,
538784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 51),
538884417368Smartijn 	};
538984417368Smartijn 	int32_t requestid;
539084417368Smartijn 	char buf[1024];
539184417368Smartijn 	size_t n;
539284417368Smartijn 
539384417368Smartijn 	ax_s = agentx_connect(axsocket);
539484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
539584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 51), __func__);
539684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
539784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 51), 0);
539884417368Smartijn 
539984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
540084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
540184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
540284417368Smartijn 
540384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
540484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
540584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
540684417368Smartijn 	varbind.name.n_subid--;
540784417368Smartijn 	agentx_response(ax_s, buf, NOTOPEN, 1, &varbind, 1);
540884417368Smartijn 
540984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
541084417368Smartijn 	    &varbind, 1);
541184417368Smartijn }
541284417368Smartijn 
541384417368Smartijn void
backend_error_getnext_indexwrongtype(void)541484417368Smartijn backend_error_getnext_indexwrongtype(void)
541584417368Smartijn {
541684417368Smartijn 	struct sockaddr_storage ss;
541784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
541884417368Smartijn 	socklen_t salen;
541984417368Smartijn 	int snmp_s, ax_s;
542084417368Smartijn 	uint32_t sessionid;
542184417368Smartijn 	struct varbind varbind = {
542284417368Smartijn 		.type = TYPE_NULL,
542384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 52),
542484417368Smartijn 	};
542584417368Smartijn 	int32_t requestid;
542684417368Smartijn 	char buf[1024];
542784417368Smartijn 	size_t n;
542884417368Smartijn 
542984417368Smartijn 	ax_s = agentx_connect(axsocket);
543084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
543184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 52), __func__);
543284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
543384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 52), 0);
543484417368Smartijn 
543584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
543684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
543784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
543884417368Smartijn 
543984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
544084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
544184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
544284417368Smartijn 	varbind.name.n_subid--;
544384417368Smartijn 	agentx_response(ax_s, buf, INDEXWRONGTYPE, 1, &varbind, 1);
544484417368Smartijn 
544584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
544684417368Smartijn 	    &varbind, 1);
544784417368Smartijn }
544884417368Smartijn 
544984417368Smartijn void
backend_error_getnext_indexalreadyallocated(void)545084417368Smartijn backend_error_getnext_indexalreadyallocated(void)
545184417368Smartijn {
545284417368Smartijn 	struct sockaddr_storage ss;
545384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
545484417368Smartijn 	socklen_t salen;
545584417368Smartijn 	int snmp_s, ax_s;
545684417368Smartijn 	uint32_t sessionid;
545784417368Smartijn 	struct varbind varbind = {
545884417368Smartijn 		.type = TYPE_NULL,
545984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 53),
546084417368Smartijn 	};
546184417368Smartijn 	int32_t requestid;
546284417368Smartijn 	char buf[1024];
546384417368Smartijn 	size_t n;
546484417368Smartijn 
546584417368Smartijn 	ax_s = agentx_connect(axsocket);
546684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
546784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 53), __func__);
546884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
546984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 53), 0);
547084417368Smartijn 
547184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
547284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
547384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
547484417368Smartijn 
547584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
547684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
547784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
547884417368Smartijn 	varbind.name.n_subid--;
547984417368Smartijn 	agentx_response(ax_s, buf, INDEXALREADYALLOCATED, 1, &varbind, 1);
548084417368Smartijn 
548184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
548284417368Smartijn 	    &varbind, 1);
548384417368Smartijn }
548484417368Smartijn 
548584417368Smartijn void
backend_error_getnext_indexnonavailable(void)548684417368Smartijn backend_error_getnext_indexnonavailable(void)
548784417368Smartijn {
548884417368Smartijn 	struct sockaddr_storage ss;
548984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
549084417368Smartijn 	socklen_t salen;
549184417368Smartijn 	int snmp_s, ax_s;
549284417368Smartijn 	uint32_t sessionid;
549384417368Smartijn 	struct varbind varbind = {
549484417368Smartijn 		.type = TYPE_NULL,
549584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 54),
549684417368Smartijn 	};
549784417368Smartijn 	int32_t requestid;
549884417368Smartijn 	char buf[1024];
549984417368Smartijn 	size_t n;
550084417368Smartijn 
550184417368Smartijn 	ax_s = agentx_connect(axsocket);
550284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
550384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 54), __func__);
550484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
550584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 54), 0);
550684417368Smartijn 
550784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
550884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
550984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
551084417368Smartijn 
551184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
551284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
551384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
551484417368Smartijn 	varbind.name.n_subid--;
551584417368Smartijn 	agentx_response(ax_s, buf, INDEXNONEAVAILABLE, 1, &varbind, 1);
551684417368Smartijn 
551784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
551884417368Smartijn 	    &varbind, 1);
551984417368Smartijn }
552084417368Smartijn 
552184417368Smartijn void
backend_error_getnext_indexnotallocated(void)552284417368Smartijn backend_error_getnext_indexnotallocated(void)
552384417368Smartijn {
552484417368Smartijn 	struct sockaddr_storage ss;
552584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
552684417368Smartijn 	socklen_t salen;
552784417368Smartijn 	int snmp_s, ax_s;
552884417368Smartijn 	uint32_t sessionid;
552984417368Smartijn 	struct varbind varbind = {
553084417368Smartijn 		.type = TYPE_NULL,
553184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 55),
553284417368Smartijn 	};
553384417368Smartijn 	int32_t requestid;
553484417368Smartijn 	char buf[1024];
553584417368Smartijn 	size_t n;
553684417368Smartijn 
553784417368Smartijn 	ax_s = agentx_connect(axsocket);
553884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
553984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 55), __func__);
554084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
554184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 55), 0);
554284417368Smartijn 
554384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
554484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
554584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
554684417368Smartijn 
554784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
554884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
554984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
555084417368Smartijn 	varbind.name.n_subid--;
555184417368Smartijn 	agentx_response(ax_s, buf, INDEXNOTALLOCATED, 1, &varbind, 1);
555284417368Smartijn 
555384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
555484417368Smartijn 	    &varbind, 1);
555584417368Smartijn }
555684417368Smartijn 
555784417368Smartijn void
backend_error_getnext_unsupportedcontext(void)555884417368Smartijn backend_error_getnext_unsupportedcontext(void)
555984417368Smartijn {
556084417368Smartijn 	struct sockaddr_storage ss;
556184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
556284417368Smartijn 	socklen_t salen;
556384417368Smartijn 	int snmp_s, ax_s;
556484417368Smartijn 	uint32_t sessionid;
556584417368Smartijn 	struct varbind varbind = {
556684417368Smartijn 		.type = TYPE_NULL,
556784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 56),
556884417368Smartijn 	};
556984417368Smartijn 	int32_t requestid;
557084417368Smartijn 	char buf[1024];
557184417368Smartijn 	size_t n;
557284417368Smartijn 
557384417368Smartijn 	ax_s = agentx_connect(axsocket);
557484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
557584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 56), __func__);
557684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
557784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 56), 0);
557884417368Smartijn 
557984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
558084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
558184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
558284417368Smartijn 
558384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
558484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
558584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
558684417368Smartijn 	varbind.name.n_subid--;
558784417368Smartijn 	agentx_response(ax_s, buf, UNSUPPORTEDCONTEXT, 1, &varbind, 1);
558884417368Smartijn 
558984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
559084417368Smartijn 	    &varbind, 1);
559184417368Smartijn }
559284417368Smartijn 
559384417368Smartijn void
backend_error_getnext_duplicateregistration(void)559484417368Smartijn backend_error_getnext_duplicateregistration(void)
559584417368Smartijn {
559684417368Smartijn 	struct sockaddr_storage ss;
559784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
559884417368Smartijn 	socklen_t salen;
559984417368Smartijn 	int snmp_s, ax_s;
560084417368Smartijn 	uint32_t sessionid;
560184417368Smartijn 	struct varbind varbind = {
560284417368Smartijn 		.type = TYPE_NULL,
560384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 57),
560484417368Smartijn 	};
560584417368Smartijn 	int32_t requestid;
560684417368Smartijn 	char buf[1024];
560784417368Smartijn 	size_t n;
560884417368Smartijn 
560984417368Smartijn 	ax_s = agentx_connect(axsocket);
561084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
561184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 57), __func__);
561284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
561384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 57), 0);
561484417368Smartijn 
561584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
561684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
561784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
561884417368Smartijn 
561984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
562084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
562184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
562284417368Smartijn 	varbind.name.n_subid--;
562384417368Smartijn 	agentx_response(ax_s, buf, DUPLICATEREGISTRATION, 1, &varbind, 1);
562484417368Smartijn 
562584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
562684417368Smartijn 	    &varbind, 1);
562784417368Smartijn }
562884417368Smartijn 
562984417368Smartijn void
backend_error_getnext_unknownregistration(void)563084417368Smartijn backend_error_getnext_unknownregistration(void)
563184417368Smartijn {
563284417368Smartijn 	struct sockaddr_storage ss;
563384417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
563484417368Smartijn 	socklen_t salen;
563584417368Smartijn 	int snmp_s, ax_s;
563684417368Smartijn 	uint32_t sessionid;
563784417368Smartijn 	struct varbind varbind = {
563884417368Smartijn 		.type = TYPE_NULL,
563984417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 58),
564084417368Smartijn 	};
564184417368Smartijn 	int32_t requestid;
564284417368Smartijn 	char buf[1024];
564384417368Smartijn 	size_t n;
564484417368Smartijn 
564584417368Smartijn 	ax_s = agentx_connect(axsocket);
564684417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
564784417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 58), __func__);
564884417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
564984417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 58), 0);
565084417368Smartijn 
565184417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
565284417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
565384417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
565484417368Smartijn 
565584417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
565684417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
565784417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
565884417368Smartijn 	varbind.name.n_subid--;
565984417368Smartijn 	agentx_response(ax_s, buf, UNKNOWNREGISTRATION, 1, &varbind, 1);
566084417368Smartijn 
566184417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
566284417368Smartijn 	    &varbind, 1);
566384417368Smartijn }
566484417368Smartijn 
566584417368Smartijn void
backend_error_getnext_parseerror(void)566684417368Smartijn backend_error_getnext_parseerror(void)
566784417368Smartijn {
566884417368Smartijn 	struct sockaddr_storage ss;
566984417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
567084417368Smartijn 	socklen_t salen;
567184417368Smartijn 	int snmp_s, ax_s;
567284417368Smartijn 	uint32_t sessionid;
567384417368Smartijn 	struct varbind varbind = {
567484417368Smartijn 		.type = TYPE_NULL,
567584417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 59),
567684417368Smartijn 	};
567784417368Smartijn 	int32_t requestid;
567884417368Smartijn 	char buf[1024];
567984417368Smartijn 	size_t n;
568084417368Smartijn 
568184417368Smartijn 	ax_s = agentx_connect(axsocket);
568284417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
568384417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 59), __func__);
568484417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
568584417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 59), 0);
568684417368Smartijn 
568784417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
568884417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
568984417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
569084417368Smartijn 
569184417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
569284417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
569384417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
569484417368Smartijn 	varbind.name.n_subid--;
569584417368Smartijn 	agentx_response(ax_s, buf, PARSEERROR, 1, &varbind, 1);
569684417368Smartijn 
569784417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
569884417368Smartijn 	    &varbind, 1);
569984417368Smartijn }
570084417368Smartijn 
570184417368Smartijn void
backend_error_getnext_requestdenied(void)570284417368Smartijn backend_error_getnext_requestdenied(void)
570384417368Smartijn {
570484417368Smartijn 	struct sockaddr_storage ss;
570584417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
570684417368Smartijn 	socklen_t salen;
570784417368Smartijn 	int snmp_s, ax_s;
570884417368Smartijn 	uint32_t sessionid;
570984417368Smartijn 	struct varbind varbind = {
571084417368Smartijn 		.type = TYPE_NULL,
571184417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 60),
571284417368Smartijn 	};
571384417368Smartijn 	int32_t requestid;
571484417368Smartijn 	char buf[1024];
571584417368Smartijn 	size_t n;
571684417368Smartijn 
571784417368Smartijn 	ax_s = agentx_connect(axsocket);
571884417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
571984417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 60), __func__);
572084417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
572184417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 60), 0);
572284417368Smartijn 
572384417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
572484417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
572584417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
572684417368Smartijn 
572784417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
572884417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
572984417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
573084417368Smartijn 	varbind.name.n_subid--;
573184417368Smartijn 	agentx_response(ax_s, buf, REQUESTDENIED, 1, &varbind, 1);
573284417368Smartijn 
573384417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
573484417368Smartijn 	    &varbind, 1);
573584417368Smartijn }
573684417368Smartijn 
573784417368Smartijn void
backend_error_getnext_processingerror(void)573884417368Smartijn backend_error_getnext_processingerror(void)
573984417368Smartijn {
574084417368Smartijn 	struct sockaddr_storage ss;
574184417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
574284417368Smartijn 	socklen_t salen;
574384417368Smartijn 	int snmp_s, ax_s;
574484417368Smartijn 	uint32_t sessionid;
574584417368Smartijn 	struct varbind varbind = {
574684417368Smartijn 		.type = TYPE_NULL,
574784417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 61),
574884417368Smartijn 	};
574984417368Smartijn 	int32_t requestid;
575084417368Smartijn 	char buf[1024];
575184417368Smartijn 	size_t n;
575284417368Smartijn 
575384417368Smartijn 	ax_s = agentx_connect(axsocket);
575484417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
575584417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 61), __func__);
575684417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
575784417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 61), 0);
575884417368Smartijn 
575984417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
576084417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
576184417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
576284417368Smartijn 
576384417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
576484417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
576584417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
576684417368Smartijn 	varbind.name.n_subid--;
576784417368Smartijn 	agentx_response(ax_s, buf, PROCESSINGERROR, 1, &varbind, 1);
576884417368Smartijn 
576984417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
577084417368Smartijn 	    &varbind, 1);
577184417368Smartijn }
577284417368Smartijn 
577384417368Smartijn void
backend_error_getnext_nonstandard(void)577484417368Smartijn backend_error_getnext_nonstandard(void)
577584417368Smartijn {
577684417368Smartijn 	struct sockaddr_storage ss;
577784417368Smartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
577884417368Smartijn 	socklen_t salen;
577984417368Smartijn 	int snmp_s, ax_s;
578084417368Smartijn 	uint32_t sessionid;
578184417368Smartijn 	struct varbind varbind = {
578284417368Smartijn 		.type = TYPE_NULL,
578384417368Smartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 62),
578484417368Smartijn 	};
578584417368Smartijn 	int32_t requestid;
578684417368Smartijn 	char buf[1024];
578784417368Smartijn 	size_t n;
578884417368Smartijn 
578984417368Smartijn 	ax_s = agentx_connect(axsocket);
579084417368Smartijn 	sessionid = agentx_open(ax_s, 0, 0,
579184417368Smartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 62), __func__);
579284417368Smartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
579384417368Smartijn 	    OID_ARG(MIB_BACKEND_ERROR, 62), 0);
579484417368Smartijn 
579584417368Smartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
579684417368Smartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
579784417368Smartijn 	requestid = snmpv2_getnext(snmp_s, community, 0, &varbind, 1);
579884417368Smartijn 
579984417368Smartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
580084417368Smartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
580184417368Smartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
580284417368Smartijn 	varbind.name.n_subid--;
580384417368Smartijn 	agentx_response(ax_s, buf, 0xFFFF, 1, &varbind, 1);
580484417368Smartijn 
580584417368Smartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
580684417368Smartijn 	    &varbind, 1);
580784417368Smartijn }
5808b38eec6cSmartijn 
5809b38eec6cSmartijn void
backend_error_getbulk_firstrepetition(void)5810b38eec6cSmartijn backend_error_getbulk_firstrepetition(void)
5811b38eec6cSmartijn {
5812b38eec6cSmartijn 	struct sockaddr_storage ss;
5813b38eec6cSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
5814b38eec6cSmartijn 	socklen_t salen;
5815b38eec6cSmartijn 	int snmp_s, ax_s;
5816b38eec6cSmartijn 	uint32_t sessionid;
5817b38eec6cSmartijn 	struct varbind varbind = {
5818b38eec6cSmartijn 		.type = TYPE_NULL,
5819b38eec6cSmartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 63),
5820b38eec6cSmartijn 	};
5821b38eec6cSmartijn 	int32_t requestid;
5822b38eec6cSmartijn 	char buf[1024];
5823b38eec6cSmartijn 	size_t n;
5824b38eec6cSmartijn 
5825b38eec6cSmartijn 	ax_s = agentx_connect(axsocket);
5826b38eec6cSmartijn 	sessionid = agentx_open(ax_s, 0, 0,
5827b38eec6cSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 63), __func__);
5828b38eec6cSmartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
5829b38eec6cSmartijn 	    OID_ARG(MIB_BACKEND_ERROR, 63), 0);
5830b38eec6cSmartijn 
5831b38eec6cSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
5832b38eec6cSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
5833b38eec6cSmartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, &varbind, 1);
5834b38eec6cSmartijn 
5835b38eec6cSmartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
5836b38eec6cSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
5837b38eec6cSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
5838b38eec6cSmartijn 	varbind.name.n_subid--;
5839b38eec6cSmartijn 	agentx_response(ax_s, buf, GENERR, 1, &varbind, 1);
5840b38eec6cSmartijn 
5841b38eec6cSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
5842b38eec6cSmartijn 	    &varbind, 1);
5843b38eec6cSmartijn }
5844b38eec6cSmartijn 
5845b38eec6cSmartijn void
backend_error_getbulk_secondrepetition(void)5846b38eec6cSmartijn backend_error_getbulk_secondrepetition(void)
5847b38eec6cSmartijn {
5848b38eec6cSmartijn 	struct sockaddr_storage ss;
5849b38eec6cSmartijn 	struct sockaddr *sa = (struct sockaddr *)&ss;
5850b38eec6cSmartijn 	socklen_t salen;
5851b38eec6cSmartijn 	int snmp_s, ax_s;
5852b38eec6cSmartijn 	uint32_t sessionid;
5853b38eec6cSmartijn 	struct varbind varbind = {
5854b38eec6cSmartijn 		.type = TYPE_NULL,
5855b38eec6cSmartijn 		.name = OID_STRUCT(MIB_BACKEND_ERROR, 64),
5856b38eec6cSmartijn 		.data.int32 = 1
5857b38eec6cSmartijn 	};
5858b38eec6cSmartijn 	int32_t requestid;
5859b38eec6cSmartijn 	char buf[1024];
5860b38eec6cSmartijn 	size_t n;
5861b38eec6cSmartijn 
5862b38eec6cSmartijn 	ax_s = agentx_connect(axsocket);
5863b38eec6cSmartijn 	sessionid = agentx_open(ax_s, 0, 0,
5864b38eec6cSmartijn 	    OID_ARG(MIB_SUBAGENT_BACKEND_ERROR, 64), __func__);
5865b38eec6cSmartijn 	agentx_register(ax_s, sessionid, 0, 0, 127, 0,
5866b38eec6cSmartijn 	    OID_ARG(MIB_BACKEND_ERROR, 64), 0);
5867b38eec6cSmartijn 
5868b38eec6cSmartijn 	salen = snmp_resolve(SOCK_DGRAM, hostname, servname, sa);
5869b38eec6cSmartijn 	snmp_s = snmp_connect(SOCK_DGRAM, sa, salen);
5870b38eec6cSmartijn 	requestid = snmpv2_getbulk(snmp_s, community, 0, 0, 2, &varbind, 1);
5871b38eec6cSmartijn 
5872b38eec6cSmartijn 	varbind.name.subid[varbind.name.n_subid++] = 0;
5873b38eec6cSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
5874b38eec6cSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
5875b38eec6cSmartijn 	varbind.type = TYPE_INTEGER;
5876b38eec6cSmartijn 	agentx_response(ax_s, buf, 0, NOERROR, &varbind, 1);
5877b38eec6cSmartijn 	varbind.name.subid[varbind.name.n_subid - 1] = 1;
5878b38eec6cSmartijn 	n = agentx_read(ax_s, buf, sizeof(buf), 1000);
5879b38eec6cSmartijn 	agentx_getnext_handle(__func__, buf, n, 0, sessionid, NULL, &varbind, 1);
5880b38eec6cSmartijn 	varbind.name.subid[varbind.name.n_subid - 1] = 0;
5881b38eec6cSmartijn 	varbind.type = TYPE_NULL;
5882b38eec6cSmartijn 	agentx_response(ax_s, buf, 0, GENERR, &varbind, 1);
5883b38eec6cSmartijn 
5884b38eec6cSmartijn 	varbind.name.n_subid--;
5885b38eec6cSmartijn 	snmpv2_response_validate(snmp_s, 1000, community, requestid, GENERR, 1,
5886b38eec6cSmartijn 	    &varbind, 1);
5887b38eec6cSmartijn }
5888