aboutsummaryrefslogtreecommitdiff
path: root/src/libip
diff options
context:
space:
mode:
authorDan Cross <cross@gajendra.net>2020-01-10 14:44:21 +0000
committerDan Cross <cross@gajendra.net>2020-01-10 14:54:30 +0000
commitfa325e9b42b0bdfb48857d1958d9fb7ceac55151 (patch)
tree81d26256d152435135bcb1ae43121979a49f5f2b /src/libip
parent77a0a5b5194d4441c86de097f2aae297cb75e2c2 (diff)
downloadplan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.tar.gz
plan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.tar.bz2
plan9port-fa325e9b42b0bdfb48857d1958d9fb7ceac55151.zip
Trivial changes: whitespace and modes.
Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross <cross@gajendra.net>
Diffstat (limited to 'src/libip')
-rw-r--r--src/libip/BSD.c6
-rw-r--r--src/libip/Linux.c23
-rw-r--r--src/libip/freeipifc.c1
-rw-r--r--src/libip/myetheraddr.c3
-rw-r--r--src/libip/myipaddr.c1
-rw-r--r--src/libip/none.c2
-rw-r--r--src/libip/parseip.c2
-rw-r--r--src/libip/udp.c1
8 files changed, 17 insertions, 22 deletions
diff --git a/src/libip/BSD.c b/src/libip/BSD.c
index 9bf2db0c..57306163 100644
--- a/src/libip/BSD.c
+++ b/src/libip/BSD.c
@@ -22,7 +22,7 @@ static void
sockaddr2ip(uchar *ip, struct sockaddr *sa)
{
struct sockaddr_in *sin;
-
+
sin = (struct sockaddr_in*)sa;
memmove(ip, v4prefix, IPaddrlen);
memmove(ip+IPv4off, &sin->sin_addr, 4);
@@ -59,7 +59,7 @@ readipifc(char *net, Ipifc *ifc, int index)
mib[3] = 0;
mib[4] = NET_RT_IFLIST;
mib[5] = 0;
-
+
n = 0;
if(sysctl(mib, 6, nil, &n, nil, 0) < 0)
return nil;
@@ -115,7 +115,7 @@ readipifc(char *net, Ipifc *ifc, int index)
continue;
*lastlifc = lifc;
lastlifc = &lifc->next;
- }
+ }
sockaddr2ip(ip, sa);
switch(i){
case RTAX_IFA:
diff --git a/src/libip/Linux.c b/src/libip/Linux.c
index edc67e89..3a1411b9 100644
--- a/src/libip/Linux.c
+++ b/src/libip/Linux.c
@@ -16,7 +16,7 @@
* Thanks to Erik Quanstrom.
*/
static int
-netlinkrequest(int fd, int type, int (*fn)(struct nlmsghdr *h, Ipifc**, int),
+netlinkrequest(int fd, int type, int (*fn)(struct nlmsghdr *h, Ipifc**, int),
Ipifc **ifc, int index)
{
char buf[1024];
@@ -64,7 +64,7 @@ devsocket(void)
/* we couldn't care less which one; just want to talk to the kernel! */
static int dumb[3] = { AF_INET, AF_PACKET, AF_INET6 };
int i, fd;
-
+
for(i=0; i<nelem(dumb); i++)
if((fd = socket(dumb[i], SOCK_DGRAM, 0)) >= 0)
return fd;
@@ -76,7 +76,7 @@ parsertattr(struct rtattr **dst, int ndst, struct nlmsghdr *h, int type, int ski
{
struct rtattr *src;
int len;
-
+
len = h->nlmsg_len - NLMSG_LENGTH(skip);
if(len < 0 || h->nlmsg_type != type){
werrstr("attrs too short");
@@ -95,7 +95,7 @@ static void
rta2ip(int af, uchar *ip, struct rtattr *rta)
{
memset(ip, 0, IPaddrlen);
-
+
switch(af){
case AF_INET:
memmove(ip, v4prefix, IPv4off);
@@ -115,7 +115,7 @@ getlink(struct nlmsghdr *h, Ipifc **ipifclist, int index)
struct rtattr *attr[IFLA_MAX+1];
struct ifinfomsg *ifi;
Ipifc *ifc;
-
+
ifi = (struct ifinfomsg*)NLMSG_DATA(h);
if(index >= 0 && ifi->ifi_index != index)
return 0;
@@ -172,7 +172,7 @@ getlink(struct nlmsghdr *h, Ipifc **ipifclist, int index)
if(ioctl(fd, SIOCGIFHWADDR, &ifr) >= 0
&& ifr.ifr_hwaddr.sa_family == ARPHRD_ETHER)
memmove(ifc->ether, ifr.ifr_hwaddr.sa_data, 6);
-
+
close(fd);
}
return 0;
@@ -186,7 +186,7 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index)
Iplifc *lifc, **l;
struct ifaddrmsg *ifa;
struct rtattr *attr[IFA_MAX+1];
-
+
USED(index);
ifa = (struct ifaddrmsg*)NLMSG_DATA(h);
@@ -197,7 +197,7 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index)
return 0;
if(parsertattr(attr, nelem(attr), h, RTM_NEWADDR, sizeof(struct ifaddrmsg)) < 0)
return -1;
-
+
lifc = mallocz(sizeof *lifc, 1);
if(lifc == nil)
return -1;
@@ -211,13 +211,13 @@ getaddr(struct nlmsghdr *h, Ipifc **ipifclist, int index)
return 0;
rta2ip(ifa->ifa_family, lifc->ip, attr[IFA_ADDRESS]);
-
+
mask = ifa->ifa_prefixlen/8;
if(ifa->ifa_family == AF_INET)
mask += IPv4off;
memset(lifc->mask, 0xFF, mask);
memmove(lifc->net, lifc->ip, mask);
-
+
if(attr[IFA_CACHEINFO]){
struct ifa_cacheinfo *ci;
@@ -236,7 +236,7 @@ readipifc(char *net, Ipifc *ifc, int index)
USED(net);
freeipifc(ifc);
ifc = nil;
-
+
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if(fd < 0)
return nil;
@@ -250,4 +250,3 @@ readipifc(char *net, Ipifc *ifc, int index)
close(fd);
return ifc;
}
-
diff --git a/src/libip/freeipifc.c b/src/libip/freeipifc.c
index 7899facc..1b3bf021 100644
--- a/src/libip/freeipifc.c
+++ b/src/libip/freeipifc.c
@@ -17,4 +17,3 @@ freeipifc(Ipifc *i)
free(i);
}
}
-
diff --git a/src/libip/myetheraddr.c b/src/libip/myetheraddr.c
index a6b12def..3849bfe8 100644
--- a/src/libip/myetheraddr.c
+++ b/src/libip/myetheraddr.c
@@ -8,7 +8,7 @@ int
myetheraddr(uchar *to, char *dev)
{
Ipifc *ifclist, *ifc;
-
+
ifclist = readipifc(nil, nil, -1);
for(ifc=ifclist; ifc; ifc=ifc->next){
if(dev && strcmp(ifc->dev, dev) != 0)
@@ -23,4 +23,3 @@ myetheraddr(uchar *to, char *dev)
werrstr("no ethernet devices");
return -1;
}
-
diff --git a/src/libip/myipaddr.c b/src/libip/myipaddr.c
index bbde18f7..24faf9ff 100644
--- a/src/libip/myipaddr.c
+++ b/src/libip/myipaddr.c
@@ -42,4 +42,3 @@ myipaddr(uchar *ip, char *net)
freeipifc(ifc);
return -1;
}
-
diff --git a/src/libip/none.c b/src/libip/none.c
index 80110a64..caf5cf8f 100644
--- a/src/libip/none.c
+++ b/src/libip/none.c
@@ -8,7 +8,7 @@ readipifc(char *net, Ipifc *ipifc, int index)
USED(net);
USED(ipifc);
USED(index);
-
+
werrstr("not implemented");
return nil;
}
diff --git a/src/libip/parseip.c b/src/libip/parseip.c
index c0dd55cc..dba614ce 100644
--- a/src/libip/parseip.c
+++ b/src/libip/parseip.c
@@ -129,7 +129,7 @@ v4parsecidr(uchar *addr, uchar *mask, char *from)
*a++ = 0xff;
if(i > 0)
*a = ~((1<<(8-i))-1);
- } else
+ } else
memcpy(mask, defmask(addr), IPv4addrlen);
return p;
}
diff --git a/src/libip/udp.c b/src/libip/udp.c
index ae413a24..07f6403d 100644
--- a/src/libip/udp.c
+++ b/src/libip/udp.c
@@ -50,4 +50,3 @@ udpwrite(int fd, Udphdr *hdr, void *buf, long n)
memmove(&sin.sin_port, hdr->rport, 2);
return sendto(fd, buf, n, 0, (struct sockaddr*)&sin, sizeof sin);
}
-