diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2006-06-02 15:43:17 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2006-06-02 15:43:17 +0000 |
commit | 16f51895c695dd96d7876b703d69137146fd3da4 (patch) | |
tree | b75e7d2ca15b2615e05665ad73c12a9ba160e0c0 /usr.sbin/dvmrpd | |
parent | 47fcf79410eea6ff9db7753c088aafc2a9897344 (diff) |
simplify netid_len calculation, inspired by stuff from bgpd.
Diffstat (limited to 'usr.sbin/dvmrpd')
-rw-r--r-- | usr.sbin/dvmrpd/dvmrpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/report.c | 23 |
2 files changed, 6 insertions, 21 deletions
diff --git a/usr.sbin/dvmrpd/dvmrpd.h b/usr.sbin/dvmrpd/dvmrpd.h index 34544c7e677..8e6ef2b89e6 100644 --- a/usr.sbin/dvmrpd/dvmrpd.h +++ b/usr.sbin/dvmrpd/dvmrpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpd.h,v 1.3 2006/06/01 22:07:30 claudio Exp $ */ +/* $OpenBSD: dvmrpd.h,v 1.4 2006/06/02 15:43:16 norby Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -447,4 +447,6 @@ const char *group_state_name(int); /* printconf.c */ void print_config(struct dvmrpd_conf *); +#define PREFIX_SIZE(x) (((x) + 7) / 8) + #endif /* _DVMRPD_H_ */ diff --git a/usr.sbin/dvmrpd/report.c b/usr.sbin/dvmrpd/report.c index 6fae0421507..b034c26658c 100644 --- a/usr.sbin/dvmrpd/report.c +++ b/usr.sbin/dvmrpd/report.c @@ -1,4 +1,4 @@ -/* $OpenBSD: report.c,v 1.1 2006/06/01 14:12:20 norby Exp $ */ +/* $OpenBSD: report.c,v 1.2 2006/06/02 15:43:16 norby Exp $ */ /* * Copyright (c) 2005, 2006 Esben Norby <norby@openbsd.org> @@ -113,16 +113,8 @@ recv_report(struct nbr *nbr, char *buf, u_int16_t len) buf += 3; len -= 3; - netid_len = 0; prefixlen = mask2prefixlen(netmask); - if (prefixlen > 0) - netid_len = 1; - if (prefixlen > 8) - netid_len = 2; - if (prefixlen > 16) - netid_len = 3; - if (prefixlen > 24) - netid_len = 4; + netid_len = PREFIX_SIZE(prefixlen); do { /* @@ -256,16 +248,7 @@ rr_list_send(struct rr_head *rr_list, struct iface *xiface, struct nbr *nbr) netmask = netmask >> 8; buf_add(buf, &netmask, 3); } - - netid_len = 0; - if (prefixlen > 0) - netid_len = 1; - if (prefixlen > 8) - netid_len = 2; - if (prefixlen > 16) - netid_len = 3; - if (prefixlen > 24) - netid_len = 4; + netid_len = PREFIX_SIZE(prefixlen); /* netid */ netid = le->re->net.s_addr; |