]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Style updates
authorRoy Marples <roy@marples.name>
Thu, 12 Apr 2007 13:12:25 +0000 (13:12 +0000)
committerRoy Marples <roy@marples.name>
Thu, 12 Apr 2007 13:12:25 +0000 (13:12 +0000)
arp.c
dhcp.c
dhcp.h
dhcpcd.c
dhcpcd.h
logger.c
pathnames.h

diff --git a/arp.c b/arp.c
index 12e32cbc07309967255ee3633213049e9b1e38db..9a54453eac3cdca88b4a020dc00713f341105ddf 100644 (file)
--- a/arp.c
+++ b/arp.c
@@ -84,8 +84,8 @@ int arp_check (interface_t *iface, struct in_addr address)
        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,
diff --git a/dhcp.c b/dhcp.c
index 6007def7682cca2aa8141f7a96823fb1f405ea94..fdc842b71eeaf73f87480a6327de3db9b603a5a2 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
 #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 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
                p += 2;
        }
 
-#define PUTADDR(_type, _val) { \
+#define PUTADDR(_type, _val) \
+       { \
                *p++ = _type; \
                *p++ = 4; \
                memcpy (p, &_val.s_addr, 4); \
@@ -487,7 +488,8 @@ int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message)
        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; \
diff --git a/dhcp.h b/dhcp.h
index 7308f163a4740a2a37f6796e631eba3f579f881c..e86197af8a5ffa4f13fe3beeb428fd27f8d9ff5b 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
 
 
 /* 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 @@ enum DHCP_OPTIONS
  * 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 @@ typedef struct dhcp_t
 
 
 /* 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
index d8e6a45dc91aca6be3b741fbf6ee5a2c052f4db8..908cfedb910a4b87f69bfafaff395a461b8d4593 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -94,8 +94,8 @@ void make_pid (const char *pidfile)
 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 main(int argc, char **argv)
        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 */
index f3738e64d17edf554ab432b24403628648dde65d..41be5883ec128d0cefaea53744672e69d2103483 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
 
 #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];
index 6aa54cb99443cd70553c2de2cc5f1ce4d8aad9ef..0fe75174617f76da4c4c43f8c97403e391c6c985 100644 (file)
--- a/logger.c
+++ b/logger.c
@@ -32,34 +32,33 @@ static int loglevel = LOG_WARNING;
 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++;
index c8b5710ae5856e96bb0f7c560fbfed7f5042d580..c6c8f4dadeba2383e55eac74256639b22f86190e 100644 (file)
 #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