comparison toys/pending/ifconfig.c @ 883:aca8323e2690

Add posix headers to toynet.h, move xioctl() to lib.c, introduce lib/net.c and move xsocket() to it.
author Rob Landley <rob@landley.net>
date Fri, 26 Apr 2013 02:41:05 -0500
parents bc7aa2d123b9
children f6db08574875
comparison
equal deleted inserted replaced
882:ae7a0fd5363f 883:aca8323e2690
30 30
31 #define FOR_ifconfig 31 #define FOR_ifconfig
32 #include "toys.h" 32 #include "toys.h"
33 #include "toynet.h" 33 #include "toynet.h"
34 34
35 #include <net/if.h>
36 #include <net/if_arp.h> 35 #include <net/if_arp.h>
37 #include <net/ethernet.h> 36 #include <net/ethernet.h>
38 37
39 GLOBALS( 38 GLOBALS(
40 void *if_list; 39 void *if_list;
59 58
60 char name[IFNAMSIZ]; 59 char name[IFNAMSIZ];
61 unsigned long long val[16]; 60 unsigned long long val[16];
62 }; 61 };
63 62
64 #define HW_NAME_LEN 20
65 #define HW_TITLE_LEN 30
66
67 #define IO_MAP_INDEX 0x100 63 #define IO_MAP_INDEX 0x100
68 64
69 //from kernel header ipv6.h 65 //from kernel header ipv6.h
70 #define IPV6_ADDR_ANY 0x0000U 66 #define IPV6_ADDR_ANY 0x0000U
71 #define IPV6_ADDR_LOOPBACK 0x0010U 67 #define IPV6_ADDR_LOOPBACK 0x0010U
93 #endif 89 #endif
94 90
95 #ifndef INFINIBAND_ALEN 91 #ifndef INFINIBAND_ALEN
96 # define INFINIBAND_ALEN 20 92 # define INFINIBAND_ALEN 20
97 #endif 93 #endif
98
99 void xioctl(int fd, int request, void *data)
100 {
101 if (ioctl(fd, request, data) < 0) perror_exit("ioctl %d", request);
102 }
103
104 int xsocket(int domain, int type, int protocol)
105 {
106 int fd = socket(domain, type, protocol);
107
108 if (fd < 0) perror_exit("socket %x %x", type, protocol);
109 return fd;
110 }
111 94
112 /* 95 /*
113 * verify the host is local unix path. 96 * verify the host is local unix path.
114 * if so, set the swl input param accordingly. 97 * if so, set the swl input param accordingly.
115 */ 98 */