]>
Commit | Line | Data |
---|---|---|
d22c338e JH |
1 | ------------------------------------------ |
2 | Link-local IP address auto-configuration | |
3 | ------------------------------------------ | |
4 | ||
5 | Negotiate with other link-local clients on the local network | |
6 | for an address that doesn't require explicit configuration. | |
7 | This is especially useful if a DHCP server cannot be guaranteed | |
8 | to exist in all environments that the device must operate. | |
9 | ||
10 | This is an implementation of RFC3927. | |
11 | ||
12 | ---------- | |
13 | Commands | |
14 | ---------- | |
15 | ||
16 | When CONFIG_CMD_LINK_LOCAL is defined in the board config file, | |
17 | the "linklocal" command is available. This running this will | |
18 | take approximately 5 seconds while the address is negotiated. | |
19 | ||
20 | ------------------------ | |
21 | Environment interation | |
22 | ------------------------ | |
23 | ||
24 | The "llipaddr" variable is set with the most recently | |
25 | negotiated address and is preferred in future negotiations. | |
26 | ||
27 | The "ipaddr", "netmask", and "gatewayip" variables are set | |
28 | after successful negotiation to enable network access. | |
29 | ||
30 | ------------- | |
31 | Limitations | |
32 | ------------- | |
33 | ||
34 | RFC3927 requires that addresses are continuously checked to | |
bc0571fc | 35 | avoid conflicts, however this can only happen when the net_loop |
d22c338e JH |
36 | is getting called. It is possible for a conflict to go undetected |
37 | until a command that accesses the network is executed. | |
38 | ||
bc0571fc | 39 | Using NetConsole is one way to ensure that net_loop is always |
d22c338e JH |
40 | processing packets and monitoring for conflicts. |
41 | ||
42 | This is also not a concern if the feature is use to connect | |
43 | directly to another machine that may not be running a DHCP server. | |
44 | ||
45 | ---------------- | |
46 | Example script | |
47 | ---------------- | |
48 | ||
49 | This script allows use of DHCP and/or Link-local controlled | |
50 | by env variables. It depends on CONFIG_CMD_LINK_LOCAL, CONFIG_CMD_DHCP, | |
51 | and CONFIG_BOOTP_MAY_FAIL. | |
52 | If both fail or are disabled, static settings are used. | |
53 | ||
54 | #define CONFIG_EXTRA_ENV_SETTINGS \ | |
55 | "ipconfigcmd=if test \\\"$dhcpenabled\\\" -ne 0;" \ | |
56 | "then " \ | |
57 | "dhcpfail=0;dhcp || dhcpfail=1;" \ | |
58 | "else " \ | |
59 | "dhcpfail=-1;" \ | |
60 | "fi;" \ | |
61 | "if test \\\"$linklocalenabled\\\" -ne 0 -a " \ | |
62 | "\\\"$dhcpfail\\\" -ne 0;" \ | |
63 | "then " \ | |
64 | "linklocal;" \ | |
65 | "llfail=0;" \ | |
66 | "else " \ | |
67 | "llfail=-1;" \ | |
68 | "fi;" \ | |
69 | "if test \\\"$llfail\\\" -ne 0 -a " \ | |
70 | "\\\"$dhcpfail\\\" -ne 0; " \ | |
71 | "then " \ | |
72 | "setenv ipaddr $sipaddr; " \ | |
73 | "setenv netmask $snetmask; " \ | |
74 | "setenv gatewayip $sgatewayip; " \ | |
75 | "fi;\0" \ |