xref: /openbsd/regress/usr.bin/snmp/Makefile (revision 8fada270)
1# $OpenBSD: Makefile,v 1.8 2024/04/17 06:18:18 claudio Exp $
2
3SNMP?=			/usr/bin/snmp
4SNMPD?=			/usr/sbin/snmpd -f ${.OBJDIR}/snmpd.conf
5
6SNMPGET?=		${SNMP} get
7SNMPGETNEXT?=		${SNMP} getnext
8SNMPBULKGET?=		${SNMP}	bulkget
9SNMPWALK?=		${SNMP} walk
10SNMPBULKWALK?=		${SNMP} bulkwalk
11SNMPSET?=		${SNMP} set
12SNMPTRAP?=		${SNMP} trap
13
14REGRESS_ROOT_TARGETS=	start stop
15REGRESS_SETUP_ONCE=	start
16REGRESS_TARGETS=
17REGRESS_CLEANUP=	stop
18REGRESS_SKIP_TARGETS=
19CLEANFILES=
20
21IFIDX!=			ifconfig egress | awk '/index/{print $$2; exit}'
22IFLLADDR!=		ifconfig egress | awk '/lladdr/{gsub(":", " ", $$2); print toupper($$2); exit}'
23
24CLEANFILES+=		snmpd.conf
25snmpd.conf: Makefile
26	printf 'listen_addr="127.0.0.1"\n' > snmpd.conf
27	printf 'listen6_addr="::1"\n\n' >> snmpd.conf
28	printf '# Restrict daemon to listen on localhost only\n' >> snmpd.conf
29	printf 'listen on $$listen_addr snmpv1 snmpv2c snmpv3\n' >> snmpd.conf
30	printf 'listen on tcp $$listen_addr snmpv1 snmpv2c snmpv3\n' >> snmpd.conf
31	printf 'listen on $$listen6_addr snmpv1 snmpv2c snmpv3\n' >> snmpd.conf
32	printf 'listen on tcp $$listen6_addr snmpv1 snmpv2c snmpv3\n' >> snmpd.conf
33	printf 'listen on $$listen_addr notify snmpv1 snmpv2c snmpv3\n\n' >> snmpd.conf
34	printf 'agentx path "/tmp/agentx"\n\n' >> snmpd.conf
35	printf 'read-only community public\n' >> snmpd.conf
36	printf 'read-write community private\n' >> snmpd.conf
37	printf 'trap community public\n\n' >> snmpd.conf
38	printf '# (ab)use sysContact for DisplayString (255a) testing\n' >> snmpd.conf
39	printf 'system contact "Reyk Fl\303\266ter"\n' >> snmpd.conf
40	printf 'system services 74\n\n' >> snmpd.conf
41	printf '# Provide static user-defined SNMP OIDs\n' >> snmpd.conf
42	printf 'oid 1.3.6.1.4.1.30155.42.3.1 name testStringValue read-only string "Test"\n' >> snmpd.conf
43	printf 'oid 1.3.6.1.4.1.30155.42.3.2 name testStringValue read-only string "abcdefghijklmnopqrstuvwxyz"\n' >> snmpd.conf
44	printf 'oid 1.3.6.1.4.1.30155.42.3.3 name testIntValue read-write string a\n' >> snmpd.conf
45	printf 'oid 1.3.6.1.4.1.30155.42.3.4 name testIntValue read-write integer 1\n' >> snmpd.conf
46	printf '# (ab)use usmUserName for SnmpAdminString (255t) tests\n' >> snmpd.conf
47	printf 'oid 1.3.6.1.6.3.15.1.2.2.1.2.1 name testStringValue read-only string "Reyk Fl\303\266ter"\n' >> snmpd.conf
48	printf 'oid 1.3.6.1.6.3.15.1.2.2.1.2.2 name testStringValue read-only string "Reyk Fl\303ter"\n' >> snmpd.conf
49	printf "# 256 a's\n" >> snmpd.conf
50	printf 'oid 1.3.6.1.6.3.15.1.2.2.1.2.3 name testStringValue read-only string "%s"\n' "$$(jot -ba 256 | tr -d '\n')" >> snmpd.conf
51	printf "# 254 a's + replacement character\n" >> snmpd.conf
52	printf 'oid 1.3.6.1.6.3.15.1.2.2.1.2.4 name testStringValue read-only string "%s\357\277\275"\n\n' "$$(jot -ba 254 | tr -d '\n')" >> snmpd.conf
53	printf '# Enable SNMPv3 USM with authentication, encryption and two defined users\n' >> snmpd.conf
54	printf 'seclevel none\n\n' >> snmpd.conf
55	printf 'user md5_des authkey testtest auth hmac-md5 enckey testtest enc des\n' >> snmpd.conf
56	printf 'user md5_aes authkey testtest auth hmac-md5 enckey testtest enc aes\n' >> snmpd.conf
57	printf 'user sha1_des authkey testtest auth hmac-sha1 enckey testtest enc des\n' >> snmpd.conf
58	printf 'user sha1_aes authkey testtest auth hmac-sha1 enckey testtest enc aes\n' >> snmpd.conf
59	printf 'user sha224_des authkey testtest auth hmac-sha224 enckey testtest enc des\n' >> snmpd.conf
60	printf 'user sha224_aes authkey testtest auth hmac-sha224 enckey testtest enc aes\n' >> snmpd.conf
61	printf 'user sha256_des authkey testtest auth hmac-sha256 enckey testtest enc des\n' >> snmpd.conf
62	printf 'user sha256_aes authkey testtest auth hmac-sha256 enckey testtest enc aes\n' >> snmpd.conf
63	printf 'user sha384_des authkey testtest auth hmac-sha384 enckey testtest enc des\n' >> snmpd.conf
64	printf 'user sha384_aes authkey testtest auth hmac-sha384 enckey testtest enc aes\n' >> snmpd.conf
65	printf 'user sha512_des authkey testtest auth hmac-sha512 enckey testtest enc des\n' >> snmpd.conf
66	printf 'user sha512_aes authkey testtest auth hmac-sha512 enckey testtest enc aes\n\n' >> snmpd.conf
67	printf 'trap handle 1.3 "${.OBJDIR}/traphandle.sh"\n' >> snmpd.conf
68
69CLEANFILES+=		traphandle.sh
70traphandle.sh: Makefile
71	printf '#!/bin/sh\n\n' > traphandle.sh
72	printf 'while read line; do\n' >> traphandle.sh
73	printf '\tprintf "%%s\\n" "$$line" >> ${.OBJDIR}/trap_output\n' >> traphandle.sh
74	printf 'done\n' >> traphandle.sh
75	chmod +x traphandle.sh
76
77CLEANFILES+=		trap_output
78trap_output: Makefile
79	touch trap_output
80	chmod a+rw trap_output
81
82start: stop snmpd.conf traphandle.sh trap_output
83	rm -f /tmp/agentx 2>/dev/null
84	${SUDO} ${SNMPD}
85	@(i=0; \
86	while [ ! -S /tmp/agentx ]; do \
87		i=$$((i + 1)); \
88		[ $$i -eq 100 ] && ( \
89			printf "%s\n" '${SUDO} pkill -xf "${SNMPD}"'; \
90			printf "Failed to start snmpd\n" >&2; \
91			${SUDO} pkill -xf "${SNMPD}"; \
92			exit 1; \
93		); \
94		sleep 0.1; \
95	done;)
96
97stop:
98	-${SUDO} pkill -xf "${SNMPD}"
99
100### AGENT FORMAT
101
102REGRESS_TARGETS+=	agent_udp_v4
103CLEANFILES+=		agent_udp_v4.res agent_udp_v4.exp
104agent_udp_v4:
105	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
106	${SNMPGET} -v2c -cpublic udp:127.0.0.1 sysServices.0 > $@.res
107	diff -up $@.exp $@.res
108
109REGRESS_TARGETS+=	agent_udp_v4_port
110CLEANFILES+=		agent_udp_v4_port.res agent_udp_v4_port.exp
111agent_udp_v4_port:
112	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
113	${SNMPGET} -v2c -cpublic udp:127.0.0.1:161 sysServices.0 > $@.res
114	diff -up $@.exp $@.res
115
116REGRESS_TARGETS+=	agent_udp_v4_service
117CLEANFILES+=		agent_udp_v4_service.res agent_udp_v4_service.exp
118agent_udp_v4_service:
119	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
120	${SNMPGET} -v2c -cpublic udp:127.0.0.1:snmp sysServices.0 > $@.res
121	diff -up $@.exp $@.res
122
123REGRESS_TARGETS+=	agent_v4_port
124CLEANFILES+=		agent_v4_port.res agent_v4_port.exp
125agent_v4_port:
126	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
127	${SNMPGET} -v2c -cpublic 127.0.0.1:161 sysServices.0 > $@.res
128	diff -up $@.exp $@.res
129
130REGRESS_TARGETS+=	agent_v4_service
131CLEANFILES+=		agent_v4_service.res agent_v4_service.exp
132agent_v4_service:
133	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
134	${SNMPGET} -v2c -cpublic 127.0.0.1:snmp sysServices.0 > $@.res
135	diff -up $@.exp $@.res
136
137REGRESS_TARGETS+=	agent_tcp_v4
138CLEANFILES+=		agent_tcp_v4.res agent_tcp_v4.exp
139agent_tcp_v4:
140	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
141	${SNMPGET} -v2c -cpublic tcp:127.0.0.1 sysServices.0 > $@.res
142	diff -up $@.exp $@.res
143
144REGRESS_TARGETS+=	agent_tcp_v4_port
145CLEANFILES+=		agent_tcp_v4_port.res agent_tcp_v4_port.exp
146agent_tcp_v4_port:
147	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
148	${SNMPGET} -v2c -cpublic tcp:127.0.0.1:161 sysServices.0 > $@.res
149	diff -up $@.exp $@.res
150
151REGRESS_TARGETS+=	agent_udp_udp6plain
152CLEANFILES+=		agent_udp_udp6plain.res agent_udp_udp6plain.exp
153agent_udp_udp6plain:
154	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
155	${SNMPGET} -v2c -cpublic udp6:::1:snmp sysServices.0 > $@.res
156	diff -up $@.exp $@.res
157
158REGRESS_TARGETS+=	agent_udp_udp6bracket
159CLEANFILES+=		agent_udp_udp6bracket.res agent_udp_udp6bracket.exp
160agent_udp_udp6bracket:
161	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
162	${SNMPGET} -v2c -cpublic udp6:[::1] sysServices.0 > $@.res
163	diff -up $@.exp $@.res
164
165REGRESS_TARGETS+=	agent_udp_udp6bracket_port
166CLEANFILES+=		agent_udp_udp6bracket_port.res agent_udp_udp6bracket_port.exp
167agent_udp_udp6bracket_port:
168	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
169	${SNMPGET} -v2c -cpublic udp6:[::1]:snmp sysServices.0 > $@.res
170	diff -up $@.exp $@.res
171
172REGRESS_TARGETS+=	agent_udp_UDP6plain
173CLEANFILES+=		agent_udp_UDP6plain.res agent_udp_UDP6plain.exp
174agent_udp_UDP6plain:
175	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
176	${SNMPGET} -v2c -cpublic UDP6:::1:snmp sysServices.0 > $@.res
177	diff -up $@.exp $@.res
178
179REGRESS_TARGETS+=	agent_udp_UDP6bracket
180CLEANFILES+=		agent_udp_UDP6bracket.res agent_udp_UDP6bracket.exp
181agent_udp_UDP6bracket:
182	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
183	${SNMPGET} -v2c -cpublic UDP6:[::1] sysServices.0 > $@.res
184	diff -up $@.exp $@.res
185
186REGRESS_TARGETS+=	agent_udp_UDP6bracket_port
187CLEANFILES+=		agent_udp_UDP6bracket_port.res agent_udp_UDP6bracket_port.exp
188agent_udp_UDP6bracket_port:
189	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
190	${SNMPGET} -v2c -cpublic UDP6:[::1]:snmp sysServices.0 > $@.res
191	diff -up $@.exp $@.res
192
193REGRESS_TARGETS+=	agent_udp_udpv6plain
194CLEANFILES+=		agent_udp_udpv6plain.res agent_udp_udpv6plain.exp
195agent_udp_udpv6plain:
196	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
197	${SNMPGET} -v2c -cpublic udpv6:::1:snmp sysServices.0 > $@.res
198	diff -up $@.exp $@.res
199
200REGRESS_TARGETS+=	agent_udp_udpv6bracket
201CLEANFILES+=		agent_udp_udpv6bracket.res agent_udp_udpv6bracket.exp
202agent_udp_udpv6bracket:
203	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
204	${SNMPGET} -v2c -cpublic udpv6:[::1] sysServices.0 > $@.res
205	diff -up $@.exp $@.res
206
207REGRESS_TARGETS+=	agent_udp_udpv6bracket_port
208CLEANFILES+=		agent_udp_udpv6bracket_port.res agent_udp_udpv6bracket_port.exp
209agent_udp_udpv6bracket_port:
210	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
211	${SNMPGET} -v2c -cpublic udpv6:[::1]:snmp sysServices.0 > $@.res
212	diff -up $@.exp $@.res
213
214REGRESS_TARGETS+=	agent_udp_UDPv6plain
215CLEANFILES+=		agent_udp_UDPv6plain.res agent_udp_UDPv6plain.exp
216agent_udp_UDPv6plain:
217	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
218	${SNMPGET} -v2c -cpublic UDPv6:::1:snmp sysServices.0 > $@.res
219	diff -up $@.exp $@.res
220
221REGRESS_TARGETS+=	agent_udp_UDPv6bracket
222CLEANFILES+=		agent_udp_UDPv6bracket.res agent_udp_UDPv6bracket.exp
223agent_udp_UDPv6bracket:
224	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
225	${SNMPGET} -v2c -cpublic UDPv6:[::1] sysServices.0 > $@.res
226	diff -up $@.exp $@.res
227
228REGRESS_TARGETS+=	agent_udp_UDPv6bracket_port
229CLEANFILES+=		agent_udp_UDPv6bracket_port.res agent_udp_UDPv6bracket_port.exp
230agent_udp_UDPv6bracket_port:
231	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
232	${SNMPGET} -v2c -cpublic UDPv6:[::1]:snmp sysServices.0 > $@.res
233	diff -up $@.exp $@.res
234
235REGRESS_TARGETS+=	agent_udp_udpipv6plain
236CLEANFILES+=		agent_udp_udpipv6plain.res agent_udp_udpipv6plain.exp
237agent_udp_udpipv6plain:
238	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
239	${SNMPGET} -v2c -cpublic udpipv6:::1:snmp sysServices.0 > $@.res
240	diff -up $@.exp $@.res
241
242REGRESS_TARGETS+=	agent_udp_udpipv6bracket
243CLEANFILES+=		agent_udp_udpipv6bracket.res agent_udp_udpipv6bracket.exp
244agent_udp_udpipv6bracket:
245	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
246	${SNMPGET} -v2c -cpublic udpipv6:[::1] sysServices.0 > $@.res
247	diff -up $@.exp $@.res
248
249REGRESS_TARGETS+=	agent_udp_udpipv6bracket_port
250CLEANFILES+=		agent_udp_udpipv6bracket_port.res agent_udp_udpipv6bracket_port.exp
251agent_udp_udpipv6bracket_port:
252	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
253	${SNMPGET} -v2c -cpublic udpipv6:[::1]:snmp sysServices.0 > $@.res
254	diff -up $@.exp $@.res
255
256REGRESS_TARGETS+=	agent_udp_UDPIPv6plain
257CLEANFILES+=		agent_udp_UDPIPv6plain.res agent_udp_UDPIPv6plain.exp
258agent_udp_UDPIPv6plain:
259	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
260	${SNMPGET} -v2c -cpublic UDPIPv6:::1:snmp sysServices.0 > $@.res
261	diff -up $@.exp $@.res
262
263REGRESS_TARGETS+=	agent_udp_UDPIPv6bracket
264CLEANFILES+=		agent_udp_UDPIPv6bracket.res agent_udp_UDPIPv6bracket.exp
265agent_udp_UDPIPv6bracket:
266	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
267	${SNMPGET} -v2c -cpublic UDPIPv6:[::1] sysServices.0 > $@.res
268	diff -up $@.exp $@.res
269
270REGRESS_TARGETS+=	agent_udp_UDPIPv6bracket_port
271CLEANFILES+=		agent_udp_UDPIPv6bracket_port.res agent_udp_UDPIPv6bracket_port.exp
272agent_udp_UDPIPv6bracket_port:
273	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
274	${SNMPGET} -v2c -cpublic UDPIPv6:[::1]:snmp sysServices.0 > $@.res
275	diff -up $@.exp $@.res
276
277REGRESS_TARGETS+=	agent_tcp_tcp6plain
278CLEANFILES+=		agent_tcp_tcp6plain.res agent_tcp_tcp6plain.exp
279agent_tcp_tcp6plain:
280	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
281	${SNMPGET} -v2c -cpublic tcp6:::1:161 sysServices.0 > $@.res
282	diff -up $@.exp $@.res
283
284REGRESS_TARGETS+=	agent_tcp_tcp6bracket
285CLEANFILES+=		agent_tcp_tcp6bracket.res agent_tcp_tcp6bracket.exp
286agent_tcp_tcp6bracket:
287	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
288	${SNMPGET} -v2c -cpublic tcp6:[::1] sysServices.0 > $@.res
289	diff -up $@.exp $@.res
290
291REGRESS_TARGETS+=	agent_tcp_tcp6bracket_port
292CLEANFILES+=		agent_tcp_tcp6bracket_port.res agent_tcp_tcp6bracket_port.exp
293agent_tcp_tcp6bracket_port:
294	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
295	${SNMPGET} -v2c -cpublic tcp6:[::1]:161 sysServices.0 > $@.res
296	diff -up $@.exp $@.res
297
298REGRESS_TARGETS+=	agent_tcp_TCP6plain
299CLEANFILES+=		agent_tcp_TCP6plain.res agent_tcp_TCP6plain.exp
300agent_tcp_TCP6plain:
301	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
302	${SNMPGET} -v2c -cpublic TCP6:::1:161 sysServices.0 > $@.res
303	diff -up $@.exp $@.res
304
305REGRESS_TARGETS+=	agent_tcp_TCP6bracket
306CLEANFILES+=		agent_tcp_TCP6bracket.res agent_tcp_TCP6bracket.exp
307agent_tcp_TCP6bracket:
308	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
309	${SNMPGET} -v2c -cpublic TCP6:[::1] sysServices.0 > $@.res
310	diff -up $@.exp $@.res
311
312REGRESS_TARGETS+=	agent_tcp_TCP6bracket_port
313CLEANFILES+=		agent_tcp_TCP6bracket_port.res agent_tcp_TCP6bracket_port.exp
314agent_tcp_TCP6bracket_port:
315	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
316	${SNMPGET} -v2c -cpublic TCP6:[::1]:161 sysServices.0 > $@.res
317	diff -up $@.exp $@.res
318
319REGRESS_TARGETS+=	agent_tcp_tcpv6plain
320CLEANFILES+=		agent_tcp_tcpv6plain.res agent_tcp_tcpv6plain.exp
321agent_tcp_tcpv6plain:
322	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
323	${SNMPGET} -v2c -cpublic tcpv6:::1:161 sysServices.0 > $@.res
324	diff -up $@.exp $@.res
325
326REGRESS_TARGETS+=	agent_tcp_tcpv6bracket
327CLEANFILES+=		agent_tcp_tcpv6bracket.res agent_tcp_tcpv6bracket.exp
328agent_tcp_tcpv6bracket:
329	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
330	${SNMPGET} -v2c -cpublic tcpv6:[::1] sysServices.0 > $@.res
331	diff -up $@.exp $@.res
332
333REGRESS_TARGETS+=	agent_tcp_tcpv6bracket_port
334CLEANFILES+=		agent_tcp_tcpv6bracket_port.res agent_tcp_tcpv6bracket_port.exp
335agent_tcp_tcpv6bracket_port:
336	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
337	${SNMPGET} -v2c -cpublic tcpv6:[::1]:161 sysServices.0 > $@.res
338	diff -up $@.exp $@.res
339
340REGRESS_TARGETS+=	agent_tcp_TCPv6plain
341CLEANFILES+=		agent_tcp_TCPv6plain.res agent_tcp_TCPv6plain.exp
342agent_tcp_TCPv6plain:
343	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
344	${SNMPGET} -v2c -cpublic TCPv6:::1:161 sysServices.0 > $@.res
345	diff -up $@.exp $@.res
346
347REGRESS_TARGETS+=	agent_tcp_TCPv6bracket
348CLEANFILES+=		agent_tcp_TCPv6bracket.res agent_tcp_TCPv6bracket.exp
349agent_tcp_TCPv6bracket:
350	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
351	${SNMPGET} -v2c -cpublic TCPv6:[::1] sysServices.0 > $@.res
352	diff -up $@.exp $@.res
353
354REGRESS_TARGETS+=	agent_tcp_TCPv6bracket_port
355CLEANFILES+=		agent_tcp_TCPv6bracket_port.res agent_tcp_TCPv6bracket_port.exp
356agent_tcp_TCPv6bracket_port:
357	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
358	${SNMPGET} -v2c -cpublic TCPv6:[::1]:161 sysServices.0 > $@.res
359	diff -up $@.exp $@.res
360
361REGRESS_TARGETS+=	agent_tcp_TCPv6bracket_port
362CLEANFILES+=		agent_tcp_TCPv6bracket_port.res agent_tcp_TCPv6bracket_port.exp
363agent_tcp_tcpipv6plain:
364	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
365	${SNMPGET} -v2c -cpublic tcpipv6:::1:161 sysServices.0 > $@.res
366	diff -up $@.exp $@.res
367
368REGRESS_TARGETS+=	agent_tcp_tcpipv6bracket
369CLEANFILES+=		agent_tcp_tcpipv6bracket.res agent_tcp_tcpipv6bracket.exp
370agent_tcp_tcpipv6bracket:
371	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
372	${SNMPGET} -v2c -cpublic tcpipv6:[::1] sysServices.0 > $@.res
373	diff -up $@.exp $@.res
374
375REGRESS_TARGETS+=	agent_tcp_tcpipv6bracket_port
376CLEANFILES+=		agent_tcp_tcpipv6bracket_port.res agent_tcp_tcpipv6bracket_port.exp
377agent_tcp_tcpipv6bracket_port:
378	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
379	${SNMPGET} -v2c -cpublic tcpipv6:[::1]:161 sysServices.0 > $@.res
380	diff -up $@.exp $@.res
381
382REGRESS_TARGETS+=	agent_tcp_TCPIPv6plain
383CLEANFILES+=		agent_tcp_TCPIPv6plain.res agent_tcp_TCPIPv6plain.exp
384agent_tcp_TCPIPv6plain:
385	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
386	${SNMPGET} -v2c -cpublic TCPIPv6:::1:161 sysServices.0 > $@.res
387	diff -up $@.exp $@.res
388
389REGRESS_TARGETS+=	agent_tcp_TCPIPv6bracket
390CLEANFILES+=		agent_tcp_TCPIPv6bracket.res agent_tcp_TCPIPv6bracket.exp
391agent_tcp_TCPIPv6bracket:
392	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
393	${SNMPGET} -v2c -cpublic TCPIPv6:[::1] sysServices.0 > $@.res
394	diff -u $@.exp $@.res
395
396REGRESS_TARGETS+=	agent_tcp_TCPIPv6bracket_port
397CLEANFILES+=		agent_tcp_TCPIPv6bracket_port.res agent_tcp_TCPIPv6bracket_port.exp
398agent_tcp_TCPIPv6bracket_port:
399	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
400	${SNMPGET} -v2c -cpublic TCPIPv6:[::1]:161 sysServices.0 > $@.res
401	diff -up $@.exp $@.res
402
403### USM
404
405REGRESS_TARGETS+=	usm_noauthnopriv
406CLEANFILES+=		usm_noauthnopriv.res usm_noauthnopriv.exp
407usm_noauthnopriv:
408	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
409	${SNMPGET} -v3 -l noauthnopriv -u md5_des 127.0.0.1 sysServices.0 > $@.res
410	diff -up $@.exp $@.res
411
412REGRESS_TARGETS+=	usm_authnopriv_md5
413CLEANFILES+=		usm_authnopriv_md5.res usm_authnopriv_md5.exp
414usm_authnopriv_md5:
415	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
416	${SNMPGET} -v3 -l authnopriv -u md5_des -a md5 -A testtest 127.0.0.1 sysServices.0 > $@.res
417	diff -up $@.exp $@.res
418
419REGRESS_TARGETS+=	usm_authnopriv_sha1
420CLEANFILES+=		usm_authnopriv_sha1.res usm_authnopriv_sha1.exp
421usm_authnopriv_sha1:
422	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
423	${SNMPGET} -v3 -l authnopriv -u sha1_des -a sha -A testtest 127.0.0.1 sysServices.0 > $@.res
424	diff -up $@.exp $@.res
425
426REGRESS_TARGETS+=	usm_authnopriv_sha224
427CLEANFILES+=		usm_authnopriv_sha224.res usm_authnopriv_sha224.exp
428usm_authnopriv_sha224:
429	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
430	${SNMPGET} -v3 -l authnopriv -u sha224_des -a sha-224 -A testtest 127.0.0.1 sysServices.0 > $@.res
431	diff -up $@.exp $@.res
432
433REGRESS_TARGETS+=	usm_authnopriv_sha256
434CLEANFILES+=		usm_authnopriv_sha256.res usm_authnopriv_sha256.exp
435usm_authnopriv_sha256:
436	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
437	${SNMPGET} -v3 -l authnopriv -u sha256_des -a sha-256 -A testtest 127.0.0.1 sysServices.0 > $@.res
438	diff -up $@.exp $@.res
439
440REGRESS_TARGETS+=	usm_authnopriv_sha384
441CLEANFILES+=		usm_authnopriv_sha384.res usm_authnopriv_sha384.exp
442usm_authnopriv_sha384:
443	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
444	${SNMPGET} -v3 -l authnopriv -u sha384_des -a sha-384 -A testtest 127.0.0.1 sysServices.0 > $@.res
445	diff -up $@.exp $@.res
446
447REGRESS_TARGETS+=	usm_authnopriv_sha512
448CLEANFILES+=		usm_authnopriv_sha512.res usm_authnopriv_sha512.exp
449usm_authnopriv_sha512:
450	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
451	${SNMPGET} -v3 -l authnopriv -u sha512_des -a sha-512 -A testtest 127.0.0.1 sysServices.0 > $@.res
452	diff -up $@.exp $@.res
453
454REGRESS_TARGETS+=	usm_authpriv_md5_des
455CLEANFILES+=		usm_authpriv_md5_des.res usm_authpriv_md5_des.exp
456usm_authpriv_md5_des:
457	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
458	${SNMPGET} -v3 -l authpriv -u md5_des -a md5 -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
459	diff -up $@.exp $@.res
460
461REGRESS_TARGETS+=	usm_authpriv_md5_aes
462CLEANFILES+=		usm_authpriv_md5_aes.res usm_authpriv_md5_aes.exp
463usm_authpriv_md5_aes:
464	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
465	${SNMPGET} -v3 -l authpriv -u md5_aes -a md5 -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
466	diff -up $@.exp $@.res
467
468REGRESS_TARGETS+=	usm_authpriv_sha1_des
469CLEANFILES+=		usm_authpriv_sha1_des.res usm_authpriv_sha1_des.exp
470usm_authpriv_sha1_des:
471	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
472	${SNMPGET} -v3 -l authpriv -u sha1_des -a sha -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
473	diff -up $@.exp $@.res
474
475REGRESS_TARGETS+=	usm_authpriv_sha1_aes
476CLEANFILES+=		usm_authpriv_sha1_aes.res usm_authpriv_sha1_aes.exp
477usm_authpriv_sha1_aes:
478	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
479	${SNMPGET} -v3 -l authpriv -u sha1_aes -a sha -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
480	diff -up $@.exp $@.res
481
482REGRESS_TARGETS+=	usm_authpriv_sha224_des
483CLEANFILES+=		usm_authpriv_sha224_des.res usm_authpriv_sha224_des.exp
484usm_authpriv_sha224_des:
485	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
486	${SNMPGET} -v3 -l authpriv -u sha224_des -a sha-224 -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
487	diff -up $@.exp $@.res
488
489REGRESS_TARGETS+=	usm_authpriv_sha224_aes
490CLEANFILES+=		usm_authpriv_sha224_aes.res usm_authpriv_sha224_aes.exp
491usm_authpriv_sha224_aes:
492	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
493	${SNMPGET} -v3 -l authpriv -u sha224_aes -a sha-224 -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
494	diff -up $@.exp $@.res
495
496REGRESS_TARGETS+=	usm_authpriv_sha256_des
497CLEANFILES+=		usm_authpriv_sha256_des.res usm_authpriv_sha256_des.exp
498usm_authpriv_sha256_des:
499	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
500	${SNMPGET} -v3 -l authpriv -u sha256_des -a sha-256 -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
501	diff -up $@.exp $@.res
502
503REGRESS_TARGETS+=	usm_authpriv_sha256_aes
504CLEANFILES+=		usm_authpriv_sha256_aes.res usm_authpriv_sha256_aes.exp
505usm_authpriv_sha256_aes:
506	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
507	${SNMPGET} -v3 -l authpriv -u sha256_aes -a sha-256 -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
508	diff -up $@.exp $@.res
509
510REGRESS_TARGETS+=	usm_authpriv_sha384_des
511CLEANFILES+=		usm_authpriv_sha384_des.res usm_authpriv_sha384_des.exp
512usm_authpriv_sha384_des:
513	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
514	${SNMPGET} -v3 -l authpriv -u sha384_des -a sha-384 -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
515	diff -up $@.exp $@.res
516
517REGRESS_TARGETS+=	usm_authpriv_sha384_aes
518CLEANFILES+=		usm_authpriv_sha384_aes.res usm_authpriv_sha384_aes.exp
519usm_authpriv_sha384_aes:
520	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
521	${SNMPGET} -v3 -l authpriv -u sha384_aes -a sha-384 -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
522	diff -up $@.exp $@.res
523
524REGRESS_TARGETS+=	usm_authpriv_sha512_des
525CLEANFILES+=		usm_authpriv_sha512_des.res usm_authpriv_sha512_des.exp
526usm_authpriv_sha512_des:
527	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
528	${SNMPGET} -v3 -l authpriv -u sha512_des -a sha-512 -A testtest -x des -X testtest 127.0.0.1 sysServices.0 > $@.res
529	diff -up $@.exp $@.res
530
531REGRESS_TARGETS+=	usm_authpriv_sha512_aes
532CLEANFILES+=		usm_authpriv_sha512_aes.res usm_authpriv_sha512_aes.exp
533usm_authpriv_sha512_aes:
534	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
535	${SNMPGET} -v3 -l authpriv -u sha512_aes -a sha-512 -A testtest -x aes -X testtest 127.0.0.1 sysServices.0 > $@.res
536	diff -up $@.exp $@.res
537
538### OUTPUT FORMAT
539
540REGRESS_TARGETS+=	output_string
541CLEANFILES+=		output_string.exp output_string.res
542output_string:
543	printf "sysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
544	${SNMPGET} -v2c -cpublic 127.0.0.1 sysDescr.0 > $@.res
545	diff -up $@.exp $@.res
546
547REGRESS_TARGETS+=	output_integer
548CLEANFILES+=		output_integer.res output_integer.exp
549output_integer:
550	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
551	${SNMPGET} -v2c -cpublic 127.0.0.1 sysServices.0 > $@.res
552	diff -up $@.exp $@.res
553
554REGRESS_TARGETS+=	output_oid
555CLEANFILES+=		output_oid.res output_oid.exp
556output_oid:
557# The OID name used here is not compatible with net-snmp, so this
558# might change in the future.
559	printf "sysObjectID.0 = OID: localSystem.1\n" > $@.exp
560	${SNMPGET} -v2c -cpublic 127.0.0.1 sysObjectID.0 > $@.res
561	diff -up $@.exp $@.res
562
563REGRESS_TARGETS+=	output_hexstring
564CLEANFILES+=		output_hexstring.res output_hexstring.exp
565.if ${IFIDX} == ""
566REGRESS_SKIP_TARGETS+=	output_hexstring
567.endif
568output_hexstring:
569# (Ab)use table for known unknown Hex-string. In this case: lladdr
570	printf "ifPhysAddress.%d = Hex-STRING: %s\n" "${IFIDX}" "${IFLLADDR}" > $@.exp
571	${SNMPGET} -v2c -cpublic 127.0.0.1 ifPhysAddress.${IFIDX} > $@.res
572	diff -up $@.exp $@.res
573
574REGRESS_TARGETS+=	output_ipstring
575CLEANFILES+=		output_ipstring.res output_ipstring.exp
576output_ipstring:
577	printf "ipAdEntAddr.127.0.0.1 = IpAddress: 127.0.0.1\n" > $@.exp
578	${SNMPGET} -v2c -cpublic 127.0.0.1 ipAdEntAddr.127.0.0.1 > $@.res
579	diff -up $@.exp $@.res
580
581REGRESS_TARGETS+=	output_quiettype_string
582CLEANFILES+=		output_quiettype_string.res output_quiettype_string.exp
583output_quiettype_string:
584	printf "sysDescr.0 = %s\n" "$$(uname -a)" > $@.exp
585	${SNMPGET} -v2c -cpublic -OQ 127.0.0.1 sysDescr.0 > $@.res
586	diff -up $@.exp $@.res
587
588REGRESS_TARGETS+=	output_quiettype_integer
589CLEANFILES+=		output_quiettype_integer.res output_quiettype_integer.exp
590output_quiettype_integer:
591	printf "sysServices.0 = 74\n" > $@.exp
592	${SNMPGET} -v2c -cpublic -OQ 127.0.0.1 sysServices.0 > $@.res
593	diff -up $@.exp $@.res
594
595REGRESS_TARGETS+=	output_quiettype_oid
596CLEANFILES+=		output_quiettype_oid.res output_quiettype_oid.exp
597output_quiettype_oid:
598# The OID name used here is not compatible with net-snmp, so this
599# might change in the future.
600	printf "sysObjectID.0 = localSystem.1\n" > $@.exp
601	${SNMPGET} -v2c -cpublic -OQ 127.0.0.1 sysObjectID.0 > $@.res
602	diff -up $@.exp $@.res
603
604REGRESS_TARGETS+=	output_quiettype_ipstring
605CLEANFILES+=		output_quiettype_ipstring.res output_quiettype_ipstring.exp
606output_quiettype_ipstring:
607	printf "ipAdEntAddr.127.0.0.1 = 127.0.0.1\n" > $@.exp
608	${SNMPGET} -v2c -cpublic -OQ 127.0.0.1 ipAdEntAddr.127.0.0.1 > $@.res
609	diff -up $@.exp $@.res
610
611REGRESS_TARGETS+=	output_quiettype_hexstring
612CLEANFILES+=		output_quiettype_hexstring.res output_quiettype_hexstring.exp
613.if ${IFIDX} == ""
614REGRESS_SKIP_TARGETS+=	output_quiettype_hexstring
615.endif
616output_quiettype_hexstring:
617# (Ab)use table for known unknown Hex-string. In this case: lladdr
618	printf "ifPhysAddress.%d = %s\n" "${IFIDX}" "${IFLLADDR}" > $@.exp
619	${SNMPGET} -v2c -cpublic -OQ 127.0.0.1 ifPhysAddress.${IFIDX} > $@.res
620	diff -up $@.exp $@.res
621
622REGRESS_TARGETS+=	output_varbind_string
623CLEANFILES+=		output_varbind_string.res output_varbind_string.exp
624output_varbind_string:
625	printf "STRING: %s\n" "$$(uname -a)" > $@.exp
626	${SNMPGET} -v2c -cpublic -Ov 127.0.0.1 sysDescr.0 > $@.res
627	diff -up $@.exp $@.res
628
629REGRESS_TARGETS+=	output_varbind_integer
630CLEANFILES+=		output_varbind_integer.res output_varbind_integer.exp
631output_varbind_integer:
632	printf "INTEGER: 74\n" > $@.exp
633	${SNMPGET} -v2c -cpublic -Ov 127.0.0.1 sysServices.0 > $@.res
634	diff -up $@.exp $@.res
635
636REGRESS_TARGETS+=	output_varbind_oid
637CLEANFILES+=		output_varbind_oid.res output_varbind_oid.exp
638output_varbind_oid:
639# The OID name used here is not compatible with net-snmp, so this
640# might change in the future.
641	printf "OID: localSystem.1\n" > $@.exp
642	${SNMPGET} -v2c -cpublic -Ov 127.0.0.1 sysObjectID.0 > $@.res
643	diff -up $@.exp $@.res
644
645REGRESS_TARGETS+=	output_varbind_ipstring
646CLEANFILES+=		output_varbind_ipstring.res output_varbind_ipstring.exp
647output_varbind_ipstring:
648	printf "IpAddress: 127.0.0.1\n" > $@.exp
649	${SNMPGET} -v2c -cpublic -Ov 127.0.0.1 ipAdEntAddr.127.0.0.1 > $@.res
650	diff -up $@.exp $@.res
651
652REGRESS_TARGETS+=	output_varbind_hexstring
653CLEANFILES+=		output_varbind_hexstring.res output_varbind_hexstring.exp
654.if ${IFIDX} == ""
655REGRESS_SKIP_TARGETS+=	output_varbind_hexstring
656.endif
657output_varbind_hexstring:
658# (Ab)use table for known unknown Hex-string. In this case: lladdr
659	printf "Hex-STRING: %s\n" "${IFLLADDR}" > $@.exp
660	${SNMPGET} -v2c -cpublic -Ov 127.0.0.1 ifPhysAddress.${IFIDX} > $@.res
661	diff -up $@.exp $@.res
662
663REGRESS_TARGETS+=	output_quiettype_varbind
664CLEANFILES+=		output_quiettype_varbind.res output_quiettype_varbind.exp
665output_quiettype_varbind:
666	uname -a > $@.exp
667	${SNMPGET} -v2c -cpublic -OvQ 127.0.0.1 sysDescr.0 > $@.res
668	diff -up $@.exp $@.res
669
670REGRESS_TARGETS+=	output_ascii
671CLEANFILES+=		output_ascii.res output_ascii.exp
672.if ${IFIDX} == ""
673REGRESS_SKIP_TARGETS+=	output_ascii
674.endif
675output_ascii:
676# Not a full test, since a mac-address can contain all kind of weirdness,
677# so no guarantee that we handle everything. But I don't know a better
678# alternative at this moment.
679# Abuse $@.res for intermediate variable for easier cleanup.
680	printf 'ifPhysAddress.%d = STRING: "' "${IFIDX}" > $@.exp
681	printf "%s\n" "${IFLLADDR}" | tr ' ' '\n' | while read byte; do printf "\x$${byte}" | tr -c '[:print:]' '.'; done >> $@.exp
682	printf '"\n' >> $@.exp
683	${SNMPGET} -v2c -cpublic -Oa 127.0.0.1 ifPhysAddress.${IFIDX} > $@.res
684	diff -up $@.exp $@.res
685
686REGRESS_TARGETS+=	output_fulloid_mib
687CLEANFILES+=		output_fulloid_mib.res output_fulloid_mib.exp
688output_fulloid_mib:
689	printf ".iso.org.dod.internet.mgmt.mib_2.system.sysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
690	${SNMPGET} -v2c -cpublic -Of 127.0.0.1 sysDescr.0 > $@.res
691	diff -up $@.exp $@.res
692
693REGRESS_TARGETS+=	output_fulloid_varbind
694CLEANFILES+=		output_fulloid_varbind.res output_fulloid_varbind.exp
695output_fulloid_varbind:
696	printf ".iso.org.dod.internet.mgmt.mib_2.system.sysObjectID.0 = OID: .iso.org.dod.internet.private.enterprises.openBSD.localSystem.1\n" > $@.exp
697	${SNMPGET} -v2c -cpublic -Of 127.0.0.1 sysObjectID.0 > $@.res
698	diff -up $@.exp $@.res
699
700REGRESS_TARGETS+=	output_numoid_mib
701CLEANFILES+=		output_numoid_mib.res output_numoid_mib.exp
702output_numoid_mib:
703	printf ".1.3.6.1.2.1.1.1.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
704	${SNMPGET} -v2c -cpublic -On 127.0.0.1 sysDescr.0 > $@.res
705	diff -up $@.exp $@.res
706
707REGRESS_TARGETS+=	output_numoid_varbind
708CLEANFILES+=		output_numoid_varbind.res output_numoid_varbind.exp
709output_numoid_varbind:
710	printf ".1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.30155.23.1\n" > $@.exp
711	${SNMPGET} -v2c -cpublic -On 127.0.0.1 sysObjectID.0 > $@.res
712	diff -up $@.exp $@.res
713
714REGRESS_TARGETS+=	output_quiet_string
715CLEANFILES+=		output_quiet_string.res output_quiet_string.exp
716output_quiet_string:
717	printf "sysDescr.0 %s\n" "$$(uname -a)" > $@.exp
718	${SNMPGET} -v2c -cpublic -Oq 127.0.0.1 sysDescr.0 > $@.res
719	diff -up $@.exp $@.res
720
721REGRESS_TARGETS+=	output_quiet_integer
722CLEANFILES+=		output_quiet_integer.res output_quiet_integer.exp
723output_quiet_integer:
724	printf "sysServices.0 74\n" > $@.exp
725	${SNMPGET} -v2c -cpublic -Oq 127.0.0.1 sysServices.0 > $@.res
726	diff -up $@.exp $@.res
727
728REGRESS_TARGETS+=	output_quiet_oid
729CLEANFILES+=		output_quiet_oid.res output_quiet_oid.exp
730output_quiet_oid:
731# The OID name used here is not compatible with net-snmp, so this
732# might change in the future.
733	printf "sysObjectID.0 localSystem.1\n" > $@.exp
734	${SNMPGET} -v2c -cpublic -Oq 127.0.0.1 sysObjectID.0 > $@.res
735	diff -up $@.exp $@.res
736
737REGRESS_TARGETS+=	output_quiet_ipstring
738CLEANFILES+=		output_quiet_ipstring.res output_quiet_ipstring.exp
739output_quiet_ipstring:
740	printf "ipAdEntAddr.127.0.0.1 127.0.0.1\n" > $@.exp
741	${SNMPGET} -v2c -cpublic -Oq 127.0.0.1 ipAdEntAddr.127.0.0.1 > $@.res
742	diff -up $@.exp $@.res
743
744REGRESS_TARGETS+=	output_quiet_hexstring
745CLEANFILES+=		output_quiet_hexstring.res output_quiet_hexstring.exp
746.if ${IFIDX} == ""
747REGRESS_SKIP_TARGETS+=	output_quiet_hexstring
748.endif
749output_quiet_hexstring:
750# (Ab)use table for known unknown Hex-string. In this case: lladdr
751	printf "ifPhysAddress.%d %s\n" "${IFIDX}" "${IFLLADDR}" > $@.exp
752	${SNMPGET} -v2c -cpublic -Oq 127.0.0.1 ifPhysAddress.${IFIDX} > $@.res
753	diff -up $@.exp $@.res
754
755REGRESS_TARGETS+=	output_hex
756CLEANFILES+=		output_hex.res output_hex.exp
757output_hex:
758# From testing net-snmp: hex mode wraps each 16 bytes.
759# It happens that od does the same.
760	printf "localTest.3.2.0 = Hex-STRING: " > $@.exp
761	printf "abcdefghijklmnopqrstuvwxyz" | od -An -tx1 | sed 's/^ *//;s/  / /g;s/ *$$//' | tr '[:lower:]' '[:upper:]' >> $@.exp
762	${SNMPGET} -v2c -cpublic -Ox 127.0.0.1 1.3.6.1.4.1.30155.42.3.2.0 > $@.res
763	diff -up $@.exp $@.res
764
765# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
766REGRESS_TARGETS+=	output_displayhint_255t_utf8
767REGRESS_EXPECTED_FAILURES:= output_displayhint_255t_utf8
768CLEANFILES+=		output_displayhint_255t_utf8.res output_displayhint_255t_utf8.exp
769output_displayhint_255t_utf8:
770	printf "STRING: Reyk Flöter\n" > $@.exp
771	LC_ALL=en_US.UTF-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.1.0 > $@.res
772	diff -up $@.exp $@.res
773
774# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
775REGRESS_TARGETS+=	output_displayhint_255t_ascii
776REGRESS_EXPECTED_FAILURES+= output_displayhint_255t_ascii
777CLEANFILES+=		output_displayhint_255t_ascii.res output_displayhint_255t_ascii.exp
778output_displayhint_255t_ascii:
779	printf "STRING: Reyk Fl.ter\n" > $@.exp
780	LC_ALL=C ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.1.0 > $@.res
781	diff -up $@.exp $@.res
782
783# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
784REGRESS_TARGETS+=	output_displayhint_255t_invalchar_utf8
785REGRESS_EXPECTED_FAILURES+= output_displayhint_255t_invalchar_utf8
786CLEANFILES+=		output_displayhint_255t_invalchar_utf8.res output_displayhint_255t_invalchar_utf8.exp
787output_displayhint_255t_invalchar_utf8:
788	printf "STRING: Reyk Fl�ter\n" > $@.exp
789	LC_ALL=en_US.UTF-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.2.0 > $@.res
790	diff -up $@.exp $@.res
791
792# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
793REGRESS_TARGETS+=	output_displayhint_255t_invalchar_ascii
794REGRESS_EXPECTED_FAILURES+= output_displayhint_255t_invalchar_ascii
795CLEANFILES+=		output_displayhint_255t_invalchar_ascii.res output_displayhint_255t_invalchar_ascii.exp
796output_displayhint_255t_invalchar_ascii:
797	printf "STRING: Reyk Fl?ter\n" > $@.exp
798	LC_ALL=C ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.2.0 > $@.res
799	diff -up $@.exp $@.res
800
801# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
802REGRESS_TARGETS+=	output_displayhint_255t_truncatefull
803REGRESS_EXPECTED_FAILURES+= output_displayhint_255t_truncatefull
804CLEANFILES+=		output_displayhint_255t_truncatefull.res output_displayhint_255t_truncatefull.exp
805output_displayhint_255t_truncatefull:
806	printf "STRING: %s\n" "$$(jot -ba 255 | tr -d '\n')" > $@.exp
807	LC_ALL=en_US.UTF-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.3.0 > $@.res
808	diff -up $@.exp $@.res
809
810# XXX snmpd(8) setting customer oids under SNMPv2-MIB are not allowed anymore
811REGRESS_TARGETS+=	output_displayhint_255t_truncatehalf
812REGRESS_EXPECTED_FAILURES+= output_displayhint_255t_truncatehalf
813CLEANFILES+=		output_displayhint_255t_truncatehalf.res output_displayhint_255t_truncatehalf.exp
814output_displayhint_255t_truncatehalf:
815	printf "STRING: %s\n" "$$(jot -ba 254 | tr -d '\n')" > $@.exp
816	LC_ALL=en_US.UTF-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.6.3.15.1.2.2.1.2.4.0 > $@.res
817	diff -up $@.exp $@.res
818
819REGRESS_TARGETS+=	output_displayhint_255a_utf8
820CLEANFILES+=		output_displayhint_255a_utf8.res output_displayhint_255a_utf8.exp
821output_displayhint_255a_utf8:
822	printf "STRING: Reyk Fl��ter\n" > $@.exp
823	LC_ALL=en_US.UTF-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.4.0 > $@.res
824	diff -up $@.exp $@.res
825
826REGRESS_TARGETS+=	output_displayhint_255a_ascii
827CLEANFILES+=		output_displayhint_255a_ascii.res output_displayhint_255a_ascii.exp
828output_displayhint_255a_ascii:
829	printf "STRING: Reyk Fl??ter\n" > $@.exp
830	LC_ALL=C-8 ${SNMPGET} -Ov -v2c -cpublic 127.0.0.1 1.3.6.1.2.1.1.4.0 > $@.res
831	diff -up $@.exp $@.res
832
833REGRESS_TARGETS+=	output_displayhint_precedence
834CLEANFILES+=		output_displayhint_precedence.res output_displayhint_precedence.exp
835output_displayhint_precedence:
836	printf "sysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
837	${SNMPGET} -Ox -v2c -cpublic 127.0.0.1 sysDescr.0 > $@.res
838	diff -up $@.exp $@.res
839
840### SNMP GET
841# We already tested most of get in the previous tests.
842# Just test the retrieval of multiple entries
843
844REGRESS_TARGETS+=	get_multiple
845CLEANFILES+=		get_multiple.res get_multiple.exp
846get_multiple:
847	printf "sysServices.0 = INTEGER: 74\nsysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
848	${SNMPGET} -v2c -cpublic 127.0.0.1 sysServices.0 sysDescr.0 > $@.res
849	diff -up $@.exp $@.res
850
851### SNMP GETNEXT
852
853REGRESS_TARGETS+=	getnext_simple
854CLEANFILES+=		getnext_simple.res getnext_simple.exp
855getnext_simple:
856	printf "sysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
857	${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 system > $@.res
858	diff -up $@.exp $@.res
859
860REGRESS_TARGETS+=	getnext_multiple
861CLEANFILES+=		getnext_multiple.res getnext_multiple.exp
862getnext_multiple:
863	printf "sysServices.0 = INTEGER: 74\nsysDescr.0 = STRING: %s\n" "$$(uname -a)" > $@.exp
864	${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 sysLocation.0 system > $@.res
865	diff -up $@.exp $@.res
866
867### SNMP BULKGET
868# Building output manually is large and error prone: Assume get/getnext works
869
870# XXX snmpd(8) currently doesn't have any entries in sysORTable
871REGRESS_TARGETS+=	bulkget_simple
872REGRESS_EXPECTED_FAILURES+= bulkget_simple
873CLEANFILES+=		bulkget_simple.res bulkget_simple.exp
874bulkget_simple:
875	IDX=1; while [ $$IDX -le 4 ]; do ${SNMPGET} -v2c -cpublic 127.0.0.1 sysORDescr.$$IDX; IDX=$$((IDX+1)); done > $@.exp
876	${SNMPBULKGET} -v2c -cpublic -Cr4 127.0.0.1 sysORDescr > $@.res
877	diff -up $@.exp $@.res
878
879# XXX snmpd(8) currently doesn't have any entries in sysORTable
880REGRESS_TARGETS+=	bulkget_multi
881REGRESS_EXPECTED_FAILURES+= bulkget_multi
882CLEANFILES+=		bulkget_multi.res bulkget_multi.exp
883bulkget_multi:
884	> $@.exp
885	IDX=1; while [ $$IDX -le 4 ]; do ${SNMPGET} -v2c -cpublic 127.0.0.1 sysORDescr.$$IDX sysORID.$$IDX; IDX=$$((IDX+1)); done >> $@.exp
886	${SNMPBULKGET} -v2c -cpublic -Cr4 127.0.0.1 sysORDescr sysORID > $@.res
887	diff -up $@.exp $@.res
888
889# XXX snmpd(8) currently doesn't have any entries in sysORTable
890REGRESS_TARGETS+=	bulkget_nonrep
891REGRESS_EXPECTED_FAILURES+= bulkget_nonrep
892CLEANFILES+=		bulkget_nonrep.res bulkget_nonrep.exp
893bulkget_nonrep:
894	${SNMPGET} -v2c -cpublic 127.0.0.1 sysDescr.0 > $@.exp
895	IDX=1; while [ $$IDX -le 4 ]; do ${SNMPGET} -v2c -cpublic 127.0.0.1 sysORDescr.$$IDX; IDX=$$((IDX+1)); done >> $@.exp
896	${SNMPBULKGET} -v2c -cpublic -Cn1 -Cr4 127.0.0.1 sysDescr sysORDescr > $@.res
897	diff -up $@.exp $@.res
898
899# XXX snmpd(8) currently doesn't have any entries in sysORTable
900REGRESS_TARGETS+=	bulkget_maxrep
901REGRESS_EXPECTED_FAILURES+= bulkget_maxrep
902CLEANFILES+=		bulkget_maxrep.res bulkget_maxrep.exp
903bulkget_maxrep:
904	IDX=1; while [ $$IDX -le 4 ]; do ${SNMPGET} -v2c -cpublic 127.0.0.1 sysORDescr.$$IDX; IDX=$$((IDX+1)); done > $@.exp
905	${SNMPBULKGET} -v2c -cpublic -Cr4 127.0.0.1 sysORDescr > $@.res
906	diff -up $@.exp $@.res
907
908### SNMP WALK
909# Building output manually is large and error prone: Assume getnext works
910# Skip sysUptime, since it's a timer
911
912REGRESS_TARGETS+=	walk_simple
913CLEANFILES+=		walk_simple.res walk_simple.exp
914walk_simple:
915	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
916	${SNMPWALK} -v2c -cpublic 127.0.0.1 system | grep -v ^sysUpTime.0 > $@.res
917	diff -up $@.exp $@.res
918
919REGRESS_TARGETS+=	walk_end
920CLEANFILES+=		walk_end.res walk_end.exp
921walk_end:
922	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ "$${OID%% *}" == "sysServices.0" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
923	${SNMPWALK} -v2c -cpublic -CE sysServices 127.0.0.1 system | grep -v ^sysUpTime.0 > $@.res
924	diff -up $@.exp $@.res
925
926REGRESS_TARGETS+=	walk_includeoid
927CLEANFILES+=		walk_includeoid.res walk_includeoid.exp
928walk_includeoid:
929	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
930	${SNMPWALK} -v2c -cpublic 127.0.0.1 sysServices.0 > $@.res
931	diff -up $@.exp $@.res
932
933REGRESS_TARGETS+=	walk_excludeoid
934CLEANFILES+=		walk_excludeoid.res walk_excludeoid.exp
935walk_excludeoid:
936	> $@.exp
937	${SNMPWALK} -v2c -cpublic -CI 127.0.0.1 sysServices.0 > $@.res
938	diff -up $@.exp $@.res
939
940REGRESS_TARGETS+=	walk_summary
941CLEANFILES+=		walk_summary.res walk_summary.exp
942walk_summary:
943	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
944	wc -l $@.exp | awk '{printf("Variables found: %d\n", $$1 + 1)}' >> $@.exp
945	${SNMPWALK} -v2c -cpublic -Cp 127.0.0.1 system | grep -v ^sysUpTime.0 > $@.res
946	diff -up $@.exp $@.res
947
948REGRESS_TARGETS+=	walk_skip
949CLEANFILES+=		walk_skip.exp walk_skip.res
950walk_skip:
951	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
952	${SNMPWALK} -v2c -cpublic -Cs sysUpTime 127.0.0.1 system > $@.res
953	diff -up $@.exp $@.res
954
955### SNMP BULKWALK
956
957REGRESS_TARGETS+=	bulkwalk_simple
958CLEANFILES+=		bulkwalk_simple.res bulkwalk_simple.exp
959bulkwalk_simple:
960	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
961	${SNMPBULKWALK} -v2c -cpublic 127.0.0.1 system | grep -v ^sysUpTime.0 > $@.res
962	diff -up $@.exp $@.res
963
964REGRESS_TARGETS+=	bulkwalk_includeoid
965CLEANFILES+=		bulkwalk_includeoid.res bulkwalk_includeoid.exp
966bulkwalk_includeoid:
967	printf "sysServices.0 = INTEGER: 74\n" > $@.exp
968	${SNMPBULKWALK} -v2c -cpublic 127.0.0.1 sysServices.0 > $@.res
969	diff -up $@.exp $@.res
970
971REGRESS_TARGETS+=	bulkwalk_summary
972CLEANFILES+=		bulkwalk_summary.res bulkwalk_summary.exp
973bulkwalk_summary:
974	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
975	wc -l $@.exp | awk '{printf("Variables found: %d\n", $$1 + 1)}' >> $@.exp
976	${SNMPBULKWALK} -v2c -cpublic -Cp 127.0.0.1 system | grep -v ^sysUpTime.0 > $@.res
977	diff -up $@.exp $@.res
978
979REGRESS_TARGETS+=	bulkwalk_skip
980CLEANFILES+=		bulkwalk_skip.exp bulkwalk_skip.res
981bulkwalk_skip:
982	OID=system; while true; do OID="$$(${SNMPGETNEXT} -v2c -cpublic 127.0.0.1 "$$OID")"; [ -n "$${OID%sys*}" ] && break; printf "%s\n" "$${OID}"; OID="$${OID%% *}"; done | grep -v ^sysUpTime.0 > $@.exp
983	${SNMPBULKWALK} -v2c -cpublic -Cs sysUpTime 127.0.0.1 system > $@.res
984	diff -up $@.exp $@.res
985
986### SNMP SET
987
988# XXX snmpd(8) doesn't support set
989REGRESS_TARGETS+=	set_string
990REGRESS_EXPECTED_FAILURES+= set_string
991CLEANFILES+=		set_string.res set_string.exp
992set_string:
993	${SNMPGET} -v2c -cpublic -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.3.0 | awk '{ printf("%sa\n", $$1) }' > $@.exp
994	${SNMPSET} -v2c -cprivate -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.3.0 s $$(cat $@.exp) > $@.res
995	diff -up $@.exp $@.res
996
997REGRESS_TARGETS+=	set_integer
998REGRESS_EXPECTED_FAILURES+= set_integer
999CLEANFILES+=		set_integer.res set_integer.exp
1000set_integer:
1001	${SNMPGET} -v2c -cpublic -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.4.0 | awk '{ print $$1 + 1 }' > $@.exp
1002	${SNMPSET} -v2c -cprivate -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.4.0 i $$(cat $@.exp) > $@.res
1003	diff -up $@.exp $@.res
1004
1005REGRESS_TARGETS+=	set_string_integer
1006REGRESS_EXPECTED_FAILURES+= set_string_integer
1007CLEANFILES+=		set_string_integer.res set_string_integer.exp
1008set_string_integer:
1009	${SNMPGET} -v2c -cpublic -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.3.0 1.3.6.1.4.1.30155.42.3.4.0 | \
1010	    awk 'NR == 1 { printf("%sa\n", $$1) } NR == 2 { print $$1 + 1 }' > $@.exp
1011	${SNMPSET} -v2c -cprivate -Oqv 127.0.0.1 1.3.6.1.4.1.30155.42.3.3.0 s $$(head -1 $@.exp) 1.3.6.1.4.1.30155.42.3.4.0 i $$(tail -1 $@.exp) > $@.res
1012	diff -up $@.exp $@.res
1013
1014### SNMP TRAP
1015
1016TRAP_EXEC!=		${SUDO} su -s /bin/sh _snmpd -c '[ -r ${.OBJDIR}/traphandle.sh ]' > /dev/null 2>&1 && printf 'yes' || printf 'no'
1017
1018REGRESS_TARGETS+=	trap_simple
1019CLEANFILES+=		trap_simple.res trap_simple.exp
1020.if ${TRAP_EXEC} != yes
1021REGRESS_SKIP_TARGETS+=	trap_simple
1022.endif
1023trap_simple:
1024	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1025	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1026	> trap_output
1027	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6
1028# Give snmpd some time to write out the data
1029	sleep 0.1
1030	cp trap_output $@.res
1031	diff -up $@.exp $@.res
1032
1033REGRESS_TARGETS+=	trap_ip
1034CLEANFILES+=		trap_ip.res trap_ip.exp
1035.if ${TRAP_EXEC} != yes
1036REGRESS_SKIP_TARGETS+=	trap_ip
1037.endif
1038trap_ip:
1039	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1040	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1041	printf 'iso.org.dod.8 192.168.1.1\n' >> $@.exp
1042	> trap_output
1043	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 a 192.168.1.1
1044# Give snmpd some time to write out the data
1045	sleep 0.1
1046	cp trap_output $@.res
1047	diff -up $@.exp $@.res
1048
1049REGRESS_TARGETS+=	trap_bitstring
1050CLEANFILES+=		trap_bitstring.res trap_bitstring.exp
1051.if ${TRAP_EXEC} != yes
1052REGRESS_SKIP_TARGETS+=	trap_bitstring
1053.endif
1054trap_bitstring:
1055	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1056	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1057	printf 'iso.org.dod.8 "a"\n' >> $@.exp
1058	> trap_output
1059	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 b '1,2,7'
1060# Give snmpd some time to write out the data
1061	sleep 0.1
1062	cp trap_output $@.res
1063	diff -up $@.exp $@.res
1064
1065REGRESS_TARGETS+=	trap_counter32
1066CLEANFILES+=		trap_counter32.res trap_counter32.exp
1067.if ${TRAP_EXEC} != yes
1068REGRESS_SKIP_TARGETS+=	trap_counter32
1069.endif
1070trap_counter32:
1071	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1072	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1073	printf 'iso.org.dod.8 20\n' >> $@.exp
1074	> trap_output
1075	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 c 20
1076# Give snmpd some time to write out the data
1077	sleep 0.1
1078	cp trap_output $@.res
1079	diff -up $@.exp $@.res
1080
1081REGRESS_TARGETS+=	trap_decimal
1082CLEANFILES+=		trap_decimal.res trap_decimal.exp
1083.if ${TRAP_EXEC} != yes
1084REGRESS_SKIP_TARGETS+=	trap_decimal
1085.endif
1086trap_decimal:
1087	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1088	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1089	printf 'iso.org.dod.8 "hello world"\n' >> $@.exp
1090	> trap_output
1091	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 d '104 101 108 108 111 32 119 111 114 108 100'
1092# Give snmpd some time to write out the data
1093	sleep 0.1
1094	cp trap_output $@.res
1095	diff -up $@.exp $@.res
1096
1097REGRESS_TARGETS+=	trap_integer
1098CLEANFILES+=		trap_integer.res trap_integer.exp
1099.if ${TRAP_EXEC} != yes
1100REGRESS_SKIP_TARGETS+=	trap_integer
1101.endif
1102trap_integer:
1103	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1104	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1105	printf 'iso.org.dod.8 42\n' >> $@.exp
1106	> trap_output
1107	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 i 42
1108# Give snmpd some time to write out the data
1109	sleep 0.1
1110	cp trap_output $@.res
1111	diff -up $@.exp $@.res
1112
1113REGRESS_TARGETS+=	trap_null
1114CLEANFILES+=		trap_null.res trap_null.exp
1115.if ${TRAP_EXEC} != yes
1116REGRESS_SKIP_TARGETS+=	trap_null
1117.endif
1118trap_null:
1119	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1120	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1121	printf 'iso.org.dod.8\n' >> $@.exp
1122	> trap_output
1123	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 n ignored
1124# Give snmpd some time to write out the data
1125	sleep 0.1
1126	cp trap_output $@.res
1127	diff -up $@.exp $@.res
1128
1129REGRESS_TARGETS+=	trap_oid
1130CLEANFILES+=		trap_oid.res trap_oid.exp
1131.if ${TRAP_EXEC} != yes
1132REGRESS_SKIP_TARGETS+=	trap_oid
1133.endif
1134trap_oid:
1135	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1136	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1137	printf 'iso.org.dod.8 iso.org.dod\n' >> $@.exp
1138	> trap_output
1139	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 o 1.3.6
1140# Give snmpd some time to write out the data
1141	sleep 0.1
1142	cp trap_output $@.res
1143	diff -up $@.exp $@.res
1144
1145REGRESS_TARGETS+=	trap_string
1146CLEANFILES+=		trap_string.res trap_string.exp
1147.if ${TRAP_EXEC} != yes
1148REGRESS_SKIP_TARGETS+=	trap_string
1149.endif
1150trap_string:
1151	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1152	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1153	printf 'iso.org.dod.8 "hello world"\n' >> $@.exp
1154	> trap_output
1155	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 s "hello world"
1156# Give snmpd some time to write out the data
1157	sleep 0.1
1158	cp trap_output $@.res
1159	diff -up $@.exp $@.res
1160
1161REGRESS_TARGETS+=	trap_timeticks
1162CLEANFILES+=		trap_timeticks.res trap_timeticks.exp
1163.if ${TRAP_EXEC} != yes
1164REGRESS_SKIP_TARGETS+=	trap_timeticks
1165.endif
1166trap_timeticks:
1167	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1168	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1169	printf 'iso.org.dod.8 420\n' >> $@.exp
1170	> trap_output
1171	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 t 420
1172# Give snmpd some time to write out the data
1173	sleep 0.1
1174	cp trap_output $@.res
1175	diff -up $@.exp $@.res
1176
1177REGRESS_TARGETS+=	trap_unsigned
1178CLEANFILES+=		trap_unsigned.res trap_unsigned.exp
1179.if ${TRAP_EXEC} != yes
1180REGRESS_SKIP_TARGETS+=	trap_unsigned
1181.endif
1182trap_unsigned:
1183	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1184	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1185	printf 'iso.org.dod.8 420\n' >> $@.exp
1186	> trap_output
1187	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 u 420
1188# Give snmpd some time to write out the data
1189	sleep 0.1
1190	cp trap_output $@.res
1191	diff -up $@.exp $@.res
1192
1193REGRESS_TARGETS+=	trap_hex
1194CLEANFILES+=		trap_hex.res trap_hex.exp
1195.if ${TRAP_EXEC} != yes
1196REGRESS_SKIP_TARGETS+=	trap_hex
1197.endif
1198trap_hex:
1199	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1200	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1201	printf 'iso.org.dod.8 "hello world"\n' >> $@.exp
1202	> trap_output
1203	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 x '68 65 6c 6c 6f 20 77 6f 72 6c 64'
1204# Give snmpd some time to write out the data
1205	sleep 0.1
1206	cp trap_output $@.res
1207	diff -up $@.exp $@.res
1208
1209REGRESS_TARGETS+=	trap_multi
1210CLEANFILES+=		trap_multi.res trap_multi.exp
1211.if ${TRAP_EXEC} != yes
1212REGRESS_SKIP_TARGETS+=	trap_multi
1213.endif
1214trap_multi:
1215	printf 'localhost\n127.0.0.1\niso.org.dod.internet.mgmt.mib_2.system.sysUpTime.0 100\n' > $@.exp
1216	printf 'iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTrap.snmpTrapOID.0 iso.org.dod\n' >> $@.exp
1217	printf 'iso.org.dod.8 "hello world"\niso.org.dod.9 42\n' >> $@.exp
1218	> trap_output
1219	${SNMPTRAP} -v2c -cpublic 127.0.0.1 100 1.3.6 1.3.6.8 x '68 65 6c 6c 6f 20 77 6f 72 6c 64' 1.3.6.9 i 42
1220# Give snmpd some time to write out the data
1221	sleep 0.1
1222	cp trap_output $@.res
1223	diff -up $@.exp $@.res
1224
1225.include <bsd.regress.mk>
1226