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