discover/network: Use platform definition for DHCP architecture ID
authorJeremy Kerr <jk@ozlabs.org>
Fri, 17 Jan 2014 08:12:42 +0000 (16:12 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 13:59:10 +0000 (21:59 +0800)
Allow a platform to specify a DHCP architecture ID, as this is
platform-specific.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/network.c
discover/platform-powerpc.c
discover/platform.c
discover/platform.h

index 9da0f7a72526837011c67191152e4653c048e12c..c300f3dc7719619aa6092df5b476837ff8177b74 100644 (file)
@@ -212,8 +212,9 @@ static void udhcpc_process_exit(struct process *process)
 
 static void configure_interface_dhcp(struct interface *interface)
 {
+       const struct platform *platform;
+       char pidfile[256], id[10];
        struct process *process;
-       char pidfile[256];
        int rc;
        const char *argv[] = {
                pb_system_apps.udhcpc,
@@ -221,14 +222,21 @@ static void configure_interface_dhcp(struct interface *interface)
                "-n",
                "-O", "pxeconffile",
                "-O", "pxepathprefix",
-               "-x", "0x5d:000a",
                "-p", pidfile,
                "-i", interface->name,
+               "-x", id, /* [11,12] - dhcp client identifier */
                NULL,
        };
+
        snprintf(pidfile, sizeof(pidfile), "%s/udhcpc-%s.pid",
                        PIDFILE_BASE, interface->name);
 
+       platform = platform_get();
+       if (platform && platform->dhcp_arch_id != 0xffff)
+               snprintf(id, sizeof(id), "0x5d:%04x", platform->dhcp_arch_id);
+       else
+               argv[11] = NULL;
+
        process = process_create(interface);
 
        process->path = pb_system_apps.udhcpc;
index 776176956a8c9df777948728a9fcc15660998e2e..b0a35a7dfff4ea9a886513de2260658ea8cf42a6 100644 (file)
@@ -560,6 +560,7 @@ static bool probe(struct platform *p, void *ctx)
 
 static struct platform platform_powerpc = {
        .name           = "powerpc",
+       .dhcp_arch_id   = 0x000e,
        .probe          = probe,
        .load_config    = load_config,
        .save_config    = save_config,
index 66e776edd530548f9815c91942520362f5205e59..d52c9f65eecd48617b24f911a803f9498cde4ab4 100644 (file)
@@ -102,6 +102,11 @@ int platform_init(void *ctx)
        return 0;
 }
 
+const struct platform *platform_get(void)
+{
+       return platform;
+}
+
 int config_set(struct config *newconfig)
 {
        int rc;
index 44315fa4f0b40a5cc1575d7898e15489993e257d..a01ac7108ae562ae9cea3ecc7ed03b69357af6a4 100644 (file)
@@ -8,11 +8,13 @@ struct platform {
        bool            (*probe)(struct platform *, void *);
        int             (*load_config)(struct platform *, struct config *);
        int             (*save_config)(struct platform *, struct config *);
+       uint16_t        dhcp_arch_id;
        void            *platform_data;
 };
 
 int platform_init(void *ctx);
 int platform_fini(void);
+const struct platform *platform_get(void);
 
 /* configuration interface */
 const struct config *config_get(void);