changeset 94:c0667e989e61 draft

Style updates
author Roy Marples <roy@marples.name>
date Thu, 12 Apr 2007 13:12:25 +0000
parents 0aee17c728c9
children 18989fb0965b
files arp.c dhcp.c dhcp.h dhcpcd.c dhcpcd.h logger.c pathnames.h
diffstat 7 files changed, 167 insertions(+), 166 deletions(-) [+]
line wrap: on
line diff
--- a/arp.c	Thu Apr 12 06:58:02 2007 +0000
+++ b/arp.c	Thu Apr 12 13:12:25 2007 +0000
@@ -84,8 +84,8 @@
 	memcpy (ar_sha (&arp.ah), &iface->hwaddr, arp.ah.ar_hln);
 	memcpy (ar_tpa (&arp.ah), &address, arp.ah.ar_pln);
 
-	logger (LOG_INFO, "checking %s is available on attached networks", inet_ntoa
-			(address));
+	logger (LOG_INFO, "checking %s is available on attached networks",
+			inet_ntoa (address));
 
 	open_socket (iface, true);
 	send_packet (iface, ETHERTYPE_ARP, (unsigned char *) &arp.buffer,
--- a/dhcp.c	Thu Apr 12 06:58:02 2007 +0000
+++ b/dhcp.c	Thu Apr 12 13:12:25 2007 +0000
@@ -39,15 +39,15 @@
 #include "socket.h"
 
 static const char *dhcp_message[] = {
-	[DHCP_DISCOVER] 	= "DHCP_DISCOVER",
-	[DHCP_OFFER]		= "DHCP_OFFER",
-	[DHCP_REQUEST]	= "DHCP_REQUEST",
-	[DHCP_DECLINE]	= "DHCP_DECLINE",
-	[DHCP_ACK]		= "DHCP_ACK",
-	[DHCP_NAK]		= "DHCP_NAK",
-	[DHCP_RELEASE]	= "DHCP_RELEASE",
-	[DHCP_INFORM]		= "DHCP_INFORM",
-	[DHCP_INFORM + 1]	= NULL
+	[DHCP_DISCOVER]     = "DHCP_DISCOVER",
+	[DHCP_OFFER]        = "DHCP_OFFER",
+	[DHCP_REQUEST]      = "DHCP_REQUEST",
+	[DHCP_DECLINE]      = "DHCP_DECLINE",
+	[DHCP_ACK]          = "DHCP_ACK",
+	[DHCP_NAK]          = "DHCP_NAK",
+	[DHCP_RELEASE]      = "DHCP_RELEASE",
+	[DHCP_INFORM]       = "DHCP_INFORM",
+	[DHCP_INFORM + 1]   = NULL
 };
 
 size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
@@ -128,7 +128,8 @@
 		p += 2;
 	}
 
-#define PUTADDR(_type, _val) { \
+#define PUTADDR(_type, _val) \
+	{ \
 		*p++ = _type; \
 		*p++ = 4; \
 		memcpy (p, &_val.s_addr, 4); \
@@ -487,7 +488,8 @@
 	strlcpy (dhcp->servername, message->servername,
 			 sizeof (dhcp->servername));
 
-#define LEN_ERR { \
+#define LEN_ERR \
+	{ \
 		logger (LOG_ERR, "invalid length %d for option %d", length, option); \
 		p += length; \
 		continue; \
--- a/dhcp.h	Thu Apr 12 06:58:02 2007 +0000
+++ b/dhcp.h	Thu Apr 12 13:12:25 2007 +0000
@@ -33,70 +33,70 @@
 
 
 /* Max MTU - defines dhcp option length */
-#define MTU_MAX				1500
-#define MTU_MIN				576
+#define MTU_MAX             1500
+#define MTU_MIN             576
 
 /* UDP port numbers for DHCP */
-#define DHCP_SERVER_PORT 	67
-#define DHCP_CLIENT_PORT 	68
+#define DHCP_SERVER_PORT    67
+#define DHCP_CLIENT_PORT    68
 
-#define MAGIC_COOKIE		0x63825363
-#define BROADCAST_FLAG 		0x8000
+#define MAGIC_COOKIE        0x63825363
+#define BROADCAST_FLAG      0x8000
 
 /* DHCP message OP code */
-#define DHCP_BOOTREQUEST	1
-#define DHCP_BOOTREPLY		2
+#define DHCP_BOOTREQUEST    1
+#define DHCP_BOOTREPLY      2
 
 /* DHCP message type */
-#define	DHCP_DISCOVER		1
-#define DHCP_OFFER			2
-#define	DHCP_REQUEST		3
-#define	DHCP_DECLINE		4
-#define	DHCP_ACK			5
-#define DHCP_NAK			6
-#define	DHCP_RELEASE		7
-#define DHCP_INFORM			8
+#define DHCP_DISCOVER       1
+#define DHCP_OFFER          2
+#define DHCP_REQUEST        3
+#define DHCP_DECLINE        4
+#define DHCP_ACK            5
+#define DHCP_NAK            6
+#define DHCP_RELEASE        7
+#define DHCP_INFORM         8
 
 /* DHCP options */
 enum DHCP_OPTIONS
 {
-	DHCP_PAD					=	0,
-	DHCP_NETMASK				=	1,
-	DHCP_TIMEROFFSET			=	2,
-	DHCP_ROUTERS				=	3,
-	DHCP_TIMESERVER				=	4,
-	DHCP_NAMESERVER				=	5,
-	DHCP_DNSSERVER				=	6,
-	DHCP_LOGSERVER				=	7,
-	DHCP_COOKIESERVER			=	8,
-	DHCP_HOSTNAME				=	12,
-	DHCP_DNSDOMAIN				=	15,
-	DHCP_ROOTPATH				=	17,
-	DHCP_DEFAULTIPTTL			=	23,
-	DHCP_MTU					=	26,
-	DHCP_BROADCAST				=	28,
-	DHCP_MASKDISCOVERY			=	29,
-	DHCP_ROUTERDISCOVERY		=	31,
-	DHCP_STATICROUTE			=	33,
-	DHCP_NISDOMAIN				=	40,
-	DHCP_NISSERVER				=	41,
-	DHCP_NTPSERVER				=	42,
-	DHCP_ADDRESS				=	50,
-	DHCP_LEASETIME				=	51,
-	DHCP_MESSAGETYPE			=	53,
-	DHCP_SERVERIDENTIFIER		=	54,
-	DHCP_PARAMETERREQUESTLIST	=	55,
-	DHCP_MESSAGE				=	56,
-	DHCP_MAXMESSAGESIZE			=	57,
-	DHCP_RENEWALTIME			=	58,
-	DHCP_REBINDTIME				=	59,
-	DHCP_CLASSID				=	60,
-	DHCP_CLIENTID				=	61,
-	DHCP_USERCLASS				=	77,  /* RFC 3004 */
-	DHCP_FQDN					=	81,
-	DHCP_DNSSEARCH				=	119, /* RFC 3397 */
-	DHCP_CSR					=	121, /* RFC 3442 */
-	DHCP_END					=	255
+	DHCP_PAD                    = 0,
+	DHCP_NETMASK                = 1,
+	DHCP_TIMEROFFSET            = 2,
+	DHCP_ROUTERS                = 3,
+	DHCP_TIMESERVER             = 4,
+	DHCP_NAMESERVER             = 5,
+	DHCP_DNSSERVER              = 6,
+	DHCP_LOGSERVER              = 7,
+	DHCP_COOKIESERVER           = 8,
+	DHCP_HOSTNAME               = 12,
+	DHCP_DNSDOMAIN              = 15,
+	DHCP_ROOTPATH               = 17,
+	DHCP_DEFAULTIPTTL           = 23,
+	DHCP_MTU                    = 26,
+	DHCP_BROADCAST              = 28,
+	DHCP_MASKDISCOVERY          = 29,
+	DHCP_ROUTERDISCOVERY        = 31,
+	DHCP_STATICROUTE            = 33,
+	DHCP_NISDOMAIN              = 40,
+	DHCP_NISSERVER              = 41,
+	DHCP_NTPSERVER              = 42,
+	DHCP_ADDRESS                = 50,
+	DHCP_LEASETIME              = 51,
+	DHCP_MESSAGETYPE            = 53,
+	DHCP_SERVERIDENTIFIER       = 54,
+	DHCP_PARAMETERREQUESTLIST   = 55,
+	DHCP_MESSAGE                = 56,
+	DHCP_MAXMESSAGESIZE         = 57,
+	DHCP_RENEWALTIME            = 58,
+	DHCP_REBINDTIME             = 59,
+	DHCP_CLASSID                = 60,
+	DHCP_CLIENTID               = 61,
+	DHCP_USERCLASS              = 77,  /* RFC 3004 */
+	DHCP_FQDN                   = 81,
+	DHCP_DNSSEARCH              = 119, /* RFC 3397 */
+	DHCP_CSR                    = 121, /* RFC 3442 */
+	DHCP_END                    = 255
 };
 
 /* SetFQDNHostName values - lsnybble used in flags
@@ -104,10 +104,10 @@
  * and to allow 0x00 to mean disable
  */
 enum FQQN {
-	FQDN_DISABLE			=	0x00,
-	FQDN_NONE				=	0x18,
-	FQDN_PTR				=	0x20,
-	FQDN_BOTH				=	0x31
+	FQDN_DISABLE    = 0x00,
+	FQDN_NONE       = 0x18,
+	FQDN_PTR        = 0x20,
+	FQDN_BOTH       = 0x31
 };
 
 typedef struct fqdn_t
@@ -156,38 +156,38 @@
 
 
 /* Sizes for DHCP options */
-#define DHCP_CHADDR_LEN			16
-#define SERVERNAME_LEN			64
-#define BOOTFILE_LEN			128
-#define DHCP_UDP_LEN			(20 + 8)
-#define DHCP_BASE_LEN			(4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4)
-#define DHCP_RESERVE_LEN		(4 + 4 + 4 + 4 + 2)
-#define DHCP_FIXED_LEN			(DHCP_BASE_LEN + DHCP_CHADDR_LEN + \
-							 	+ SERVERNAME_LEN + BOOTFILE_LEN)
-#define DHCP_OPTION_LEN			(MTU_MAX - DHCP_FIXED_LEN - DHCP_UDP_LEN \
-							 	- DHCP_RESERVE_LEN)
+#define DHCP_CHADDR_LEN         16
+#define SERVERNAME_LEN          64
+#define BOOTFILE_LEN            128
+#define DHCP_UDP_LEN            (20 + 8)
+#define DHCP_BASE_LEN           (4 + 4 + 2 + 2 + 4 + 4 + 4 + 4 + 4)
+#define DHCP_RESERVE_LEN        (4 + 4 + 4 + 4 + 2)
+#define DHCP_FIXED_LEN          (DHCP_BASE_LEN + DHCP_CHADDR_LEN + \
+                                 + SERVERNAME_LEN + BOOTFILE_LEN)
+#define DHCP_OPTION_LEN         (MTU_MAX - DHCP_FIXED_LEN - DHCP_UDP_LEN \
+                                 - DHCP_RESERVE_LEN)
 
 /* Some crappy DHCP servers require the BOOTP minimum length */
-#define BOOTP_MESSAGE_LENTH_MIN	300
+#define BOOTP_MESSAGE_LENTH_MIN 300
 
 typedef struct dhcpmessage_t
 {
-	unsigned char op;				/* message type */
-	unsigned char hwtype;				/* hardware address type */
-	unsigned char hwlen;				/* hardware address length */
-	unsigned char hwopcount;			/* should be zero in client's message */
-	int32_t xid;				/* transaction id */
-	int16_t secs;				/* elapsed time in sec. from trying to boot */
+	unsigned char op;           /* message type */
+	unsigned char hwtype;       /* hardware address type */
+	unsigned char hwlen;        /* hardware address length */
+	unsigned char hwopcount;        /* should be zero in client message */
+	int32_t xid;            /* transaction id */
+	int16_t secs;           /* elapsed time in sec. from boot */
 	int16_t flags;
-	int32_t ciaddr;			/* (previously allocated) client IP address */
-	int32_t yiaddr;			/* 'your' client IP address */
-	int32_t siaddr;			/* should be zero in client's messages */
-	int32_t giaddr;			/* should be zero in client's messages */
-	unsigned char chaddr[DHCP_CHADDR_LEN];	/* client's hardware address */
-	char servername[SERVERNAME_LEN];	/* server host name, null terminated string */
-	char bootfile[BOOTFILE_LEN];		/* boot file name, null terminated string */
+	int32_t ciaddr;         /* (previously allocated) client IP */
+	int32_t yiaddr;         /* 'your' client IP address */
+	int32_t siaddr;         /* should be zero in client's messages */
+	int32_t giaddr;         /* should be zero in client's messages */
+	unsigned char chaddr[DHCP_CHADDR_LEN];  /* client's hardware address */
+	char servername[SERVERNAME_LEN];    /* server host name */
+	char bootfile[BOOTFILE_LEN];    /* boot file name */
 	uint32_t cookie;
-	unsigned char options[DHCP_OPTION_LEN];	/* message options - cookie */
+	unsigned char options[DHCP_OPTION_LEN]; /* message options - cookie */
 } dhcpmessage_t;
 
 struct udp_dhcp_packet
--- a/dhcpcd.c	Thu Apr 12 06:58:02 2007 +0000
+++ b/dhcpcd.c	Thu Apr 12 13:12:25 2007 +0000
@@ -94,8 +94,8 @@
 static void usage ()
 {
 	printf ("usage: "PACKAGE" [-adknpGHMNRY] [-c script] [-h hostame] [-i classID]\n"
-			"              [-l leasetime] [-m metric] [-s ipaddress] [-t timeout]\n"
-			"              [-u userclass] [-F [none | ptr | both]] [-I clientID]\n");
+	        "              [-l leasetime] [-m metric] [-s ipaddress] [-t timeout]\n"
+	        "              [-u userclass] [-F [none | ptr | both]] [-I clientID]\n");
 }
 
 int main(int argc, char **argv)
@@ -111,30 +111,30 @@
 	int debug = 0;
 
 	const struct option longopts[] = {
-		{"arp", no_argument, NULL, 'a'},
-		{"script",required_argument, NULL, 'c'},
-		{"debug", no_argument, NULL, 'd'},
-		{"hostname", required_argument, NULL, 'h'},
-		{"classid", required_argument, NULL, 'i'},
-		{"release", no_argument, NULL, 'k'},
-		{"leasetime", required_argument, NULL, 'l'},
-		{"metric", required_argument, NULL, 'm'},
-		{"renew", no_argument, NULL, 'n'},
-		{"persistent", no_argument, NULL, 'p'},
-		{"request", required_argument, NULL, 's'},
-		{"timeout", required_argument, NULL, 't'},
-		{"userclass", required_argument, NULL, 'u'},
-		{"fqdn", optional_argument, NULL, 'F'},
-		{"nogateway", no_argument, NULL, 'G'},
-		{"sethostname", no_argument, NULL, 'H'},
-		{"clientid", required_argument, NULL, 'I'},
-		{"nomtu", no_argument, NULL, 'M'},
-		{"nontp", no_argument, NULL, 'N'},
-		{"nodns", no_argument, NULL, 'R'},
-		{"nonis", no_argument, NULL, 'Y'},
-		{"help", no_argument, &dohelp, 1},
-		{"version", no_argument, &doversion, 1},
-		{NULL, 0, NULL, 0}
+        {"arp",         no_argument,        NULL, 'a'},
+        {"script",      required_argument,  NULL, 'c'},
+        {"debug",       no_argument,        NULL, 'd'},
+        {"hostname",    required_argument,  NULL, 'h'},
+        {"classid",     required_argument,  NULL, 'i'},
+        {"release",     no_argument,        NULL, 'k'},
+        {"leasetime",   required_argument,  NULL, 'l'},
+        {"metric",      required_argument,  NULL, 'm'},
+        {"renew",       no_argument,        NULL, 'n'},
+        {"persistent",  no_argument,        NULL, 'p'},
+        {"request",     required_argument,  NULL, 's'},
+        {"timeout",     required_argument,  NULL, 't'},
+        {"userclass",   required_argument,  NULL, 'u'},
+        {"fqdn",        optional_argument,  NULL, 'F'},
+        {"nogateway",   no_argument,        NULL, 'G'},
+        {"sethostname", no_argument,        NULL, 'H'},
+        {"clientid",    required_argument,  NULL, 'I'},
+        {"nomtu",       no_argument,        NULL, 'M'},
+        {"nontp",       no_argument,        NULL, 'N'},
+        {"nodns",       no_argument,        NULL, 'R'},
+        {"nonis",       no_argument,        NULL, 'Y'},
+        {"help",        no_argument,        &dohelp, 1},
+        {"version",     no_argument,        &doversion, 1},
+        {NULL,          0,                  NULL, 0}
 	};
 
 	/* Sanitize our fd's */
--- a/dhcpcd.h	Thu Apr 12 06:58:02 2007 +0000
+++ b/dhcpcd.h	Thu Apr 12 13:12:25 2007 +0000
@@ -29,13 +29,13 @@
 
 #include "common.h"
 
-#define DEFAULT_TIMEOUT		20
-#define DEFAULT_LEASETIME	3600 		/* 1 hour */
+#define DEFAULT_TIMEOUT     20
+#define DEFAULT_LEASETIME   3600        /* 1 hour */
 
-#define CLASS_ID_MAX_LEN	48
-#define CLIENT_ID_MAX_LEN	48
-#define HOSTNAME_MAX_LEN	255	
-#define USERCLASS_MAX_LEN	255	
+#define CLASS_ID_MAX_LEN    48
+#define CLIENT_ID_MAX_LEN   48
+#define HOSTNAME_MAX_LEN    255 
+#define USERCLASS_MAX_LEN   255 
 
 typedef struct options_t {
 	char interface[IF_NAMESIZE];
--- a/logger.c	Thu Apr 12 06:58:02 2007 +0000
+++ b/logger.c	Thu Apr 12 13:12:25 2007 +0000
@@ -32,34 +32,33 @@
 static char logprefix[12] = {0};
 
 static const char *syslog_level_msg[] = {
-	[LOG_EMERG]   	= "EMERGENCY!",
-	[LOG_ALERT]   	= "ALERT!",
-	[LOG_CRIT]    	= "Critical!",
-	[LOG_WARNING] 	= "Warning",
-	[LOG_ERR]     	= "Error",
-	[LOG_INFO]    	= "Info",
-	[LOG_DEBUG]   	= "Debug",
-	[LOG_DEBUG + 1]	= NULL
+	[LOG_EMERG]     = "EMERGENCY!",
+	[LOG_ALERT]     = "ALERT!",
+	[LOG_CRIT]      = "Critical!",
+	[LOG_WARNING]   = "Warning",
+	[LOG_ERR]       = "Error",
+	[LOG_INFO]      = "Info",
+	[LOG_DEBUG]     = "Debug",
+	[LOG_DEBUG + 1] = NULL
 };
 
 static const char *syslog_level[] = {
-	[LOG_EMERG]   	= "LOG_EMERG",
-	[LOG_ALERT]   	= "LOG_ALERT",
-	[LOG_CRIT]    	= "LOG_CRIT",
-	[LOG_ERR]     	= "LOG_ERR",
-	[LOG_WARNING] 	= "LOG_WARNING",
-	[LOG_NOTICE]  	= "LOG_NOTICE",
-	[LOG_INFO]    	= "LOG_INFO",
-	[LOG_DEBUG]   	= "LOG_DEBUG",
-	[LOG_DEBUG + 1]		= NULL
+	[LOG_EMERG]     = "LOG_EMERG",
+	[LOG_ALERT]     = "LOG_ALERT",
+	[LOG_CRIT]      = "LOG_CRIT",
+	[LOG_ERR]       = "LOG_ERR",
+	[LOG_WARNING]   = "LOG_WARNING",
+	[LOG_NOTICE]    = "LOG_NOTICE",
+	[LOG_INFO]      = "LOG_INFO",
+	[LOG_DEBUG]     = "LOG_DEBUG",
+	[LOG_DEBUG + 1]     = NULL
 };
 
 int logtolevel (const char *priority)
 {
 	int i = 0;
 
-	while (syslog_level[i])
-	{
+	while (syslog_level[i]) {
 		if (!strcmp (priority, syslog_level[i]))
 			return i;
 		i++;
--- a/pathnames.h	Thu Apr 12 06:58:02 2007 +0000
+++ b/pathnames.h	Thu Apr 12 13:12:25 2007 +0000
@@ -22,33 +22,33 @@
 #ifndef PATHNAMES_H
 #define PATHNAMES_H
 
-#define PACKAGE			"dhcpcd"
+#define PACKAGE             "dhcpcd"
 
-#define RESOLVCONF		"/sbin/resolvconf"
+#define RESOLVCONF          "/sbin/resolvconf"
 
-#define ETCDIR			"/etc"
-#define RESOLVFILE		ETCDIR "/resolv.conf"
+#define ETCDIR              "/etc"
+#define RESOLVFILE          ETCDIR "/resolv.conf"
 
-#define NISFILE			ETCDIR "/yp.conf"
-#define NISSERVICE		ETCDIR "/init.d/ypbind"
-#define NISRESTARTARGS		"--quiet", "conditionalrestart"
+#define NISFILE             ETCDIR "/yp.conf"
+#define NISSERVICE          ETCDIR "/init.d/ypbind"
+#define NISRESTARTARGS      "--quiet", "conditionalrestart"
 
-#define NTPFILE			ETCDIR "/ntp.conf"
-#define NTPDRIFTFILE		ETCDIR "/ntp.drift"
-#define NTPLOGFILE		"/var/log/ntp.log"
-#define NTPSERVICE		ETCDIR "/init.d/ntpd"
-#define NTPRESTARTARGS		"--quiet", "conditionalrestart"
+#define NTPFILE             ETCDIR "/ntp.conf"
+#define NTPDRIFTFILE        ETCDIR "/ntp.drift"
+#define NTPLOGFILE          "/var/log/ntp.log"
+#define NTPSERVICE          ETCDIR "/init.d/ntpd"
+#define NTPRESTARTARGS      "--quiet", "conditionalrestart"
 
-#define OPENNTPFILE		ETCDIR "/ntpd.conf"
-#define OPENNTPSERVICE		ETCDIR "/init.d/ntpd"
-#define OPENNTPRESTARTARGS	"--quiet", "conditionalrestart"
+#define OPENNTPFILE         ETCDIR "/ntpd.conf"
+#define OPENNTPSERVICE      ETCDIR "/init.d/ntpd"
+#define OPENNTPRESTARTARGS  "--quiet", "conditionalrestart"
 
-#define DEFAULT_SCRIPT		ETCDIR "/" PACKAGE ".sh"
+#define DEFAULT_SCRIPT      ETCDIR "/" PACKAGE ".sh"
 
-#define STATEDIR		"/var"
-#define PIDFILE			STATEDIR "/run/" PACKAGE "-%s.pid"
+#define STATEDIR            "/var"
+#define PIDFILE             STATEDIR "/run/" PACKAGE "-%s.pid"
 
-#define CONFIGDIR		STATEDIR "/lib/" PACKAGE
-#define INFOFILE		CONFIGDIR "/" PACKAGE "-%s.info"
+#define CONFIGDIR           STATEDIR "/lib/" PACKAGE
+#define INFOFILE            CONFIGDIR "/" PACKAGE "-%s.info"
 
 #endif