-/* $OpenBSD: if_ether.c,v 1.113 2013/11/27 12:25:30 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.114 2013/12/31 03:24:44 tedu Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
ea = mtod(m, struct ether_arp *);
eh = (struct ether_header *)sa.sa_data;
bzero((caddr_t)ea, sizeof (*ea));
- bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
- sizeof(eh->ether_dhost));
+ 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);
ea->arp_pro = htons(ETHERTYPE_IP);
ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
ea->arp_op = htons(ARPOP_REQUEST);
- bcopy((caddr_t)enaddr, (caddr_t)eh->ether_shost,
- sizeof(eh->ether_shost));
- bcopy((caddr_t)enaddr, (caddr_t)ea->arp_sha, sizeof(ea->arp_sha));
- bcopy((caddr_t)sip, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
- bcopy((caddr_t)tip, (caddr_t)ea->arp_tpa, sizeof(ea->arp_tpa));
+ memcpy(eh->ether_shost, enaddr, sizeof(eh->ether_shost));
+ memcpy(ea->arp_sha, enaddr, sizeof(ea->arp_sha));
+ memcpy(ea->arp_spa, sip, sizeof(ea->arp_spa));
+ memcpy(ea->arp_tpa, tip, sizeof(ea->arp_tpa));
sa.sa_family = pseudo_AF_HDRCMPLT;
sa.sa_len = sizeof(sa);
m->m_flags |= M_BCAST;
char addr[INET_ADDRSTRLEN];
if (m->m_flags & M_BCAST) { /* broadcast */
- bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
- sizeof(etherbroadcastaddr));
+ memcpy(desten, etherbroadcastaddr, sizeof(etherbroadcastaddr));
return (1);
}
if (m->m_flags & M_MCAST) { /* multicast */
*/
if ((rt->rt_expire == 0 || rt->rt_expire > time_second) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
- bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
+ memcpy(desten, LLADDR(sdl), sdl->sdl_alen);
return 1;
}
if (((struct ifnet *)ac)->if_flags & IFF_NOARP) {
}
#endif
- bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof(itaddr));
- bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof(isaddr));
+ memcpy(&itaddr, ea->arp_tpa, sizeof(itaddr));
+ memcpy(&isaddr, ea->arp_spa, sizeof(isaddr));
/* First try: check target against our addresses */
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
ac->ac_if.if_xname);
goto out;
}
- bcopy(ea->arp_sha, LLADDR(sdl),
- sdl->sdl_alen = sizeof(ea->arp_sha));
+ sdl->sdl_alen = sizeof(ea->arp_sha);
+ memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
if (rt->rt_expire)
rt->rt_expire = time_second + arpt_keep;
rt->rt_flags &= ~RTF_REJECT;
}
if (itaddr.s_addr == myaddr.s_addr) {
/* I am the target */
- bcopy(ea->arp_sha, ea->arp_tha, sizeof(ea->arp_sha));
- bcopy(enaddr, ea->arp_sha, sizeof(ea->arp_sha));
+ memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
+ memcpy(ea->arp_sha, enaddr, sizeof(ea->arp_sha));
} else {
la = arplookup(itaddr.s_addr, 0, SIN_PROXY,
rtable_l2(m->m_pkthdr.rdomain));
rt = la->la_rt;
if (rt->rt_ifp->if_type == IFT_CARP && ifp->if_type != IFT_CARP)
goto out;
- bcopy(ea->arp_sha, ea->arp_tha, sizeof(ea->arp_sha));
+ memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
sdl = SDL(rt->rt_gateway);
- bcopy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
+ memcpy(ea->arp_sha, LLADDR(sdl), sizeof(ea->arp_sha));
}
- bcopy(ea->arp_spa, ea->arp_tpa, sizeof(ea->arp_spa));
- bcopy(&itaddr, ea->arp_spa, sizeof(ea->arp_spa));
+ memcpy(ea->arp_tpa, ea->arp_spa, sizeof(ea->arp_spa));
+ memcpy(ea->arp_spa, &itaddr, sizeof(ea->arp_spa));
ea->arp_op = htons(ARPOP_REPLY);
ea->arp_pro = htons(ETHERTYPE_IP); /* let's be sure! */
eh = (struct ether_header *)sa.sa_data;
- bcopy(ea->arp_tha, eh->ether_dhost, sizeof(eh->ether_dhost));
+ memcpy(eh->ether_dhost, ea->arp_tha, sizeof(eh->ether_dhost));
#if NCARP > 0
if (ether_shost)
enaddr = ether_shost;
#endif
- bcopy(enaddr, eh->ether_shost, sizeof(eh->ether_shost));
+ memcpy(eh->ether_shost, enaddr, sizeof(eh->ether_shost));
eh->ether_type = htons(ETHERTYPE_ARP);
sa.sa_family = pseudo_AF_HDRCMPLT;
if (bcmp(ar->arp_tha, ((struct arpcom *)ifp)->ac_enaddr,
sizeof(ar->arp_tha)))
goto out;
- bcopy((caddr_t)ar->arp_spa, (caddr_t)&revarp_srvip,
- sizeof(revarp_srvip));
- bcopy((caddr_t)ar->arp_tpa, (caddr_t)&revarp_myip,
- sizeof(revarp_myip));
+ memcpy(&revarp_srvip, ar->arp_spa, sizeof(revarp_srvip));
+ memcpy(&revarp_myip, ar->arp_tpa, sizeof(revarp_myip));
revarp_finished = 1;
wake: /* Do wakeup every time in case it was missed. */
wakeup((caddr_t)&revarp_myip);
ea = mtod(m, struct ether_arp *);
eh = (struct ether_header *)sa.sa_data;
bzero((caddr_t)ea, sizeof(*ea));
- bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
- sizeof(eh->ether_dhost));
+ memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost));
eh->ether_type = htons(ETHERTYPE_REVARP);
ea->arp_hrd = htons(ARPHRD_ETHER);
ea->arp_pro = htons(ETHERTYPE_IP);
ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
ea->arp_op = htons(ARPOP_REVREQUEST);
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
- sizeof(ea->arp_tha));
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
- sizeof(ea->arp_sha));
- bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_tha,
- sizeof(ea->arp_tha));
+ memcpy(eh->ether_shost, ac->ac_enaddr, sizeof(ea->arp_tha));
+ memcpy(ea->arp_sha, ac->ac_enaddr, sizeof(ea->arp_sha));
+ memcpy(ea->arp_tha, ac->ac_enaddr, sizeof(ea->arp_tha));
sa.sa_family = pseudo_AF_HDRCMPLT;
sa.sa_len = sizeof(sa);
m->m_flags |= M_BCAST;
if (!revarp_finished)
return ENETUNREACH;
- bcopy((caddr_t)&revarp_srvip, serv_in, sizeof(*serv_in));
- bcopy((caddr_t)&revarp_myip, clnt_in, sizeof(*clnt_in));
+ memcpy(serv_in, &revarp_srvip, sizeof(*serv_in));
+ memcpy(clnt_in, &revarp_myip, sizeof(*clnt_in));
return 0;
}
-/* $OpenBSD: in.c,v 1.89 2013/11/28 10:16:44 mpi Exp $ */
+/* $OpenBSD: in.c,v 1.90 2013/12/31 03:24:44 tedu Exp $ */
/* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */
/*
/* copy args to in_aliasreq, perform ioctl(SIOCAIFADDR). */
bzero(&ifra, sizeof(ifra));
- bcopy(iflr->iflr_name, ifra.ifra_name,
- sizeof(ifra.ifra_name));
+ memcpy(ifra.ifra_name, iflr->iflr_name,
+ sizeof(ifra.ifra_name));
- bcopy(&iflr->addr, &ifra.ifra_addr,
- ((struct sockaddr *)&iflr->addr)->sa_len);
+ memcpy(&ifra.ifra_addr, &iflr->addr,
+ ((struct sockaddr *)&iflr->addr)->sa_len);
if (((struct sockaddr *)&iflr->dstaddr)->sa_family) { /*XXX*/
- bcopy(&iflr->dstaddr, &ifra.ifra_dstaddr,
- ((struct sockaddr *)&iflr->dstaddr)->sa_len);
+ memcpy(&ifra.ifra_dstaddr, &iflr->dstaddr,
+ ((struct sockaddr *)&iflr->dstaddr)->sa_len);
}
ifra.ifra_mask.sin_family = AF_INET;
if (cmd == SIOCGLIFADDR) {
/* fill in the if_laddrreq structure */
- bcopy(&ia->ia_addr, &iflr->addr, ia->ia_addr.sin_len);
+ memcpy(&iflr->addr, &ia->ia_addr, ia->ia_addr.sin_len);
if ((ifp->if_flags & IFF_POINTOPOINT) != 0) {
- bcopy(&ia->ia_dstaddr, &iflr->dstaddr,
- ia->ia_dstaddr.sin_len);
+ memcpy(&iflr->dstaddr, &ia->ia_dstaddr,
+ ia->ia_dstaddr.sin_len);
} else
bzero(&iflr->dstaddr, sizeof(iflr->dstaddr));
/* fill in_aliasreq and do ioctl(SIOCDIFADDR) */
bzero(&ifra, sizeof(ifra));
- bcopy(iflr->iflr_name, ifra.ifra_name,
- sizeof(ifra.ifra_name));
+ memcpy(ifra.ifra_name, iflr->iflr_name,
+ sizeof(ifra.ifra_name));
- bcopy(&ia->ia_addr, &ifra.ifra_addr,
- ia->ia_addr.sin_len);
+ memcpy(&ifra.ifra_addr, &ia->ia_addr,
+ ia->ia_addr.sin_len);
if ((ifp->if_flags & IFF_POINTOPOINT) != 0) {
- bcopy(&ia->ia_dstaddr, &ifra.ifra_dstaddr,
- ia->ia_dstaddr.sin_len);
+ memcpy(&ifra.ifra_dstaddr, &ia->ia_dstaddr,
+ ia->ia_dstaddr.sin_len);
}
- bcopy(&ia->ia_sockmask, &ifra.ifra_dstaddr,
- ia->ia_sockmask.sin_len);
+ memcpy(&ifra.ifra_dstaddr, &ia->ia_sockmask,
+ ia->ia_sockmask.sin_len);
return in_control(so, SIOCDIFADDR, (caddr_t)&ifra, ifp);
}
-/* $OpenBSD: ip_ether.c,v 1.63 2013/11/06 17:08:57 deraadt Exp $ */
+/* $OpenBSD: ip_ether.c,v 1.64 2013/12/31 03:24:44 tedu Exp $ */
/*
* The author of this code is Angelos D. Keromytis (kermit@adk.gr)
*
if (M_LEADINGSPACE(m) < off)
panic("etherip_output: no space for align fixup");
m->m_data -= off;
- bcopy(mtod(m, caddr_t) + off, mtod(m, caddr_t), m->m_len);
+ memmove(mtod(m, caddr_t), mtod(m, caddr_t) + off, m->m_len);
}
/* Statistics */
-/* $OpenBSD: ip_gre.c,v 1.47 2013/10/24 11:31:43 mpi Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.48 2013/12/31 03:24:44 tedu Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
return;
}
- bcopy(ip + (ip->ip_hl << 2) + msiz, ip + (ip->ip_hl << 2),
+ memmove(ip + (ip->ip_hl << 2), ip + (ip->ip_hl << 2) + msiz,
m->m_len - msiz - (ip->ip_hl << 2));
m->m_len -= msiz;
-/* $OpenBSD: ip_icmp.c,v 1.111 2013/11/26 11:27:41 henning Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.112 2013/12/31 03:24:44 tedu Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
bzero(&ssrc, sizeof(ssrc));
sdst.sin_family = sgw.sin_family = ssrc.sin_family = AF_INET;
sdst.sin_len = sgw.sin_len = ssrc.sin_len = sizeof(sdst);
- bcopy(&icp->icmp_ip.ip_dst, &sdst.sin_addr, sizeof(sdst));
- bcopy(&icp->icmp_gwaddr, &sgw.sin_addr, sizeof(sgw));
- bcopy(&ip->ip_src, &ssrc.sin_addr, sizeof(ssrc));
+ memcpy(&sdst.sin_addr, &icp->icmp_ip.ip_dst, sizeof(sdst));
+ memcpy(&sgw.sin_addr, &icp->icmp_gwaddr, sizeof(sgw));
+ memcpy(&ssrc.sin_addr, &ip->ip_src, sizeof(ssrc));
#ifdef ICMPPRINTFS
if (icmpprintfs) {
*/
if (opt == IPOPT_RR || opt == IPOPT_TS ||
opt == IPOPT_SECURITY) {
- bcopy((caddr_t)cp,
- mtod(opts, caddr_t) + opts->m_len,
- len);
+ memcpy(mtod(opts, caddr_t) +
+ opts->m_len, cp, len);
opts->m_len += len;
}
}
-/* $OpenBSD: ip_input.c,v 1.222 2013/11/27 08:34:39 mpi Exp $ */
+/* $OpenBSD: ip_input.c,v 1.223 2013/12/31 03:24:44 tedu Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
/*
* locate outgoing interface
*/
- bcopy((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr,
+ memcpy(&ipaddr.sin_addr, cp + off,
sizeof(ipaddr.sin_addr));
if (opt == IPOPT_SSRR) {
if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(&ipaddr),
goto bad;
}
ip->ip_dst = ipaddr.sin_addr;
- bcopy((caddr_t)&ia->ia_addr.sin_addr,
- (caddr_t)(cp + off), sizeof(struct in_addr));
+ memcpy(cp + off, &ia->ia_addr.sin_addr,
+ sizeof(struct in_addr));
cp[IPOPT_OFFSET] += sizeof(struct in_addr);
/*
* Let ip_intr's mcast routing check handle mcast pkts
off--; /* 0 origin */
if ((off + sizeof(struct in_addr)) > optlen)
break;
- bcopy((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr,
+ memcpy(&ipaddr.sin_addr, &ip->ip_dst,
sizeof(ipaddr.sin_addr));
/*
* locate outgoing interface; if we're the destination,
code = ICMP_UNREACH_HOST;
goto bad;
}
- bcopy((caddr_t)&ia->ia_addr.sin_addr,
- (caddr_t)(cp + off), sizeof(struct in_addr));
+ memcpy(cp + off, &ia->ia_addr.sin_addr,
+ sizeof(struct in_addr));
cp[IPOPT_OFFSET] += sizeof(struct in_addr);
break;
code = cp - (u_char *)ip;
if (optlen < sizeof(struct ip_timestamp))
goto bad;
- bcopy(cp, &ipt, sizeof(struct ip_timestamp));
+ memcpy(&ipt, cp, sizeof(struct ip_timestamp));
if (ipt.ipt_ptr < 5 || ipt.ipt_len < 5)
goto bad;
if (ipt.ipt_ptr - 1 + sizeof(n_time) > ipt.ipt_len) {
goto bad;
break;
}
- bcopy(cp + ipt.ipt_ptr - 1, &sin, sizeof sin);
+ memcpy(&sin, cp + ipt.ipt_ptr - 1, sizeof sin);
switch (ipt.ipt_flg) {
case IPOPT_TS_TSONLY:
m->m_pkthdr.rcvif));
if (ia == 0)
continue;
- bcopy((caddr_t)&ia->ia_addr.sin_addr,
- (caddr_t)&sin, sizeof(struct in_addr));
+ memcpy(&sin, &ia->ia_addr.sin_addr,
+ sizeof(struct in_addr));
ipt.ipt_ptr += sizeof(struct in_addr);
break;
if (ipt.ipt_ptr - 1 + sizeof(n_time) +
sizeof(struct in_addr) > ipt.ipt_len)
goto bad;
- bcopy((caddr_t)&sin, (caddr_t)&ipaddr.sin_addr,
+ memcpy(&ipaddr.sin_addr, &sin,
sizeof(struct in_addr));
if (ifa_ifwithaddr(sintosa(&ipaddr),
m->m_pkthdr.rdomain) == 0)
goto bad;
}
ntime = iptime();
- bcopy((caddr_t)&ntime, (caddr_t)cp + ipt.ipt_ptr - 1,
- sizeof(n_time));
+ memcpy(cp + ipt.ipt_ptr - 1, &ntime, sizeof(n_time));
ipt.ipt_ptr += sizeof(n_time);
}
}
return;
isr = (struct ip_srcrt *)(mtag + 1);
- bcopy(option, isr->isr_hdr, olen);
+ memcpy(isr->isr_hdr, option, olen);
isr->isr_nhops = (olen - IPOPT_OFFSET - 1) / sizeof(struct in_addr);
isr->isr_dst = dst;
m_tag_prepend(m, mtag);
*/
isr->isr_nop = IPOPT_NOP;
isr->isr_hdr[IPOPT_OFFSET] = IPOPT_MINOFF;
- bcopy(&isr->isr_nop, mtod(m, caddr_t) + sizeof(struct in_addr), OPTSIZ);
+ memcpy(mtod(m, caddr_t) + sizeof(struct in_addr), &isr->isr_nop,
+ OPTSIZ);
q = (struct in_addr *)(mtod(m, caddr_t) +
sizeof(struct in_addr) + OPTSIZ);
#undef OPTSIZ
olen = (ip->ip_hl<<2) - sizeof (struct ip);
opts = (caddr_t)(ip + 1);
i = m->m_len - (sizeof (struct ip) + olen);
- bcopy(opts + olen, opts, (unsigned)i);
+ memmove(opts, opts + olen, i);
m->m_len -= olen;
if (m->m_flags & M_PKTHDR)
m->m_pkthdr.len -= olen;