-/* $OpenBSD: if_ether.c,v 1.114 2013/12/31 03:24:44 tedu Exp $ */
+/* $OpenBSD: if_ether.c,v 1.115 2014/01/09 06:29:05 tedu Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
MH_ALIGN(m, sizeof(*ea));
ea = mtod(m, struct ether_arp *);
eh = (struct ether_header *)sa.sa_data;
- bzero((caddr_t)ea, sizeof (*ea));
+ memset(ea, 0, sizeof(*ea));
memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost));
eh->ether_type = htons(ETHERTYPE_ARP); /* if_output will not swap */
ea->arp_hrd = htons(ARPHRD_ETHER);
enaddr = ac->ac_enaddr;
myaddr = ifatoia(ifa)->ia_addr.sin_addr;
- if (!bcmp((caddr_t)ea->arp_sha, enaddr, sizeof (ea->arp_sha)))
+ if (!memcmp(ea->arp_sha, enaddr, sizeof(ea->arp_sha)))
goto out; /* it's from me, ignore it. */
if (ETHER_IS_MULTICAST(&ea->arp_sha[0]))
- if (!bcmp((caddr_t)ea->arp_sha, (caddr_t)etherbroadcastaddr,
+ if (!memcmp(ea->arp_sha, etherbroadcastaddr,
sizeof (ea->arp_sha))) {
inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_ERR, "arp: ether address is broadcast for "
rtable_l2(m->m_pkthdr.rdomain));
if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) {
if (sdl->sdl_alen) {
- if (bcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) {
+ if (memcmp(ea->arp_sha, LLADDR(sdl), sdl->sdl_alen)) {
if (rt->rt_flags & RTF_PERMANENT_ARP) {
inet_ntop(AF_INET, &isaddr, addr, sizeof(addr));
log(LOG_WARNING,
rt->rt_flags &= ~RTF_REJECT;
return;
}
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
struct rtentry *rt;
struct sockaddr_inarp sin;
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = addr;
(rt->rt_flags & RTF_CLONED) != 0) {
struct rt_addrinfo info;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
if (ifp->if_rdomain != rdomain)
continue;
- if (!bcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway),
+ if (!memcmp(LLADDR((struct sockaddr_dl *)la->la_rt->rt_gateway),
LLADDR((struct sockaddr_dl *)ifp->if_lladdr->ifa_addr),
ETHER_ADDR_LEN)) {
found = 1;
goto out;
if (revarp_finished)
goto wake;
- if (bcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr,
+ if (memcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr,
sizeof(ar->arp_tha)))
goto out;
memcpy(&revarp_srvip, ar->arp_spa, sizeof(revarp_srvip));
MH_ALIGN(m, sizeof(*ea));
ea = mtod(m, struct ether_arp *);
eh = (struct ether_header *)sa.sa_data;
- bzero((caddr_t)ea, sizeof(*ea));
+ memset(ea, 0, sizeof(*ea));
memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost));
eh->ether_type = htons(ETHERTYPE_REVARP);
ea->arp_hrd = htons(ARPHRD_ETHER);
-/* $OpenBSD: if_ether.h,v 1.52 2013/11/21 16:34:33 mikeb Exp $ */
+/* $OpenBSD: if_ether.h,v 1.53 2014/01/09 06:29:05 tedu Exp $ */
/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
/*
/* struct ether_multi *enm; */ \
do { \
for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \
- (enm) != NULL && \
- (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
- bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
+ (enm) != NULL && \
+ (memcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 ||\
+ memcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
(enm) = LIST_NEXT((enm), enm_list)); \
} while (/* CONSTCOND */ 0)
-/* $OpenBSD: ip_ah.c,v 1.107 2013/06/11 18:15:53 deraadt Exp $ */
+/* $OpenBSD: ip_ah.c,v 1.108 2014/01/09 06:29:05 tedu Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen);
/* Initialize crypto session. */
- bzero(&cria, sizeof(cria));
+ memset(&cria, 0, sizeof(cria));
cria.cri_alg = tdbp->tdb_authalgxform->type;
cria.cri_klen = ii->ii_authkeylen * 8;
cria.cri_key = ii->ii_authkey;
if ((tdbp->tdb_wnd > 0) && (tdbp->tdb_flags & TDBF_ESN)) {
- bzero(&crin, sizeof(crin));
+ memset(&crin, 0, sizeof(crin));
crin.cri_alg = CRYPTO_ESN;
cria.cri_next = &crin;
}
if (tdbi->proto == tdb->tdb_sproto &&
tdbi->spi == tdb->tdb_spi &&
tdbi->rdomain == tdb->tdb_rdomain &&
- !bcmp(&tdbi->dst, &tdb->tdb_dst,
+ !memcmp(&tdbi->dst, &tdb->tdb_dst,
sizeof(union sockaddr_union)))
break;
}
if (encif->if_bpf) {
struct enchdr hdr;
- bzero (&hdr, sizeof(hdr));
+ memset(&hdr, 0, sizeof(hdr));
hdr.af = tdb->tdb_dst.sa.sa_family;
hdr.spi = tdb->tdb_spi;
-/* $OpenBSD: ip_carp.c,v 1.217 2013/11/28 09:36:37 mpi Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.218 2014/01/09 06:29:06 tedu Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
#endif /* INET6 */
/* compute ipad from key */
- bzero(vhe->vhe_pad, sizeof(vhe->vhe_pad));
+ memset(vhe->vhe_pad, 0, sizeof(vhe->vhe_pad));
bcopy(sc->sc_key, vhe->vhe_pad, sizeof(sc->sc_key));
for (i = 0; i < sizeof(vhe->vhe_pad); i++)
vhe->vhe_pad[i] ^= 0x36;
/* the rest of the precomputation */
if (!sc->sc_realmac && vhe->vhe_leader &&
- bcmp(sc->sc_ac.ac_enaddr, vhe->vhe_enaddr, ETHER_ADDR_LEN) != 0)
+ memcmp(sc->sc_ac.ac_enaddr, vhe->vhe_enaddr, ETHER_ADDR_LEN) != 0)
SHA1Update(&vhe->vhe_sha1[ctx], sc->sc_ac.ac_enaddr,
ETHER_ADDR_LEN);
const char *label;
/* Remove the existing host route, if any */
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = ifa->ifa_addr;
info.rti_flags = RTF_HOST;
error = rtrequest1(RTM_DELETE, &info, RTP_CONNECTED,
nr_ourif = (rt && rt->rt_ifp == &sc->sc_if);
/* Restore the route label */
- bzero(&sa_rl, sizeof(sa_rl));
+ memset(&sa_rl, 0, sizeof(sa_rl));
if (rt && rt->rt_labelid) {
sa_rl.sr_len = sizeof(sa_rl);
sa_rl.sr_family = AF_UNSPEC;
if (hr_otherif) {
ifa->ifa_rtrequest = NULL;
ifa->ifa_flags &= ~RTF_CLONING;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = ifa->ifa_addr;
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
info.rti_flags = RTF_UP | RTF_HOST;
if (!hr_otherif || nr_ourif || !rt) {
if (nr_ourif && !(rt->rt_flags &
RTF_CLONING)) {
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = &sa;
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
error = rtrequest1(RTM_DELETE,
ifa->ifa_rtrequest = arp_rtrequest;
ifa->ifa_flags |= RTF_CLONING;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = &sa;
info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr;
info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask;
return;
}
- if (!bcmp(&vhe->vhe_replay_cookie, ch->carp_counter,
+ if (!memcmp(&vhe->vhe_replay_cookie, ch->carp_counter,
sizeof(ch->carp_counter))) {
/* Do not log duplicates from non simplex interfaces */
if (sc->sc_carpdev->if_flags & IFF_SIMPLEX) {
ip->ip_p = IPPROTO_CARP;
ip->ip_sum = 0;
- bzero(&sa, sizeof(sa));
+ memset(&sa, 0, sizeof(sa));
sa.sa_family = AF_INET;
ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev);
if (ifa == NULL)
MH_ALIGN(m, m->m_len);
m->m_flags |= M_MCAST;
ip6 = mtod(m, struct ip6_hdr *);
- bzero(ip6, sizeof(*ip6));
+ memset(ip6, 0, sizeof(*ip6));
ip6->ip6_vfc |= IPV6_VERSION;
ip6->ip6_hlim = CARP_DFLTTL;
ip6->ip6_nxt = IPPROTO_CARP;
/* set the source address */
- bzero(&sa, sizeof(sa));
+ memset(&sa, 0, sizeof(sa));
sa.sa_family = AF_INET6;
ifa = ifaof_ifpforaddr(&sa, sc->sc_carpdev);
if (ifa == NULL) /* This should never happen with IPv6 */
- bzero(&ip6->ip6_src, sizeof(struct in6_addr));
+ memset(&ip6->ip6_src, 0, sizeof(struct in6_addr));
else
bcopy(ifatoia6(ifa)->ia_addr.sin6_addr.s6_addr,
&ip6->ip6_src, sizeof(struct in6_addr));
if (vh->sc_balancing == CARP_BAL_ARP) {
LIST_FOREACH(vhe, &vh->carp_vhosts, vhost_entries)
if (vhe->state == MASTER &&
- !bcmp(ena, vhe->vhe_enaddr, ETHER_ADDR_LEN))
+ !memcmp(ena, vhe->vhe_enaddr,
+ ETHER_ADDR_LEN))
return (&vh->sc_if);
} else {
vhe = LIST_FIRST(&vh->carp_vhosts);
if ((vhe->state == MASTER ||
vh->sc_balancing >= CARP_BAL_IP) &&
- !bcmp(ena, vh->sc_ac.ac_enaddr, ETHER_ADDR_LEN))
+ !memcmp(ena, vh->sc_ac.ac_enaddr, ETHER_ADDR_LEN))
return (&vh->sc_if);
}
}
if (sc->sc_balancing != CARP_BAL_IP)
return (0);
- return(!bcmp(sc->sc_ac.ac_enaddr, d_enaddr, ETHER_ADDR_LEN));
+ return (!memcmp(sc->sc_ac.ac_enaddr, d_enaddr, ETHER_ADDR_LEN));
}
return;
}
- if (bcmp(((struct arpcom *)sc->sc_carpdev)->ac_enaddr,
+ if (memcmp(((struct arpcom *)sc->sc_carpdev)->ac_enaddr,
sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN) == 0)
sc->sc_realmac = 1;
else
vhe->vhe_sdl.sdl_alen = ETHER_ADDR_LEN;
bcopy(vhe->vhe_enaddr, vhe->vhe_sdl.sdl_data, ETHER_ADDR_LEN);
} else
- bzero(vhe->vhe_enaddr, ETHER_ADDR_LEN);
+ memset(vhe->vhe_enaddr, 0, ETHER_ADDR_LEN);
}
void
* Use the carp lladdr if the running one isn't manually set.
* Only compare static parts of the lladdr.
*/
- if ((bcmp(sc->sc_ac.ac_enaddr + 1, vhe->vhe_enaddr + 1,
+ if ((memcmp(sc->sc_ac.ac_enaddr + 1, vhe->vhe_enaddr + 1,
ETHER_ADDR_LEN - 2) == 0) ||
(!sc->sc_ac.ac_enaddr[0] && !sc->sc_ac.ac_enaddr[1] &&
!sc->sc_ac.ac_enaddr[2] && !sc->sc_ac.ac_enaddr[3] &&
bcopy(vhe->vhe_enaddr, sc->sc_ac.ac_enaddr, ETHER_ADDR_LEN);
/* Make sure the enaddr has changed before further twiddling. */
- if (bcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) {
+ if (memcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0) {
bcopy(sc->sc_ac.ac_enaddr, LLADDR(sc->sc_if.if_sadl),
ETHER_ADDR_LEN);
bcopy(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN);
u_int16_t maxmem =
sc->sc_imo.imo_max_memberships;
- bzero(&sc->sc_imo, sizeof(sc->sc_imo));
+ memset(&sc->sc_imo, 0, sizeof(sc->sc_imo));
sc->sc_imo.imo_membership = imm;
sc->sc_imo.imo_max_memberships = maxmem;
int error;
/* Join IPv6 CARP multicast group */
- bzero(&addr6, sizeof(addr6));
+ memset(&addr6, 0, sizeof(addr6));
addr6.sin6_family = AF_INET6;
addr6.sin6_len = sizeof(addr6);
addr6.sin6_addr.s6_addr16[0] = htons(0xff02);
return (error);
}
/* join solicited multicast address */
- bzero(&addr6.sin6_addr, sizeof(addr6.sin6_addr));
+ memset(&addr6.sin6_addr, 0, sizeof(addr6.sin6_addr));
addr6.sin6_addr.s6_addr16[0] = htons(0xff02);
addr6.sin6_addr.s6_addr16[1] = htons(sc->sc_if.if_index);
addr6.sin6_addr.s6_addr32[1] = 0;
sc->sc_advbase = carpr.carpr_advbase;
error--;
}
- if (bcmp(sc->sc_advskews, carpr.carpr_advskews,
+ if (memcmp(sc->sc_advskews, carpr.carpr_advskews,
sizeof(sc->sc_advskews))) {
i = 0;
LIST_FOREACH(vhe, &sc->carp_vhosts, vhost_entries)
break;
case SIOCGVH:
- bzero(&carpr, sizeof(carpr));
+ memset(&carpr, 0, sizeof(carpr));
if (sc->sc_carpdev != NULL)
strlcpy(carpr.carpr_carpdev, sc->sc_carpdev->if_xname,
IFNAMSIZ);
error = ENOTTY;
}
- if (bcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0)
+ if (memcmp(sc->sc_ac.ac_enaddr, sc->sc_curlladdr, ETHER_ADDR_LEN) != 0)
carp_set_enaddr(sc);
return (error);
}
u_int8_t taken_vhids[256];
if (carpr->carpr_vhids[0] == 0 ||
- !bcmp(sc->sc_vhids, carpr->carpr_vhids, sizeof(sc->sc_vhids)))
+ !memcmp(sc->sc_vhids, carpr->carpr_vhids, sizeof(sc->sc_vhids)))
return (0);
- bzero(taken_vhids, sizeof(taken_vhids));
+ memset(taken_vhids, 0, sizeof(taken_vhids));
for (i = 0; carpr->carpr_vhids[i]; i++) {
if (taken_vhids[carpr->carpr_vhids[i]])
return (EINVAL);
/* destroy all */
carp_del_all_timeouts(sc);
carp_destroy_vhosts(sc);
- bzero(sc->sc_vhids, sizeof(sc->sc_vhids));
+ memset(sc->sc_vhids, 0, sizeof(sc->sc_vhids));
/* sort vhosts list by vhid */
for (j = 1; j <= 255; j++) {
-/* $OpenBSD: ip_divert.c,v 1.15 2013/12/20 02:04:08 krw Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.16 2014/01/09 06:29:06 tedu Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
break;
}
- bzero(&addr, sizeof(addr));
+ memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_len = sizeof(addr);
-/* $OpenBSD: ip_esp.c,v 1.122 2013/04/11 12:06:25 mpi Exp $ */
+/* $OpenBSD: ip_esp.c,v 1.123 2014/01/09 06:29:06 tedu Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
M_WAITOK);
bcopy(ii->ii_enckey, tdbp->tdb_emxkey, tdbp->tdb_emxkeylen);
- bzero(&crie, sizeof(crie));
+ memset(&crie, 0, sizeof(crie));
crie.cri_alg = tdbp->tdb_encalgxform->type;
M_WAITOK);
bcopy(ii->ii_authkey, tdbp->tdb_amxkey, tdbp->tdb_amxkeylen);
- bzero(&cria, sizeof(cria));
+ memset(&cria, 0, sizeof(cria));
cria.cri_alg = tdbp->tdb_authalgxform->type;
if ((tdbp->tdb_wnd > 0) && (tdbp->tdb_flags & TDBF_ESN)) {
- bzero(&crin, sizeof(crin));
+ memset(&crin, 0, sizeof(crin));
crin.cri_alg = CRYPTO_ESN;
cria.cri_next = &crin;
}
tdbi = (struct tdb_ident *) (mtag + 1);
if (tdbi->proto == tdb->tdb_sproto && tdbi->spi == tdb->tdb_spi &&
- tdbi->rdomain == tdb->tdb_rdomain && !bcmp(&tdbi->dst,
+ tdbi->rdomain == tdb->tdb_rdomain && !memcmp(&tdbi->dst,
&tdb->tdb_dst, sizeof(union sockaddr_union)))
break;
}
if (encif->if_bpf) {
struct enchdr hdr;
- bzero (&hdr, sizeof(hdr));
+ memset(&hdr, 0, sizeof(hdr));
hdr.af = tdb->tdb_dst.sa.sa_family;
hdr.spi = tdb->tdb_spi;
if (seq > tl) {
if (commit) {
if (seq - tl > window)
- bzero(tdb->tdb_seen,
+ memset(tdb->tdb_seen, 0,
sizeof(tdb->tdb_seen));
else {
int i = (tl % TDB_REPLAYMAX) / 32;
return (1);
if (commit) {
if (seq - tl > window)
- bzero(tdb->tdb_seen, sizeof(tdb->tdb_seen));
+ memset(tdb->tdb_seen, 0, sizeof(tdb->tdb_seen));
else {
int i = (tl % TDB_REPLAYMAX) / 32;
-/* $OpenBSD: ip_ether.c,v 1.64 2013/12/31 03:24:44 tedu Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.65 2014/01/09 06:29:06 tedu Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
/* Reset the flags based on the inner packet */
m->m_flags &= ~(M_BCAST|M_MCAST|M_AUTH|M_CONF);
if (eh.ether_dhost[0] & 1) {
- if (bcmp((caddr_t) etherbroadcastaddr,
- (caddr_t)eh.ether_dhost, sizeof(etherbroadcastaddr)) == 0)
+ if (memcmp(etherbroadcastaddr, eh.ether_dhost,
+ sizeof(etherbroadcastaddr)) == 0)
m->m_flags |= M_BCAST;
else
m->m_flags |= M_MCAST;
u_int8_t v;
/* Copy the addresses for use later. */
- bzero(&ssrc, sizeof(ssrc));
- bzero(&sdst, sizeof(sdst));
+ memset(&ssrc, 0, sizeof(ssrc));
+ memset(&sdst, 0, sizeof(sdst));
v = *mtod(m, u_int8_t *);
switch (v >> 4) {
!(sc->gif_if.if_flags & (IFF_UP|IFF_RUNNING)))
continue;
- if (!bcmp(sc->gif_psrc, &sdst, sc->gif_psrc->sa_len) &&
- !bcmp(sc->gif_pdst, &ssrc, sc->gif_pdst->sa_len))
+ if (!memcmp(sc->gif_psrc, &sdst, sc->gif_psrc->sa_len) &&
+ !memcmp(sc->gif_pdst, &ssrc, sc->gif_pdst->sa_len))
break;
}
-/* $OpenBSD: ip_icmp.c,v 1.112 2013/12/31 03:24:44 tedu Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.113 2014/01/09 06:29:06 tedu Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
if (icmpprintfs)
printf("deliver to protocol %d\n", icp->icmp_ip.ip_p);
#endif
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_addr = icp->icmp_ip.ip_dst;
* We are not able to respond with all ones broadcast
* unless we receive it over a point-to-point interface.
*/
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_len = sizeof(struct sockaddr_in);
if (ip->ip_dst.s_addr == INADDR_BROADCAST ||
* listening on a raw socket (e.g. the routing
* daemon for use in updating its tables).
*/
- bzero(&sdst, sizeof(sdst));
- bzero(&sgw, sizeof(sgw));
- bzero(&ssrc, sizeof(ssrc));
+ memset(&sdst, 0, sizeof(sdst));
+ memset(&sgw, 0, sizeof(sgw));
+ memset(&ssrc, 0, sizeof(ssrc));
sdst.sin_family = sgw.sin_family = ssrc.sin_family = AF_INET;
sdst.sin_len = sgw.sin_len = ssrc.sin_len = sizeof(sdst);
memcpy(&sdst.sin_addr, &icp->icmp_ip.ip_dst, sizeof(sdst));
struct sockaddr_in *dst;
struct route ro;
- bzero((caddr_t) &ro, sizeof(ro));
+ memset(&ro, 0, sizeof(ro));
ro.ro_tableid = m->m_pkthdr.rdomain;
dst = satosin(&ro.ro_dst);
dst->sin_family = AF_INET;
struct rtentry *rt;
int error;
- bzero(&ro, sizeof(ro));
+ memset(&ro, 0, sizeof(ro));
ro.ro_tableid = rtableid;
sin = satosin(&ro.ro_dst);
sin->sin_family = AF_INET;
struct rtentry *nrt;
struct rt_addrinfo info;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = sintosa(sin);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
info.rti_flags = RTF_GATEWAY | RTF_HOST | RTF_DYNAMIC;
struct sockaddr_in sa;
struct rt_addrinfo info;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
(RTF_DYNAMIC | RTF_HOST)) {
struct rt_addrinfo info;
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = rt_key(rt);
info.rti_info[RTAX_NETMASK] = rt_mask(rt);
info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
off = max(off, ICMP_EXT_OFFSET);
icp->icmp_length = off / sizeof(u_int32_t);
- bzero(&hdr, sizeof(hdr));
+ memset(&hdr, 0, sizeof(hdr));
hdr.ieh.ieh_version = ICMP_EXT_HDR_VERSION;
hdr.ieo.ieo_length = htons(sizeof(struct icmp_ext_obj_hdr) + len);
hdr.ieo.ieo_cnum = class;
-/* $OpenBSD: ip_input.c,v 1.223 2013/12/31 03:24:44 tedu Exp $ */
+/* $OpenBSD: ip_input.c,v 1.224 2014/01/09 06:29:06 tedu Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
rt_timer_queue_create(ip_mtudisc_timeout);
/* Fill in list of ports not to allocate dynamically. */
- bzero((void *)&baddynamicports, sizeof(baddynamicports));
+ memset(&baddynamicports, 0, sizeof(baddynamicports));
for (i = 0; defbaddynamicports_tcp[i] != 0; i++)
DP_SET(baddynamicports.tcp, defbaddynamicports_tcp[i]);
for (i = 0; defbaddynamicports_udp[i] != 0; i++)
}
#endif
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr = ina;
struct in_ifaddr *ia;
struct sockaddr_in sin;
- bzero(&sin, sizeof(sin));
+ memset(&sin, 0, sizeof(sin));
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr = ina;
* acts as a temporary storage not intended to be
* passed down the IP stack or to the mfree.
*/
- bzero(&mfake.m_hdr, sizeof(mfake.m_hdr));
+ memset(&mfake.m_hdr, 0, sizeof(mfake.m_hdr));
mfake.m_type = m->m_type;
if (m_dup_pkthdr(&mfake, m, M_DONTWAIT) == 0) {
mfake.m_data = mfake.m_pktdat;
if ((ifp = m->m_pkthdr.rcvif) == NULL ||
ifp->if_sadl == NULL) {
- bzero(&sdl, sizeof(sdl));
+ memset(&sdl, 0, sizeof(sdl));
sdl.sdl_len = offsetof(struct sockaddr_dl, sdl_data[0]);
sdl.sdl_family = AF_LINK;
sdl.sdl_index = ifp != NULL ? ifp->if_index : 0;
-/* $OpenBSD: ip_ipcomp.c,v 1.32 2013/05/14 14:29:08 mpi Exp $ */
+/* $OpenBSD: ip_ipcomp.c,v 1.33 2014/01/09 06:29:06 tedu Exp $ */
/*
* Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org)
tdbp->tdb_xform = xsp;
/* Initialize crypto session */
- bzero(&cric, sizeof(cric));
+ memset(&cric, 0, sizeof(cric));
cric.cri_alg = tdbp->tdb_compalgxform->type;
return crypto_newsession(&tdbp->tdb_cryptoid, &cric, 0);
if (encif->if_bpf) {
struct enchdr hdr;
- bzero (&hdr, sizeof(hdr));
+ memset(&hdr, 0, sizeof(hdr));
hdr.af = tdb->tdb_dst.sa.sa_family;
hdr.spi = tdb->tdb_spi;
/* Initialize the IPCOMP header */
ipcomp = mtod(mo, struct ipcomp *);
- bzero(ipcomp, sizeof(struct ipcomp));
+ memset(ipcomp, 0, sizeof(struct ipcomp));
cpi = (u_int16_t) ntohl(tdb->tdb_spi);
ipcomp->ipcomp_cpi = htons(cpi);
-/* $OpenBSD: ip_ipsp.c,v 1.192 2013/11/11 09:15:34 mpi Exp $ */
+/* $OpenBSD: ip_ipsp.c,v 1.193 2014/01/09 06:29:06 tedu Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr),
for (tdbp = tdbh[hashval]; tdbp != NULL; tdbp = tdbp->tdb_hnext)
if ((tdbp->tdb_spi == spi) && (tdbp->tdb_sproto == proto) &&
(tdbp->tdb_rdomain == rdomain) &&
- !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))
+ !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))
break;
return tdbp;
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
(tdbp->tdb_dst.sa.sa_family == AF_UNSPEC ||
- !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
- !bcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))
+ !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
+ !memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))
break;
if (tdbp != NULL)
return (tdbp);
- bzero(&su_null, sizeof(su_null));
+ memset(&su_null, 0, sizeof(su_null));
su_null.sa.sa_len = sizeof(struct sockaddr);
hashval = tdb_hash(rdomain, 0, &su_null, proto);
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
(tdbp->tdb_dst.sa.sa_family == AF_UNSPEC ||
- !bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
+ !memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa))) &&
tdbp->tdb_src.sa.sa_family == AF_UNSPEC)
break;
* most problems (all this will do is make every
* policy get its own SAs).
*/
- if (bcmp(&tdb->tdb_filter, pfilter,
+ if (memcmp(&tdb->tdb_filter, pfilter,
sizeof(struct sockaddr_encap)) ||
- bcmp(&tdb->tdb_filtermask, pfiltermask,
+ memcmp(&tdb->tdb_filtermask, pfiltermask,
sizeof(struct sockaddr_encap)))
return 0;
}
if ((tdbp->tdb_sproto == sproto) &&
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
- (!bcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))) {
+ (!memcmp(&tdbp->tdb_dst, dst, SA_LEN(&dst->sa)))) {
/* Do IDs and local credentials match ? */
if (!ipsp_aux_match(tdbp, srcid, dstid,
local_cred, NULL, filter, filtermask))
if ((tdbp->tdb_sproto == sproto) &&
(tdbp->tdb_rdomain == rdomain) &&
((tdbp->tdb_flags & TDBF_INVALID) == 0) &&
- (!bcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))) {
+ (!memcmp(&tdbp->tdb_src, src, SA_LEN(&src->sa)))) {
/* Check whether IDs match */
if (!ipsp_aux_match(tdbp, dstid, srcid, NULL, NULL,
filter, filtermask))
return;
}
- bzero (buckets, sizeof(buckets));
+ memset(buckets, 0, sizeof(buckets));
for (i = 0; i <= tdb_hashmask; i++) {
cnt = 0;
for (tdbp = tdbh[i]; cnt < NBUCKETS - 1 && tdbp != NULL;
{
if (ref1->ref_type != ref2->ref_type ||
ref1->ref_len != ref2->ref_len ||
- bcmp(ref1 + 1, ref2 + 1, ref1->ref_len))
+ memcmp(ref1 + 1, ref2 + 1, ref1->ref_len))
return 0;
return 1;
return SLIST_FIRST(&tags);
tdbi = (struct tdb_ident *) (mtag + 1);
- bzero(tdbi, sizeof(struct tdb_ident));
+ memset(tdbi, 0, sizeof(struct tdb_ident));
m_copydata(m, off + sizeof(u_int32_t),
sizeof(u_int32_t),
u_int32_t spi;
m_copydata(m, off, sizeof(u_int32_t), (caddr_t) &spi);
- bzero(&su, sizeof(union sockaddr_union));
+ memset(&su, 0, sizeof(union sockaddr_union));
s = splsoftnet();
return SLIST_FIRST(&tags);
tdbi = (struct tdb_ident *) (mtag + 1);
- bzero(tdbi, sizeof(struct tdb_ident));
+ memset(tdbi, 0, sizeof(struct tdb_ident));
/* Get SPI off the relevant header. */
if (proto == IPPROTO_AH)
-/* $OpenBSD: ip_mroute.c,v 1.63 2013/10/27 20:57:39 deraadt Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.64 2014/01/09 06:29:06 tedu Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
ip_mrouter = so;
mfchashtbl = hashinit(MFCTBLSIZ, M_MRTABLE, M_WAITOK, &mfchash);
- bzero((caddr_t)nexpire, sizeof(nexpire));
+ memset(nexpire, 0, sizeof(nexpire));
pim_assert = 0;
}
}
- bzero((caddr_t)nexpire, sizeof(nexpire));
+ memset(nexpire, 0, sizeof(nexpire));
free(mfchashtbl, M_MRTABLE);
mfchashtbl = NULL;
bw_upcalls_n = 0;
- bzero(bw_meter_timers, sizeof(bw_meter_timers));
+ memset(bw_meter_timers, 0, sizeof(bw_meter_timers));
/* Reset de-encapsulation cache. */
have_encap_tunnel = 0;
log(LOG_DEBUG, "Adding a register vif, ifp: %p\n",
(void *)ifp);
if (reg_vif_num == VIFI_INVALID) {
- bzero(ifp, sizeof(*ifp));
+ memset(ifp, 0, sizeof(*ifp));
snprintf(ifp->if_xname, sizeof ifp->if_xname,
"register_vif");
ifp->if_flags = IFF_LOOPBACK;
- bzero(&vifp->v_route, sizeof(vifp->v_route));
+ memset(&vifp->v_route, 0, sizeof(vifp->v_route));
reg_vif_num = vifcp->vifc_vifi;
}
#endif
ifp = vifp->v_ifp;
(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)&ifr);
}
- bzero((caddr_t)vifp, sizeof(*vifp));
+ memset(vifp, 0, sizeof(*vifp));
}
/*
for (i = 0; i < numvifs; i++) {
vifp = &viftable[i];
if (vifp->v_ifp == ifp)
- bzero((caddr_t)vifp, sizeof *vifp);
+ memset(vifp, 0, sizeof(*vifp));
}
for (i = numvifs; i > 0; i--)
} else {
struct mfcctl *mp = mtod(m, struct mfcctl *);
bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp));
- bzero((caddr_t)&mfcctl2 + sizeof(struct mfcctl),
+ memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0,
sizeof(mfcctl2) - sizeof(struct mfcctl));
}
mfccp = &mfcctl2;
return (EINVAL);
bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp));
- bzero((caddr_t)&mfcctl2 + sizeof(struct mfcctl),
+ memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0,
sizeof(mfcctl2) - sizeof(struct mfcctl));
mfccp = &mfcctl2;
-/* $OpenBSD: ip_output.c,v 1.253 2013/12/17 02:41:07 matthew Exp $ */
+/* $OpenBSD: ip_output.c,v 1.254 2014/01/09 06:29:06 tedu Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
if (ro == 0) {
ro = &iproute;
- bzero((caddr_t)ro, sizeof (*ro));
+ memset(ro, 0, sizeof(*ro));
}
dst = satosin(&ro->ro_dst);
if (tdbi->spi == tdb->tdb_spi &&
tdbi->proto == tdb->tdb_sproto &&
tdbi->rdomain == tdb->tdb_rdomain &&
- !bcmp(&tdbi->dst, &tdb->tdb_dst,
+ !memcmp(&tdbi->dst, &tdb->tdb_dst,
sizeof(union sockaddr_union))) {
sproto = 0; /* mark as no-IPsec-needed */
goto done_spd;
} else if (donerouting == 0) {
if (ro == 0) {
ro = &iproute;
- bzero((caddr_t)ro, sizeof (*ro));
+ memset(ro, 0, sizeof(*ro));
}
dst = satosin(&ro->ro_dst);
m->m_len += sizeof(struct in_addr);
cp = mtod(m, u_char *) + sizeof(struct in_addr);
memmove((caddr_t)cp, mtod(m, caddr_t), (unsigned)cnt);
- bzero(mtod(m, caddr_t), sizeof(struct in_addr));
+ memset(mtod(m, caddr_t), 0, sizeof(struct in_addr));
for (; cnt > 0; cnt -= optlen, cp += optlen) {
opt = cp[IPOPT_OPTVAL];
-/* $OpenBSD: ip_spd.c,v 1.69 2013/10/24 11:31:43 mpi Exp $ */
+/* $OpenBSD: ip_spd.c,v 1.70 2014/01/09 06:29:06 tedu Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
return NULL;
}
- bzero((caddr_t) re, sizeof(struct route_enc));
- bzero((caddr_t) &sdst, sizeof(union sockaddr_union));
- bzero((caddr_t) &ssrc, sizeof(union sockaddr_union));
+ memset(re, 0, sizeof(struct route_enc));
+ memset(&sdst, 0, sizeof(union sockaddr_union));
+ memset(&ssrc, 0, sizeof(union sockaddr_union));
ddst = (struct sockaddr_encap *) &re->re_dst;
ddst->sen_family = PF_KEY;
ddst->sen_len = SENT_LEN;
#ifdef INET6
case AF_INET6:
if ((IN6_IS_ADDR_UNSPECIFIED(&ipo->ipo_dst.sin6.sin6_addr)) ||
- (bcmp(&ipo->ipo_dst.sin6.sin6_addr, &in6mask128,
- sizeof(in6mask128)) == 0))
+ (memcmp(&ipo->ipo_dst.sin6.sin6_addr, &in6mask128,
+ sizeof(in6mask128)) == 0))
dignore = 1;
break;
#endif /* INET6 */
(inp->inp_seclevel[SL_AUTH] == IPSEC_LEVEL_BYPASS)) {
/* Direct match. */
if (dignore ||
- !bcmp(&sdst, &ipo->ipo_dst, sdst.sa.sa_len)) {
+ !memcmp(&sdst, &ipo->ipo_dst, sdst.sa.sa_len)) {
*error = 0;
return NULL;
}
if (ipo->ipo_tdb) {
if ((ipo->ipo_last_searched <= ipsec_last_added) ||
(ipo->ipo_sproto != ipo->ipo_tdb->tdb_sproto) ||
- bcmp(dignore ? &sdst : &ipo->ipo_dst,
- &ipo->ipo_tdb->tdb_dst,
- ipo->ipo_tdb->tdb_dst.sa.sa_len))
+ memcmp(dignore ? &sdst : &ipo->ipo_dst,
+ &ipo->ipo_tdb->tdb_dst,
+ ipo->ipo_tdb->tdb_dst.sa.sa_len))
goto nomatchout;
if (!ipsp_aux_match(ipo->ipo_tdb,
direction, tdbp, inp, ipo);
}
- if (bcmp(dignore ? &ssrc : &ipo->ipo_dst,
+ if (memcmp(dignore ? &ssrc : &ipo->ipo_dst,
&tdbp->tdb_src, tdbp->tdb_src.sa.sa_len) ||
(ipo->ipo_sproto != tdbp->tdb_sproto))
goto nomatchin;
* policy.
*/
if (ipo->ipo_sproto == ipo->ipo_tdb->tdb_sproto &&
- !bcmp(&ipo->ipo_tdb->tdb_src,
- dignore ? &ssrc : &ipo->ipo_dst,
- ipo->ipo_tdb->tdb_src.sa.sa_len))
+ !memcmp(&ipo->ipo_tdb->tdb_src,
+ dignore ? &ssrc : &ipo->ipo_dst,
+ ipo->ipo_tdb->tdb_src.sa.sa_len))
goto skipinputsearch;
/* Not applicable, unlink. */
/* Delete from SPD. */
if (!(ipo->ipo_flags & IPSP_POLICY_SOCKET)) {
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.rti_info[RTAX_DST] = (struct sockaddr *)&ipo->ipo_addr;
info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&ipo->ipo_mask;
struct ipsec_acquire *ipa;
TAILQ_FOREACH (ipa, &ipo->ipo_acquires, ipa_ipo_next) {
- if (!bcmp(gw, &ipa->ipa_addr, gw->sa.sa_len))
+ if (!memcmp(gw, &ipa->ipa_addr, gw->sa.sa_len))
return ipa;
}
* accept the packet; otherwise, discard.
*/
if (tdbp->tdb_sproto == inp->inp_ipo->ipo_sproto &&
- !bcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst,
- SA_LEN(&tdbp->tdb_src.sa)) &&
- ipsp_aux_match(tdbp,
- inp->inp_ipo->ipo_srcid,
- inp->inp_ipo->ipo_dstid,
- NULL, NULL,
- &inp->inp_ipo->ipo_addr,
- &inp->inp_ipo->ipo_mask))
+ !memcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst,
+ SA_LEN(&tdbp->tdb_src.sa)) &&
+ ipsp_aux_match(tdbp, inp->inp_ipo->ipo_srcid,
+ inp->inp_ipo->ipo_dstid, NULL, NULL,
+ &inp->inp_ipo->ipo_addr, &inp->inp_ipo->ipo_mask))
goto justreturn;
else {
*error = -EINVAL;
*/
if (tdbp != NULL &&
tdbp->tdb_sproto == inp->inp_ipo->ipo_sproto &&
- !bcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst,
- SA_LEN(&tdbp->tdb_src.sa)) &&
- ipsp_aux_match(tdbp,
- inp->inp_ipo->ipo_srcid,
- inp->inp_ipo->ipo_dstid,
- NULL, NULL,
- &inp->inp_ipo->ipo_addr,
- &inp->inp_ipo->ipo_mask))
+ !memcmp(&tdbp->tdb_src, &inp->inp_ipo->ipo_dst,
+ SA_LEN(&tdbp->tdb_src.sa)) &&
+ ipsp_aux_match(tdbp, inp->inp_ipo->ipo_srcid,
+ inp->inp_ipo->ipo_dstid, NULL, NULL,
+ &inp->inp_ipo->ipo_addr, &inp->inp_ipo->ipo_mask))
goto justreturn;
/*
-/* $OpenBSD: ipsec_input.c,v 1.118 2013/11/11 09:15:35 mpi Exp $ */
+/* $OpenBSD: ipsec_input.c,v 1.119 2014/01/09 06:29:06 tedu Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
* IP packet ready to go through input processing.
*/
- bzero(&dst_address, sizeof(dst_address));
+ memset(&dst_address, 0, sizeof(dst_address));
dst_address.sa.sa_family = af;
switch (af) {
if (mtu < 296)
return (NULL);
- bzero(&dst, sizeof(struct sockaddr_in));
+ memset(&dst, 0, sizeof(struct sockaddr_in));
dst.sin_family = AF_INET;
dst.sin_len = sizeof(struct sockaddr_in);
dst.sin_addr.s_addr = ip->ip_dst.s_addr;
if (mtu < 296)
return (NULL);
- bzero(&dst, sizeof(dst));
+ memset(&dst, 0, sizeof(dst));
dst.sin_family = AF_INET;
dst.sin_len = sizeof(struct sockaddr_in);
dst.sin_addr.s_addr = ip->ip_dst.s_addr;
su_dst = (union sockaddr_union *)&dst;
- bzero(&src, sizeof(src));
+ memset(&src, 0, sizeof(src));
src.sin_family = AF_INET;
src.sin_len = sizeof(struct sockaddr_in);
src.sin_addr.s_addr = ip->ip_src.s_addr;
for (; tdbp != NULL; tdbp = tdbp->tdb_snext) {
if (tdbp->tdb_sproto == IPPROTO_ESP &&
- ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP))
- == TDBF_UDPENCAP) &&
- !bcmp(&tdbp->tdb_dst, &dst, SA_LEN(&su_dst->sa)) &&
- !bcmp(&tdbp->tdb_src, &src, SA_LEN(&su_src->sa))) {
+ ((tdbp->tdb_flags & (TDBF_INVALID|TDBF_UDPENCAP)) ==
+ TDBF_UDPENCAP) &&
+ !memcmp(&tdbp->tdb_dst, &dst, SA_LEN(&su_dst->sa)) &&
+ !memcmp(&tdbp->tdb_src, &src, SA_LEN(&su_src->sa))) {
if ((adjust = ipsec_hdrsz(tdbp)) != -1) {
/* Store adjusted MTU in tdb */
tdbp->tdb_mtu = mtu - adjust;