summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/snmp.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/usr.sbin/relayd/snmp.c b/usr.sbin/relayd/snmp.c
index 5715cb8396d..dafd2f2e1f7 100644
--- a/usr.sbin/relayd/snmp.c
+++ b/usr.sbin/relayd/snmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmp.c,v 1.21 2014/12/21 00:54:49 guenther Exp $ */
+/* $OpenBSD: snmp.c,v 1.22 2015/01/22 15:21:05 reyk Exp $ */
/*
* Copyright (c) 2008 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -290,14 +290,17 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
/* FALLTHROUGH */
case AGENTX_GET:
case AGENTX_GET_NEXT:
- if ((resp = snmp_agentx_response_pdu(0, AGENTX_ERR_NONE, 0)) == NULL) {
- log_warn("%s unable to allocate response pdu", __func__);
+ if ((resp = snmp_agentx_response_pdu(0,
+ AGENTX_ERR_NONE, 0)) == NULL) {
+ log_warn("%s unable to allocate response pdu",
+ __func__);
break;
}
repetitions = 0;
repeat:
while (pdu->datalen > sizeof(struct agentx_hdr)) {
- uint32_t infoendidx, infoentryendidx, infoentryidxendidx;
+ uint32_t infoendidx, infoentryendidx,
+ infoentryidxendidx;
erridx++;
@@ -313,25 +316,27 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
else
infoendidx = UINT32_MAX;
if (sr.end.o_n >= OIDIDX_relaydInfo + 1 + 1)
- infoentryendidx = sr.end.o_id[OIDIDX_relaydInfo + 1];
+ infoentryendidx =
+ sr.end.o_id[OIDIDX_relaydInfo + 1];
else
infoentryendidx = UINT32_MAX;
if (sr.end.o_n >= OIDIDX_relaydInfo + 2 + 1)
- infoentryidxendidx = sr.end.o_id[OIDIDX_relaydInfo + 2];
+ infoentryidxendidx =
+ sr.end.o_id[OIDIDX_relaydInfo + 2];
else
infoentryidxendidx = UINT32_MAX;
bcopy(&sr.start, &oid, sizeof(oid));
/*
- * If the requested OID is not part of the registered MIB,
- * return "no such object", per RFC
+ * If the requested OID is not part of the registered
+ * MIB, return "no such object", per RFC
*/
if (snmp_oid_cmp(&relaydinfooid, &oid) == -1) {
if (snmp_agentx_varbind(resp, &sr.start,
AGENTX_NO_SUCH_OBJECT, NULL, 0) == -1) {
- log_warn("%s: unable to generate response",
- __func__);
+ log_warn("%s: unable to generate"
+ " response", __func__);
snmp_agentx_pdu_free(resp);
resp = NULL;
}
@@ -339,7 +344,7 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
}
if (oid.o_n != OIDIDX_relaydInfo + 2 + 1) {
- /* GET requests require the exact OID to exist */
+ /* GET requests require the exact OID */
if (pdu->hdr->type == AGENTX_GET)
goto nosuchinstance;
@@ -369,7 +374,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 1)
break;
if (snmp_redirect(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -383,7 +389,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 2)
break;
if (snmp_relay(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -397,7 +404,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 3)
break;
if (snmp_router(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -411,7 +419,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 4)
break;
if (snmp_netroute(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -425,7 +434,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 5)
break;
if (snmp_host(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -439,7 +449,8 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 6)
break;
if (snmp_session(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
@@ -453,26 +464,28 @@ snmp_agentx_process(struct agentx_handle *h, struct agentx_pdu *pdu, void *arg)
if (infoendidx < 7)
break;
if (snmp_table(env, &oid, resp, getnext,
- infoentryendidx, infoentryidxendidx, sr.include) == 0)
+ infoentryendidx, infoentryidxendidx,
+ sr.include) == 0)
break;
if (!getnext)
goto nosuchinstance;
if (snmp_agentx_varbind(resp, &oid,
AGENTX_END_OF_MIB_VIEW, NULL, 0) == -1) {
- log_warn("%s: unable to generate response",
- __func__);
+ log_warn("%s: unable to generate"
+ " response", __func__);
snmp_agentx_pdu_free(resp);
resp = NULL;
}
goto reply;
default:
nosuchinstance:
- log_warnx("unknown index %i", oid.o_id[OIDIDX_relaydInfo]);
+ log_warnx("unknown index %i",
+ oid.o_id[OIDIDX_relaydInfo]);
if (snmp_agentx_varbind(resp, &sr.start,
AGENTX_NO_SUCH_INSTANCE, NULL, 0) == -1) {
- log_warn("%s: unable to generate response",
- __func__);
+ log_warn("%s: unable to generate"
+ " response", __func__);
snmp_agentx_pdu_free(resp);
resp = NULL;
}
@@ -880,7 +893,8 @@ snmp_router_byidx(struct relayd *env, u_int *instanceidx, u_int *objectidx,
/* Lexographical ordering */
/* 1) try the next instance index */
- if (router->rt_conf.id == *instanceidx && !include)
+ if ((router->rt_conf.id == *instanceidx) &&
+ !include)
router = TAILQ_NEXT(router, rt_entry);
if (router) {
*instanceidx = router->rt_conf.id;
@@ -1391,7 +1405,7 @@ snmp_netroute(struct relayd *env, struct snmp_oid *oid,
{
struct netroute *nr;
u_int32_t addrtype;
- u_int instanceidx, objectidx;
+ u_int instanceidx, objectidx;
instanceidx = oid->o_id[OIDIDX_relaydInfo + 2];
objectidx = oid->o_id[OIDIDX_relaydInfo + 1];
@@ -1559,7 +1573,7 @@ snmp_session(struct relayd *env, struct snmp_oid *oid, struct agentx_pdu *resp,
struct timeval tv, now;
time_t ticks;
struct rsession *session;
- u_int instanceidx, objectidx;
+ u_int instanceidx, objectidx;
u_int32_t status, pid, port, addrtype;
instanceidx = oid->o_id[OIDIDX_relaydInfo + 2];
@@ -1683,7 +1697,7 @@ snmp_table(struct relayd *env, struct snmp_oid *oid, struct agentx_pdu *resp,
int getnext, uint32_t einstanceidx, uint32_t eobjectidx, u_int include)
{
struct table *table;
- u_int instanceidx, objectidx;
+ u_int instanceidx, objectidx;
u_int32_t status;
instanceidx = oid->o_id[OIDIDX_relaydInfo + 2];