aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/udhcp/common.c2
-rw-r--r--networking/udhcp/dhcpc.c76
2 files changed, 37 insertions, 41 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index b6b274d91..e34f926bb 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -69,7 +69,7 @@ const struct dhcp_optflag dhcp_optflags[] = {
69 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */ 69 { OPTION_U8 , 0x35 }, /* DHCP_MESSAGE_TYPE */
70 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */ 70 { OPTION_U16 , 0x39 }, /* DHCP_MAX_SIZE */
71 { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */ 71 { OPTION_STRING , 0x3c }, /* DHCP_VENDOR */
72//FIXME: handling of this option is not exactly correct: 72 /* not really a string */
73 { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */ 73 { OPTION_STRING , 0x3d }, /* DHCP_CLIENT_ID */
74 { 0, 0 } /* zeroed terminating entry */ 74 { 0, 0 } /* zeroed terminating entry */
75}; 75};
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 3630129ed..864fcf690 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -772,7 +772,7 @@ static void client_background(void)
772//usage:#endif 772//usage:#endif
773//usage:#define udhcpc_trivial_usage 773//usage:#define udhcpc_trivial_usage
774//usage: "[-fbnq"IF_UDHCP_VERBOSE("v")"oCR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n" 774//usage: "[-fbnq"IF_UDHCP_VERBOSE("v")"oCR] [-i IFACE] [-r IP] [-s PROG] [-p PIDFILE]\n"
775//usage: " [-H HOSTNAME] [-c CID] [-V VENDOR] [-O DHCP_OPT]..." IF_FEATURE_UDHCP_PORT(" [-P N]") 775//usage: " [-H HOSTNAME] [-V VENDOR] [-x OPT:VAL]... [-O OPT]..." IF_FEATURE_UDHCP_PORT(" [-P N]")
776//usage:#define udhcpc_full_usage "\n" 776//usage:#define udhcpc_full_usage "\n"
777//usage: IF_LONG_OPTS( 777//usage: IF_LONG_OPTS(
778//usage: "\n -i,--interface IFACE Interface to use (default eth0)" 778//usage: "\n -i,--interface IFACE Interface to use (default eth0)"
@@ -796,14 +796,14 @@ static void client_background(void)
796//usage: IF_FEATURE_UDHCPC_ARPING( 796//usage: IF_FEATURE_UDHCPC_ARPING(
797//usage: "\n -a,--arping Use arping to validate offered address" 797//usage: "\n -a,--arping Use arping to validate offered address"
798//usage: ) 798//usage: )
799//usage: "\n -O,--request-option OPT Request DHCP option OPT (cumulative)" 799//usage: "\n -O,--request-option OPT Request option OPT from server (cumulative)"
800//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)" 800//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)"
801//usage: "\n -x OPT:VAL Include option OPT in sent packets (cumulative)" 801//usage: "\n -x OPT:VAL Include option OPT in sent packets (cumulative)"
802//usage: "\n Examples: -x hostname:bbox -x 61:0100ffee11cc55"
802//usage: "\n -F,--fqdn NAME Ask server to update DNS mapping for NAME" 803//usage: "\n -F,--fqdn NAME Ask server to update DNS mapping for NAME"
803//usage: "\n -H,-h,--hostname NAME Send NAME as client hostname (default none)" 804//usage: "\n -H,-h,--hostname NAME Send NAME as client hostname (default none)"
804//usage: "\n -V,--vendorclass VENDOR Vendor identifier (default 'udhcp VERSION')" 805//usage: "\n -V,--vendorclass VENDOR Vendor identifier (default 'udhcp VERSION')"
805//usage: "\n -c,--clientid CLIENTID Client identifier (default own MAC)" 806//usage: "\n -C,--clientid-none Don't send MAC as client identifier"
806//usage: "\n -C,--clientid-none Don't send client identifier"
807//usage: IF_UDHCP_VERBOSE( 807//usage: IF_UDHCP_VERBOSE(
808//usage: "\n -v Verbose" 808//usage: "\n -v Verbose"
809//usage: ) 809//usage: )
@@ -816,8 +816,9 @@ static void client_background(void)
816//usage: "\n -t N Send up to N discover packets" 816//usage: "\n -t N Send up to N discover packets"
817//usage: "\n -T N Pause between packets (default 3 seconds)" 817//usage: "\n -T N Pause between packets (default 3 seconds)"
818//usage: "\n -A N Wait N seconds (default 20) after failure" 818//usage: "\n -A N Wait N seconds (default 20) after failure"
819//usage: "\n -x OPT:VAL Include option OPT in sent packets" 819//usage: "\n -x OPT:VAL Include option OPT in sent packets (cumulative)"
820//usage: "\n -O OPT Request DHCP option OPT (cumulative)" 820//usage: "\n Examples: -x hostname:bbox -x 61:0100ffee11cc55"
821//usage: "\n -O OPT Request option OPT from server (cumulative)"
821//usage: "\n -o Don't request any options (unless -O is given)" 822//usage: "\n -o Don't request any options (unless -O is given)"
822//usage: "\n -f Run in foreground" 823//usage: "\n -f Run in foreground"
823//usage: USE_FOR_MMU( 824//usage: USE_FOR_MMU(
@@ -836,8 +837,7 @@ static void client_background(void)
836//usage: "\n -F NAME Ask server to update DNS mapping for NAME" 837//usage: "\n -F NAME Ask server to update DNS mapping for NAME"
837//usage: "\n -H,-h NAME Send NAME as client hostname (default none)" 838//usage: "\n -H,-h NAME Send NAME as client hostname (default none)"
838//usage: "\n -V VENDOR Vendor identifier (default 'udhcp VERSION')" 839//usage: "\n -V VENDOR Vendor identifier (default 'udhcp VERSION')"
839//usage: "\n -c CLIENTID Client identifier (default own MAC)" 840//usage: "\n -C Don't send MAC as client identifier"
840//usage: "\n -C Don't send client identifier"
841//usage: IF_UDHCP_VERBOSE( 841//usage: IF_UDHCP_VERBOSE(
842//usage: "\n -v Verbose" 842//usage: "\n -v Verbose"
843//usage: ) 843//usage: )
@@ -847,7 +847,7 @@ int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
847int udhcpc_main(int argc UNUSED_PARAM, char **argv) 847int udhcpc_main(int argc UNUSED_PARAM, char **argv)
848{ 848{
849 uint8_t *temp, *message; 849 uint8_t *temp, *message;
850 const char *str_c, *str_V, *str_h, *str_F, *str_r; 850 const char *str_V, *str_h, *str_F, *str_r;
851 IF_FEATURE_UDHCP_PORT(char *str_P;) 851 IF_FEATURE_UDHCP_PORT(char *str_P;)
852 llist_t *list_O = NULL; 852 llist_t *list_O = NULL;
853 llist_t *list_x = NULL; 853 llist_t *list_x = NULL;
@@ -870,7 +870,6 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
870 870
871#if ENABLE_LONG_OPTS 871#if ENABLE_LONG_OPTS
872 static const char udhcpc_longopts[] ALIGN1 = 872 static const char udhcpc_longopts[] ALIGN1 =
873 "clientid\0" Required_argument "c"
874 "clientid-none\0" No_argument "C" 873 "clientid-none\0" No_argument "C"
875 "vendorclass\0" Required_argument "V" 874 "vendorclass\0" Required_argument "V"
876 "hostname\0" Required_argument "H" 875 "hostname\0" Required_argument "H"
@@ -896,29 +895,28 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
896 ; 895 ;
897#endif 896#endif
898 enum { 897 enum {
899 OPT_c = 1 << 0, 898 OPT_C = 1 << 0,
900 OPT_C = 1 << 1, 899 OPT_V = 1 << 1,
901 OPT_V = 1 << 2, 900 OPT_H = 1 << 2,
902 OPT_H = 1 << 3, 901 OPT_h = 1 << 3,
903 OPT_h = 1 << 4, 902 OPT_F = 1 << 4,
904 OPT_F = 1 << 5, 903 OPT_i = 1 << 5,
905 OPT_i = 1 << 6, 904 OPT_n = 1 << 6,
906 OPT_n = 1 << 7, 905 OPT_p = 1 << 7,
907 OPT_p = 1 << 8, 906 OPT_q = 1 << 8,
908 OPT_q = 1 << 9, 907 OPT_R = 1 << 9,
909 OPT_R = 1 << 10, 908 OPT_r = 1 << 10,
910 OPT_r = 1 << 11, 909 OPT_s = 1 << 11,
911 OPT_s = 1 << 12, 910 OPT_T = 1 << 12,
912 OPT_T = 1 << 13, 911 OPT_t = 1 << 13,
913 OPT_t = 1 << 14, 912 OPT_S = 1 << 14,
914 OPT_S = 1 << 15, 913 OPT_A = 1 << 15,
915 OPT_A = 1 << 16, 914 OPT_O = 1 << 16,
916 OPT_O = 1 << 17, 915 OPT_o = 1 << 17,
917 OPT_o = 1 << 18, 916 OPT_x = 1 << 18,
918 OPT_x = 1 << 19, 917 OPT_f = 1 << 19,
919 OPT_f = 1 << 20,
920/* The rest has variable bit positions, need to be clever */ 918/* The rest has variable bit positions, need to be clever */
921 OPTBIT_f = 20, 919 OPTBIT_f = 19,
922 USE_FOR_MMU( OPTBIT_b,) 920 USE_FOR_MMU( OPTBIT_b,)
923 IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,) 921 IF_FEATURE_UDHCPC_ARPING(OPTBIT_a,)
924 IF_FEATURE_UDHCP_PORT( OPTBIT_P,) 922 IF_FEATURE_UDHCP_PORT( OPTBIT_P,)
@@ -935,19 +933,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
935 str_V = "udhcp "BB_VER; 933 str_V = "udhcp "BB_VER;
936 934
937 /* Parse command line */ 935 /* Parse command line */
938 /* Cc: mutually exclusive; O,x: list; -T,-t,-A take numeric param */ 936 /* O,x: list; -T,-t,-A take numeric param */
939 opt_complementary = "c--C:C--c:O::x::T+:t+:A+" 937 opt_complementary = "O::x::T+:t+:A+"
940#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 938#if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1
941 ":vv" 939 ":vv"
942#endif 940#endif
943 ; 941 ;
944 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) 942 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
945 opt = getopt32(argv, "c:CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:f" 943 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:f"
946 USE_FOR_MMU("b") 944 USE_FOR_MMU("b")
947 IF_FEATURE_UDHCPC_ARPING("a") 945 IF_FEATURE_UDHCPC_ARPING("a")
948 IF_FEATURE_UDHCP_PORT("P:") 946 IF_FEATURE_UDHCP_PORT("P:")
949 "v" 947 "v"
950 , &str_c, &str_V, &str_h, &str_h, &str_F 948 , &str_V, &str_h, &str_h, &str_F
951 , &client_config.interface, &client_config.pidfile, &str_r /* i,p */ 949 , &client_config.interface, &client_config.pidfile, &str_r /* i,p */
952 , &client_config.script /* s */ 950 , &client_config.script /* s */
953 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ 951 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
@@ -1009,10 +1007,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1009 return 1; 1007 return 1;
1010 } 1008 }
1011 1009
1012 if (opt & OPT_c) { 1010 if (!(opt & OPT_C) && !udhcp_find_option(client_config.options, DHCP_CLIENT_ID)) {
1013 client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, str_c, 0); 1011 /* not suppressed and not set, set the default client ID */
1014 } else if (!(opt & OPT_C)) {
1015 /* not set and not suppressed, set the default client ID */
1016 client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, "", 7); 1012 client_config.clientid = alloc_dhcp_option(DHCP_CLIENT_ID, "", 7);
1017 client_config.clientid[OPT_DATA] = 1; /* type: ethernet */ 1013 client_config.clientid[OPT_DATA] = 1; /* type: ethernet */
1018 memcpy(client_config.clientid + OPT_DATA+1, client_config.client_mac, 6); 1014 memcpy(client_config.clientid + OPT_DATA+1, client_config.client_mac, 6);