changeset 1495:7cc993ec4abd draft

Set the broadcast flag for interfaces that say they need it.
author Roy Marples <roy@marples.name>
date Fri, 05 Mar 2010 15:47:46 +0000
parents 17ff45486c54
children 011abe8a7ca6
files dhcpcd.c if-bsd.c if-linux.c net.h
diffstat 4 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dhcpcd.c	Sat Feb 27 16:00:28 2010 +0000
+++ b/dhcpcd.c	Fri Mar 05 15:47:46 2010 +0000
@@ -765,6 +765,9 @@
 	uint8_t *duid;
 	size_t len = 0, ifl;
 
+	/* Do any platform specific configuration */
+	if_conf(iface);
+
 	if (iface->flags & IFF_POINTOPOINT && !(ifo->options & DHCPCD_INFORM))
 		ifo->options |= DHCPCD_STATIC;
 	if (iface->flags & IFF_NOARP ||
--- a/if-bsd.c	Sat Feb 27 16:00:28 2010 +0000
+++ b/if-bsd.c	Fri Mar 05 15:47:46 2010 +0000
@@ -80,6 +80,13 @@
 }
 
 int
+if_conf(_unused struct interface *iface)
+{
+	/* No extra checks needed on BSD */
+	return 0;
+}
+
+int
 init_sockets(void)
 {
 	if ((socket_afnet = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
--- a/if-linux.c	Sat Feb 27 16:00:28 2010 +0000
+++ b/if-linux.c	Fri Mar 05 15:47:46 2010 +0000
@@ -85,6 +85,26 @@
 	return n == -1 ? -1 : 0;
 }
 
+int
+if_conf(struct interface *iface)
+{
+	char path[PATH_MAX], buf[1];
+	FILE *fp;
+
+	/* Some qeth setups require the use of the broadcast flag. */
+	snprintf(path, sizeof(path),
+	    "/sys/class/net/%s/device/layer2",
+	    iface->name);
+
+	fp = fopen(path, "r");
+	if (fp == NULL)
+		return errno == ENOENT ? 0 : -1;
+	if (fgets(buf, sizeof(buf), fp) != NULL && buf[0] == '0')
+		iface->state->options->options |= DHCPCD_BROADCAST;
+	fclose(fp);
+	return 0;
+}
+
 static int
 _open_link_socket(struct sockaddr_nl *nl)
 {
--- a/net.h	Sat Feb 27 16:00:28 2010 +0000
+++ b/net.h	Fri Mar 05 15:47:46 2010 +0000
@@ -105,6 +105,7 @@
 int inet_cidrtoaddr(int, struct in_addr *);
 
 int up_interface(struct interface *);
+int if_conf(struct interface *);
 int if_init(struct interface *);
 
 int do_address(const char *,