From a3d991bd0da8b9fb9dbf2c7481091c3d082b9b13 Mon Sep 17 00:00:00 2001 From: wdenk Date: Thu, 15 Apr 2004 21:48:45 +0000 Subject: Patches by Pantelis Antoniou, 30 Mar 2004: add networking support for VLANs (802.1q), and CDP (Cisco Discovery Protocol) --- common/cmd_net.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'common/cmd_net.c') diff --git a/common/cmd_net.c b/common/cmd_net.c index f13e9d4..85a9023 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -96,7 +96,7 @@ U_BOOT_CMD( static void netboot_update_env(void) { - char tmp[16] ; + char tmp[22] ; if (NetOurGatewayIP) { ip_to_string (NetOurGatewayIP, tmp); @@ -139,6 +139,16 @@ static void netboot_update_env(void) if (NetOurNISDomain[0]) setenv("domain", NetOurNISDomain); + if (ntohs(NetOurVLAN) != (ushort)-1) { + VLAN_to_string(NetOurVLAN, tmp); + setenv("vlan", tmp); + } + + if (ntohs(NetOurNativeVLAN) != (ushort)-1) { + VLAN_to_string(NetOurNativeVLAN, tmp); + setenv("vlan", tmp); + } + } static int netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[]) @@ -238,4 +248,47 @@ U_BOOT_CMD( ); #endif /* CFG_CMD_PING */ +#if (CONFIG_COMMANDS & CFG_CMD_CDP) + +static void cdp_update_env(void) +{ + char tmp[16]; + + if (CDPApplianceVLAN != htons(-1)) { + printf("CDP offered appliance VLAN %d\n", ntohs(CDPApplianceVLAN)); + VLAN_to_string(CDPApplianceVLAN, tmp); + setenv("vlan", tmp); + NetOurVLAN = CDPApplianceVLAN; + } + + if (CDPNativeVLAN != htons(-1)) { + printf("CDP offered native VLAN %d\n", ntohs(CDPNativeVLAN)); + VLAN_to_string(CDPNativeVLAN, tmp); + setenv("nvlan", tmp); + NetOurNativeVLAN = CDPNativeVLAN; + } + +} + +int do_cdp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int r; + + r = NetLoop(CDP); + if (r < 0) { + printf("cdp failed; perhaps not a CISCO switch?\n"); + return 1; + } + + cdp_update_env(); + + return 0; +} + +U_BOOT_CMD( + cdp, 1, 1, do_cdp, + "cdp - Perform CDP network configuration\n", +); +#endif /* CFG_CMD_CDP */ + #endif /* CFG_CMD_NET */ -- cgit v1.1