busybox/networking/udhcp/d6_socket.c
Denys Vlasenko 8f2e99c813 udhcp: get rid of bb_info_msg()
function                                             old     new   delta
udhcpd_main                                         1501    1531     +30
d6_recv_raw_packet                                   251     264     +13
perform_d6_release                                   188     198     +10
udhcpc6_main                                        2443    2449      +6
udhcp_recv_raw_packet                                582     588      +6
udhcp_recv_kernel_packet                             132     138      +6
send_d6_renew                                        140     146      +6
d6_recv_kernel_packet                                118     124      +6
send_renew                                            77      82      +5
send_discover                                         85      90      +5
send_decline                                          84      89      +5
send_d6_select                                        97     102      +5
send_d6_discover                                     174     179      +5
perform_release                                      167     172      +5
count_lines                                           72      74      +2
udhcpc_main                                         2836    2837      +1
bb_info_msg                                          125       -    -125
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 17/4 up/down: 117/-180)         Total: -63 bytes
   text	   data	    bss	    dec	    hex	filename
 924935	    906	  17160	 943001	  e6399	busybox_old
 924736	    906	  17160	 942802	  e62d2	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-03-30 18:41:23 +02:00

35 lines
864 B
C

/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2011 Denys Vlasenko.
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
#include "common.h"
#include "d6_common.h"
#include <net/if.h>
int FAST_FUNC d6_listen_socket(int port, const char *inf)
{
int fd;
struct sockaddr_in6 addr;
log1("opening listen socket on *:%d %s", port, inf);
fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
setsockopt_reuseaddr(fd);
if (setsockopt_broadcast(fd) == -1)
bb_perror_msg_and_die("SO_BROADCAST");
/* NB: bug 1032 says this doesn't work on ethernet aliases (ethN:M) */
if (setsockopt_bindtodevice(fd, inf))
xfunc_die(); /* warning is already printed */
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(port);
/* addr.sin6_addr is all-zeros */
xbind(fd, (struct sockaddr *)&addr, sizeof(addr));
return fd;
}