diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2012-09-18 08:29:10 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2012-09-18 08:29:10 +0000 |
commit | dc2928ca406d1c1a1a8298759657a2492ff99be2 (patch) | |
tree | 4467b5f01f1b60b3ed9cb428cde37a22fdaf5c9a /usr.sbin | |
parent | dd55ef6ccbdca47c30e6113568af799083af3ec1 (diff) |
knf
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/snmpd/control.c | 11 | ||||
-rw-r--r-- | usr.sbin/snmpd/kroute.c | 8 | ||||
-rw-r--r-- | usr.sbin/snmpd/mib.c | 61 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpd.c | 19 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpd.h | 8 | ||||
-rw-r--r-- | usr.sbin/snmpd/snmpe.c | 4 | ||||
-rw-r--r-- | usr.sbin/snmpd/usm.c | 16 |
7 files changed, 65 insertions, 62 deletions
diff --git a/usr.sbin/snmpd/control.c b/usr.sbin/snmpd/control.c index 5352e3a98eb..d28a772c430 100644 --- a/usr.sbin/snmpd/control.c +++ b/usr.sbin/snmpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.15 2012/04/11 08:33:53 deraadt Exp $ */ +/* $OpenBSD: control.c,v 1.16 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -279,8 +279,8 @@ control_dispatch_imsg(int fd, short event, void *arg) if (c->flags & CTL_CONN_NOTIFY) { log_debug("control_dispatch_imsg: " "client requested notify more than once"); - imsg_compose(&c->iev.ibuf, IMSG_CTL_FAIL, 0, 0, -1, - NULL, 0); + imsg_compose(&c->iev.ibuf, IMSG_CTL_FAIL, + 0, 0, -1, NULL, 0); break; } c->flags |= CTL_CONN_NOTIFY; @@ -317,8 +317,9 @@ control_imsg_forward(struct imsg *imsg) TAILQ_FOREACH(c, &ctl_conns, entry) if (c->flags & CTL_CONN_NOTIFY) - imsg_compose(&c->iev.ibuf, imsg->hdr.type, 0, imsg->hdr.pid, - -1, imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE); + imsg_compose(&c->iev.ibuf, imsg->hdr.type, 0, + imsg->hdr.pid, -1, imsg->data, + imsg->hdr.len - IMSG_HEADER_SIZE); } void diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c index 65b745bc387..3b7e08288c6 100644 --- a/usr.sbin/snmpd/kroute.c +++ b/usr.sbin/snmpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.20 2012/09/17 16:43:59 reyk Exp $ */ +/* $OpenBSD: kroute.c,v 1.21 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -150,7 +150,7 @@ kr_init(void) if ((kr_state.ks_ifd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) fatal("kr_init: ioctl socket"); - if ((kr_state.ks_fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) + if ((kr_state.ks_fd = socket(AF_ROUTE, SOCK_RAW, 0)) == -1) fatal("kr_init: route socket"); /* not interested in my own messages */ @@ -423,7 +423,7 @@ kroute6_find(const struct in6_addr *prefix, u_int8_t prefixlen, u_int8_t prio) while (tmp) { if (kroute6_compare(&s, tmp) == 0) kn6 = tmp; - else + else break; tmp = RB_PREV(kroute6_tree, &krt6, kn6); } @@ -486,7 +486,7 @@ kroute6_remove(struct kroute6_node *kr) log_in6addr(&kr->r.prefix), kr->r.prefixlen); return (-1); } - if (kr->next != NULL) { + if (kr->next != NULL) { if (RB_INSERT(kroute6_tree, &krt6, kr->next) != NULL) { log_warnx("kroute6_remove failed to add %s/%u", log_in6addr(&kr->r.prefix), diff --git a/usr.sbin/snmpd/mib.c b/usr.sbin/snmpd/mib.c index fa2cae0b59f..734b6056f59 100644 --- a/usr.sbin/snmpd/mib.c +++ b/usr.sbin/snmpd/mib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mib.c,v 1.58 2012/09/17 16:43:59 reyk Exp $ */ +/* $OpenBSD: mib.c,v 1.59 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2012 Joel Knight <joel@openbsd.org> @@ -395,7 +395,7 @@ mib_usmstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) if (oid->o_oid[OIDIDX_usmStats] == mapping[i].m_id) { *elm = ber_add_integer(*elm, *mapping[i].m_ptr); ber_set_header(*elm, BER_CLASS_APPLICATION, - SNMP_T_COUNTER32); + SNMP_T_COUNTER32); return (0); } } @@ -454,15 +454,15 @@ static struct oid hr_mib[] = { int mib_hrsystemuptime(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { - struct timeval boottime; - int mib[] = { CTL_KERN, KERN_BOOTTIME }; - time_t now; - size_t len; + struct timeval boottime; + int mib[] = { CTL_KERN, KERN_BOOTTIME }; + time_t now; + size_t len; (void)time(&now); len = sizeof(boottime); - if (sysctl(mib, 2, &boottime, &len, NULL, 0) == -1) + if (sysctl(mib, 2, &boottime, &len, NULL, 0) == -1) return (-1); *elm = ber_add_integer(*elm, (now - boottime.tv_sec) * 100); @@ -1482,7 +1482,7 @@ static struct oid openbsd_mib[] = { { MIB(pfLimitStates), OID_RD, mib_pflimits }, { MIB(pfLimitSourceNodes), OID_RD, mib_pflimits }, { MIB(pfLimitFragments), OID_RD, mib_pflimits }, - { MIB(pfLimitMaxTables), OID_RD, mib_pflimits }, + { MIB(pfLimitMaxTables), OID_RD, mib_pflimits }, { MIB(pfLimitMaxTableEntries), OID_RD, mib_pflimits }, { MIB(pfTimeoutTcpFirst), OID_RD, mib_pftimeouts }, { MIB(pfTimeoutTcpOpening), OID_RD, mib_pftimeouts }, @@ -1714,7 +1714,7 @@ mib_pfcounters(struct oid *oid, struct ber_oid *o, struct ber_element **elm) ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); return (0); - } + } } return (-1); } @@ -1741,7 +1741,7 @@ mib_pfscounters(struct oid *oid, struct ber_oid *o, struct ber_element **elm) *elm = ber_add_integer(*elm, s.states); ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_UNSIGNED32); break; - default: + default: for (i = 0; (u_int)i < (sizeof(mapping) / sizeof(mapping[0])); i++) { if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { @@ -1749,7 +1749,7 @@ mib_pfscounters(struct oid *oid, struct ber_oid *o, struct ber_element **elm) ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); return (0); - } + } } return (-1); } @@ -1787,7 +1787,7 @@ mib_pflogif(struct oid *oid, struct ber_oid *o, struct ber_element **elm) case 1: *elm = ber_add_string(*elm, s.ifname); break; - default: + default: for (i = 0; (u_int)i < (sizeof(mapping) / sizeof(mapping[0])); i++) { if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { @@ -1795,7 +1795,7 @@ mib_pflogif(struct oid *oid, struct ber_oid *o, struct ber_element **elm) ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); return (0); - } + } } return (-1); } @@ -1825,7 +1825,7 @@ mib_pfsrctrack(struct oid *oid, struct ber_oid *o, struct ber_element **elm) *elm = ber_add_integer(*elm, s.src_nodes); ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_UNSIGNED32); break; - default: + default: for (i = 0; (u_int)i < (sizeof(mapping) / sizeof(mapping[0])); i++) { if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { @@ -1833,7 +1833,7 @@ mib_pfsrctrack(struct oid *oid, struct ber_oid *o, struct ber_element **elm) ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); return (0); - } + } } return (-1); } @@ -1866,7 +1866,7 @@ mib_pflimits(struct oid *oid, struct ber_oid *o, struct ber_element **elm) if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { pl.index = mapping[i].m_limit; break; - } + } } if (pl.index == PF_LIMIT_MAX) @@ -1922,7 +1922,7 @@ mib_pftimeouts(struct oid *oid, struct ber_oid *o, struct ber_element **elm) if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { pt.timeout = mapping[i].m_tm; break; - } + } } if (pt.timeout == PFTM_MAX) @@ -2053,7 +2053,7 @@ mib_pfiftable(struct oid *oid, struct ber_oid *o, struct ber_element **elm) default: return (1); } - + return (0); } @@ -2272,7 +2272,7 @@ mib_pftableaddrstable(struct oid *oid, struct ber_oid *o, struct ber_oid *no) tblidx = no->bo_id[OIDIDX_pfTblAddr + 1]; mps_decodeinaddr(no, &as.pfras_a.pfra_ip4addr, OIDIDX_pfTblAddr + 2); as.pfras_a.pfra_net = no->bo_id[OIDIDX_pfTblAddr + 6]; - + if (tblidx == 0) { if (pfta_get_first(&as)) return (NULL); @@ -2419,10 +2419,10 @@ int mib_pfsyncstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { int i; - int mib[] = { CTL_NET, AF_INET, IPPROTO_PFSYNC, + int mib[] = { CTL_NET, AF_INET, IPPROTO_PFSYNC, PFSYNCCTL_STATS }; size_t len = sizeof(struct pfsyncstats); - struct pfsyncstats s; + struct pfsyncstats s; struct statsmap { u_int8_t m_id; u_int64_t *m_ptr; @@ -2444,7 +2444,7 @@ mib_pfsyncstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { 15, &s.pfsyncs_onomem }, { 16, &s.pfsyncs_oerrors } }; - + if (sysctl(mib, 4, &s, &len, NULL, 0) == -1) { log_warn("sysctl"); return (-1); @@ -2454,9 +2454,10 @@ mib_pfsyncstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) (u_int)i < (sizeof(mapping) / sizeof(mapping[0])); i++) { if (oid->o_oid[OIDIDX_pfstatus] == mapping[i].m_id) { *elm = ber_add_integer(*elm, *mapping[i].m_ptr); - ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); + ber_set_header(*elm, BER_CLASS_APPLICATION, + SNMP_T_COUNTER64); return (0); - } + } } return (-1); @@ -2661,10 +2662,10 @@ mib_carpsysctl(struct oid *oid, struct ber_oid *o, struct ber_element **elm) int mib_carpstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { - int mib[] = { CTL_NET, PF_INET, IPPROTO_CARP, + int mib[] = { CTL_NET, PF_INET, IPPROTO_CARP, CARPCTL_STATS }; size_t len; - struct carpstats stats; + struct carpstats stats; int i; struct statsmap { u_int8_t m_id; @@ -2699,7 +2700,7 @@ mib_carpstats(struct oid *oid, struct ber_oid *o, struct ber_element **elm) ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_COUNTER64); return (0); - } + } } return (-1); @@ -2785,7 +2786,7 @@ int mib_carpiftable(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { u_int32_t idx; - struct carpif *cif; + struct carpif *cif; /* Get and verify the current row index */ idx = o->bo_id[OIDIDX_carpIfEntry]; @@ -3236,7 +3237,7 @@ mib_ipfnroutes(struct oid *oid, struct ber_oid *o, struct ber_element **elm) { *elm = ber_add_integer(*elm, kr_routenumber()); ber_set_header(*elm, BER_CLASS_APPLICATION, SNMP_T_GAUGE32); - + return (0); } @@ -3297,7 +3298,7 @@ mib_ipfroutetable(struct oid *oid, struct ber_oid *o, struct ber_oid *no) prio = kr->priority; } - switch(addr.sin_family) { + switch (addr.sin_family) { case AF_INET: atype = 1; break; diff --git a/usr.sbin/snmpd/snmpd.c b/usr.sbin/snmpd/snmpd.c index 93cf638f7c4..75775982de4 100644 --- a/usr.sbin/snmpd/snmpd.c +++ b/usr.sbin/snmpd/snmpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.c,v 1.13 2012/09/17 16:43:59 reyk Exp $ */ +/* $OpenBSD: snmpd.c,v 1.14 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org> @@ -350,20 +350,21 @@ snmpd_generate_engineid(struct snmpd *env) u_int32_t oid_enterprise, rnd, tim; /* RFC 3411 */ - memset(env->sc_engineid, 0, sizeof (env->sc_engineid)); + memset(env->sc_engineid, 0, sizeof(env->sc_engineid)); oid_enterprise = htonl(OIDVAL_openBSD_eid); - memcpy(env->sc_engineid, &oid_enterprise, sizeof (oid_enterprise)); + memcpy(env->sc_engineid, &oid_enterprise, sizeof(oid_enterprise)); env->sc_engineid[0] |= SNMP_ENGINEID_NEW; - env->sc_engineid_len = sizeof (oid_enterprise); + env->sc_engineid_len = sizeof(oid_enterprise); + /* XXX alternatively configure engine id via snmpd.conf */ env->sc_engineid[(env->sc_engineid_len)++] = SNMP_ENGINEID_FMT_EID; rnd = arc4random(); - memcpy(&env->sc_engineid[env->sc_engineid_len], &rnd, sizeof (rnd)); - env->sc_engineid_len += sizeof (rnd); + memcpy(&env->sc_engineid[env->sc_engineid_len], &rnd, sizeof(rnd)); + env->sc_engineid_len += sizeof(rnd); + tim = htonl(env->sc_starttime.tv_sec); - memcpy(&env->sc_engineid[env->sc_engineid_len], &tim, sizeof (tim)); - env->sc_engineid_len += sizeof (tim); - return; + memcpy(&env->sc_engineid[env->sc_engineid_len], &tim, sizeof(tim)); + env->sc_engineid_len += sizeof(tim); } u_long diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h index 4fd141d2916..8f112433353 100644 --- a/usr.sbin/snmpd/snmpd.h +++ b/usr.sbin/snmpd/snmpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpd.h,v 1.37 2012/09/17 16:43:59 reyk Exp $ */ +/* $OpenBSD: snmpd.h,v 1.38 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org> @@ -508,12 +508,12 @@ int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int pfr_buf_grow(struct pfr_buffer *, int); void *pfr_buf_next(struct pfr_buffer *, const void *); int pfi_get_ifaces(const char *, struct pfi_kif *, int *); -int pfi_get(struct pfr_buffer *, const char *); -int pfi_count(void); +int pfi_get(struct pfr_buffer *, const char *); +int pfi_count(void); int pfi_get_if(struct pfi_kif *, int); int pft_get(struct pfr_buffer *, struct pfr_table *); int pft_count(void); -int pft_get_table(struct pfr_tstats *, int); +int pft_get_table(struct pfr_tstats *, int); int pfta_get(struct pfr_buffer *, struct pfr_table *); int pfta_get_addr(struct pfr_astats *, int); int pfta_get_nextaddr(struct pfr_astats *, int *); diff --git a/usr.sbin/snmpd/snmpe.c b/usr.sbin/snmpd/snmpe.c index e234a0b9795..b2fd468dfa4 100644 --- a/usr.sbin/snmpd/snmpe.c +++ b/usr.sbin/snmpd/snmpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpe.c,v 1.30 2012/09/17 16:43:59 reyk Exp $ */ +/* $OpenBSD: snmpe.c,v 1.31 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org> @@ -861,7 +861,7 @@ snmpe_encode(struct snmp_message *msg) char f = MSG_SECLEVEL(msg); if ((ehdr = ber_printf_elements(ehdr, "{iixi}", msg->sm_msgid, - msg->sm_max_msg_size, &f, sizeof (f), + msg->sm_max_msg_size, &f, sizeof(f), msg->sm_secmodel)) == NULL) return -1; diff --git a/usr.sbin/snmpd/usm.c b/usr.sbin/snmpd/usm.c index a9ee9d607f0..7132d01e5b5 100644 --- a/usr.sbin/snmpd/usm.c +++ b/usr.sbin/snmpd/usm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usm.c,v 1.3 2012/09/17 19:00:06 reyk Exp $ */ +/* $OpenBSD: usm.c,v 1.4 2012/09/18 08:29:09 reyk Exp $ */ /* * Copyright (c) 2012 GeNUA mbH @@ -79,7 +79,7 @@ usm_generate_keys(void) /* optionally convert privacy password to key */ if (up->uu_priv != PRIV_NONE) { - arc4random_buf(&up->uu_salt, sizeof (up->uu_salt)); + arc4random_buf(&up->uu_salt, sizeof(up->uu_salt)); len = SNMP_CIPHER_KEYLEN; key = usm_passwd2key(md, up->uu_privkey, &len); @@ -126,7 +126,7 @@ usm_newuser(char *name, const char **errp) *errp = "user redefined"; return NULL; } - if ((up = calloc(1, sizeof (*up))) == NULL) + if ((up = calloc(1, sizeof(*up))) == NULL) fatal("usm"); up->uu_name = name; SLIST_INSERT_HEAD(&usmuserlist, up, uu_next); @@ -360,8 +360,8 @@ usm_encode(struct snmp_message *msg, struct ber_element *e) #endif ++(msg->sm_user->uu_salt); memcpy(msg->sm_salt, &msg->sm_user->uu_salt, - sizeof (msg->sm_salt)); - saltlen = sizeof (msg->sm_salt); + sizeof(msg->sm_salt)); + saltlen = sizeof(msg->sm_salt); } else saltlen = 0; @@ -583,10 +583,10 @@ usm_crypt(struct snmp_message *msg, u_char *inbuf, int inlen, u_char *outbuf, case PRIV_AES: /* RFC3826, chap 3.1.2.1. */ ivv = htobe32(msg->sm_engine_boots); - memcpy(iv, &ivv, sizeof (ivv)); + memcpy(iv, &ivv, sizeof(ivv)); ivv = htobe32(msg->sm_engine_time); - memcpy(iv + sizeof (ivv), &ivv, sizeof (ivv)); - memcpy(iv + 2 * sizeof (ivv), msg->sm_salt, SNMP_USM_SALTLEN); + memcpy(iv + sizeof(ivv), &ivv, sizeof(ivv)); + memcpy(iv + 2 * sizeof(ivv), msg->sm_salt, SNMP_USM_SALTLEN); break; default: return -1; |