aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-04-25 08:13:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-04-25 08:13:36 +0000
commita6b3a1f0bfc394a18b4cb4181a4827bf054206b4 (patch)
treea8251e40e9e9cd00a347da3236348727f2c5efa6
parent4d89a8bd1d6a081be559656b67f4adfc75137740 (diff)
downloadbusybox-w32-a6b3a1f0bfc394a18b4cb4181a4827bf054206b4.tar.gz
busybox-w32-a6b3a1f0bfc394a18b4cb4181a4827bf054206b4.tar.bz2
busybox-w32-a6b3a1f0bfc394a18b4cb4181a4827bf054206b4.zip
arping: save a few bytes by using mempcpy
function old new delta catcher 357 339 -18
-rw-r--r--networking/arping.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/networking/arping.c b/networking/arping.c
index 2b7a43cb6..9d2c671bc 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -66,6 +66,13 @@ struct globals {
66 count = -1; \ 66 count = -1; \
67 } while (0) 67 } while (0)
68 68
69// If GNUisms are not available...
70//static void *mempcpy(void *_dst, const void *_src, int n)
71//{
72// memcpy(_dst, _src, n);
73// return (char*)_dst + n;
74//}
75
69static int send_pack(struct in_addr *src_addr, 76static int send_pack(struct in_addr *src_addr,
70 struct in_addr *dst_addr, struct sockaddr_ll *ME, 77 struct in_addr *dst_addr, struct sockaddr_ll *ME,
71 struct sockaddr_ll *HE) 78 struct sockaddr_ll *HE)
@@ -81,20 +88,15 @@ static int send_pack(struct in_addr *src_addr,
81 ah->ar_pln = 4; 88 ah->ar_pln = 4;
82 ah->ar_op = option_mask32 & ADVERT ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST); 89 ah->ar_op = option_mask32 & ADVERT ? htons(ARPOP_REPLY) : htons(ARPOP_REQUEST);
83 90
84 memcpy(p, &ME->sll_addr, ah->ar_hln); 91 p = mempcpy(p, &ME->sll_addr, ah->ar_hln);
85 p += ME->sll_halen; 92 p = mempcpy(p, src_addr, 4);
86
87 memcpy(p, src_addr, 4);
88 p += 4;
89 93
90 if (option_mask32 & ADVERT) 94 if (option_mask32 & ADVERT)
91 memcpy(p, &ME->sll_addr, ah->ar_hln); 95 p = mempcpy(p, &ME->sll_addr, ah->ar_hln);
92 else 96 else
93 memcpy(p, &HE->sll_addr, ah->ar_hln); 97 p = mempcpy(p, &HE->sll_addr, ah->ar_hln);
94 p += ah->ar_hln;
95 98
96 memcpy(p, dst_addr, 4); 99 p = mempcpy(p, dst_addr, 4);
97 p += 4;
98 100
99 err = sendto(sock_fd, buf, p - buf, 0, (struct sockaddr *) HE, sizeof(*HE)); 101 err = sendto(sock_fd, buf, p - buf, 0, (struct sockaddr *) HE, sizeof(*HE));
100 if (err == p - buf) { 102 if (err == p - buf) {