|
@@ -0,0 +1,780 @@
|
|
|
+/***************************************************************
|
|
|
+** **
|
|
|
+** (C)Copyright 2006-2009, American Megatrends Inc. **
|
|
|
+** **
|
|
|
+** All Rights Reserved. **
|
|
|
+** **
|
|
|
+** 5555 Oakbrook Pkwy Suite 200, Norcross, **
|
|
|
+** **
|
|
|
+** Georgia - 30093, USA. Phone-(770)-246-8600. **
|
|
|
+** **
|
|
|
+****************************************************************
|
|
|
+* Filename: nwcfg.h
|
|
|
+*
|
|
|
+* Description: Contains code for the basic network library APIs.
|
|
|
+*
|
|
|
+****************************************************************/
|
|
|
+
|
|
|
+#ifndef _NWCFG_H
|
|
|
+#define _NWCFG_H
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+#include <sys/socket.h>
|
|
|
+#include <netinet/in.h>
|
|
|
+#include <arpa/inet.h>
|
|
|
+
|
|
|
+//#include <Types.h>
|
|
|
+//#include "hostname.h"
|
|
|
+#include <com_IPMIDefs.h>
|
|
|
+#include <com_BmcType.h>
|
|
|
+
|
|
|
+
|
|
|
+// /* External dependencies */
|
|
|
+// #define PROC_NET_ROUTE_FILE "/proc/net/route"
|
|
|
+// /* ipv6 */
|
|
|
+// #define PROC_NET_IPV6ROUTE_FILE "/proc/net/ipv6_route"
|
|
|
+// #define DHCPD_PID_FILE "/var/run/udhcpc.eth0.pid"
|
|
|
+// #define DHCP6C_PID_FILE "/var/run/dhcp6c.pid"
|
|
|
+
|
|
|
+// #define DHCPD_CONFIG_FILE "/conf/dhcpc-config"
|
|
|
+// #define DHCPD_CONFIG_FILE_TEMP "/var/dhcp-config.tmp"
|
|
|
+// #define RESOLV_CONF_FILE "/conf/resolv.conf"
|
|
|
+// #define RESOLV_CONF_DISABLED_FILE "/conf/resolv_disabled.conf"
|
|
|
+// #define RESOLV_CONF_FILE_TEMP "/var/resolv.conf.tmp"
|
|
|
+// #define DNS_CONFIG_FILE "/conf/dns.conf"
|
|
|
+// #define DNS_CONFIG_FILE_TEMP "/var/dns.conf.tmp"
|
|
|
+// #define IFUP_BIN_PATH "/sbin/ifup"
|
|
|
+// #define IFDOWN_BIN_PATH "/sbin/ifdown"
|
|
|
+#define ZERO_IP "0.0.0.0"
|
|
|
+#define DEFAULT_GW_STR "0.0.0.0"
|
|
|
+/* /etc/network/interfaces file defines */
|
|
|
+// #define NETWORK_IF_FILE "/etc/network/interfaces"
|
|
|
+// #define NETWORK_IF_FILE_TMP "/conf/interfaces.tmp"
|
|
|
+// #define NETWORK_DNS_TMP "/conf/dns.tmp"
|
|
|
+// #define NETWORK_IP_SRC_FILE "/conf/ipaddrsource"
|
|
|
+#define AUTO_LOCAL_STR "auto lo\n"
|
|
|
+#define AUTO_LOCAL_LOOPBACK_STR "iface lo inet loopback\n"
|
|
|
+#define IF_STATIC_IP_STR "address"
|
|
|
+#define IF_STATIC_MASK_STR "netmask"
|
|
|
+#define IF_STATIC_BCAST_STR "broadcast"
|
|
|
+#define IF_STATIC_GW_STR "gateway"
|
|
|
+#define IF_STATIC_MTU_STRING "mtu"
|
|
|
+#define DEFAULT_GW_FLAGS 0x0003
|
|
|
+// #define DEV_FILE "/proc/net/dev"
|
|
|
+
|
|
|
+// #define VLAN_ID_SETTING_STR "vlanid"
|
|
|
+// #define VLAN_INTERFACES_FILE "/conf/vlaninterfaces"
|
|
|
+// #define VLAN_PRIORITY_SETTING_STR "vlanpriority"
|
|
|
+// #define VLAN_INDEX_STR "index"
|
|
|
+// #define VLANSETTING_CONF_FILE "/conf/vlansetting.conf"
|
|
|
+
|
|
|
+// #define VLAN_NETWORK_DECONFIG_FILE "/etc/init.d/vlannetworking stop"
|
|
|
+// #define VLAN_NETWORK_CONFIG_FILE "/etc/init.d/vlannetworking start"
|
|
|
+// #define VLAN_ONLY_IFDOWN "/etc/init.d/vlannetworking downvlan"
|
|
|
+// #define VLAN_PROC_SYS_RAC_NCSI_ENABLE_LAN "echo 1 > /proc/sys/ractrends/ncsi/Enable"
|
|
|
+
|
|
|
+// #define VLAN_NETWORK_IP_CONFIGFILE "/etc/init.d/vlannetworking enableip"
|
|
|
+// #define IF_STATIC_ADDR_STR " pre-up ip addr add"
|
|
|
+
|
|
|
+// /*Bond*/
|
|
|
+// #define BONDING_CONF_FILE "/conf/bond.conf"
|
|
|
+// #define BONDING_SYSTEM_FILE "/sys/class/net"
|
|
|
+#define IFACE_ENABLED 0x01
|
|
|
+#define IFACE_DISABLED 0x00
|
|
|
+#define BOND_ROUND_ROBIN 0x00
|
|
|
+#define BOND_ACTIVE_BACKUP 0x01
|
|
|
+#define MAX_BOND_MODE 0x06
|
|
|
+#define MAX_BOND 0x03
|
|
|
+#define ETH_IFACE_TYPE 0x01
|
|
|
+#define BOND_IFACE_TYPE 0x02
|
|
|
+#define BOND_MAX_SLAVE 8
|
|
|
+
|
|
|
+#define MAX_CHANNEL 0x04
|
|
|
+#define MAX_ETH 5
|
|
|
+
|
|
|
+
|
|
|
+///* IPv6 */
|
|
|
+//#define KERNEL_IPV6_FILE "/proc/net/if_inet6"
|
|
|
+
|
|
|
+#define MAX_MAC_LEN 64
|
|
|
+#define MAC_ADDR_LEN 6
|
|
|
+#define IP_ADDR_LEN 4
|
|
|
+#define IP6_ADDR_LEN 16
|
|
|
+#define MAX_STR_LENGTH 128
|
|
|
+#define ROUTE_GW_LENGTH 100
|
|
|
+
|
|
|
+#define MAX_IPV6ADDRS 16
|
|
|
+#define DOMAIN_DHCP_LEN 7
|
|
|
+#define LOOPBACK_ADDR_LEN 9
|
|
|
+#define STR1_LEN 1
|
|
|
+#define STR2_LEN 2
|
|
|
+#define STR3_LEN 3
|
|
|
+#define STR4_LEN 4
|
|
|
+#define STR5_LEN 5
|
|
|
+
|
|
|
+/* DNS */
|
|
|
+#define MAX_HOST_NAME_STRING_SIZE 64
|
|
|
+#define MAX_DOMAIN_NAME_STRING_SIZE 256
|
|
|
+#define HOSTNAME_SETTING_MANUAL 0
|
|
|
+#define HOSTNAME_SETTING_AUTO 1
|
|
|
+#define ONELINE_LEN 300
|
|
|
+#define DNS_SERVERIP_LEN 26
|
|
|
+
|
|
|
+#define REG_BMC_ENABLE 0x01 //0th bit enable of BMC register
|
|
|
+#define REG_BMC_TSIG 0x02 //1st bit enable of BMC register
|
|
|
+#define REG_BMC_FQDN 0x10 //DHCP Option 81
|
|
|
+#define REG_BMC_HOSTNAME 0x20 //DHCP Option 12
|
|
|
+
|
|
|
+#define REG_BMC_RESERVED 0xCE //Binary value 1100 1110
|
|
|
+#define REG_BMC_RESERVED_TSIG 0xFD //Binary value 1111 1101
|
|
|
+
|
|
|
+/* TSIG Configuration */
|
|
|
+// #define CONF_LOCATION "/conf/"
|
|
|
+// #define TEMP_LOCATION "/tmp/"
|
|
|
+// #define TSIG_PRIVATE_FILE "tsig.private"
|
|
|
+// #define CONF_TSIG_PRIVATE_FILE CONF_LOCATION TSIG_PRIVATE_FILE
|
|
|
+// #define TEMP_TSIG_PRIVATE_FILE TEMP_LOCATION TSIG_PRIVATE_FILE
|
|
|
+// #define MAX_TSIG_PRIVKEY_SIZE (8 * 1024)
|
|
|
+// #define TSIG_ALG_TYPE_HMAC_MD5 "Algorithm: 157 (HMAC_MD5)\n"
|
|
|
+
|
|
|
+/* Type of network configuration */
|
|
|
+#define CFGMETHOD_STATIC 1
|
|
|
+#define CFGMETHOD_DHCP 2
|
|
|
+#define CFGMETHOD_BIOS 3
|
|
|
+#define CFGMETHOD_OTHER 4
|
|
|
+
|
|
|
+#define NWCFGTYPE_STATIC 0x1
|
|
|
+#define NWCFGTYPE_DHCP 0x2
|
|
|
+#define NWCFGTYPE_DHCPFIRST 0x4
|
|
|
+
|
|
|
+/*Interface enable state*/
|
|
|
+#define NW_INTERFACE_ENABLE 0x1
|
|
|
+#define NW_INTERFACE_DISABLE 0x2
|
|
|
+#define NW_INTERFACE_UNKNOWN 0x3
|
|
|
+
|
|
|
+#define NW_AUTO_NEG_ON 0x1
|
|
|
+#define NW_AUTO_NEG_OFF 0x2
|
|
|
+
|
|
|
+#define NW_DUPLEX_FULL 0x1
|
|
|
+#define NW_DUPLEX_HALF 0x2
|
|
|
+
|
|
|
+/*
|
|
|
+ * ETHSET FLAG: See nwSetNWExtEthCfg API
|
|
|
+ */
|
|
|
+#define NWEXT_ETHCFG_LAMAC 0x1
|
|
|
+#define NWEXT_ETHCFG_BURNEDMAC 0x2
|
|
|
+#define NWEXT_ETHCFG_SPEED 0x4
|
|
|
+#define NWEXT_ETHCFG_DUPLEX 0x8
|
|
|
+#define NWEXT_ETHCFG_AUTONEG 0x10
|
|
|
+#define NWEXT_ETHCFG_MTU 0x20
|
|
|
+#define NWEXT_ETHCFG_WOL 0x40
|
|
|
+#define NWEXT_ETHCFG_ALL (NWEXT_ETHCFG_LAMAC \
|
|
|
+ | NWEXT_ETHCFG_BURNEDMAC \
|
|
|
+ | NWEXT_ETHCFG_SPEED \
|
|
|
+ | NWEXT_ETHCFG_DUPLEX \
|
|
|
+ | NWEXT_ETHCFG_AUTONEG \
|
|
|
+ | NWEXT_ETHCFG_MTU \
|
|
|
+ | NWEXT_ETHCFG_WOL)
|
|
|
+
|
|
|
+/*
|
|
|
+ * NWSET FLAG: See nwSetNWExtIPCfg API
|
|
|
+ */
|
|
|
+#define NWEXT_IPCFG_INTFSTATE 0x1
|
|
|
+#define NWEXT_IPCFG_CFGMETHOD 0x2
|
|
|
+#define NWEXT_IPCFG_IP 0x4
|
|
|
+#define NWEXT_IPCFG_MASK 0x8
|
|
|
+#define NWEXT_IPCFG_GW 0x10
|
|
|
+#define NWEXT_IPCFG_FBIP 0x20
|
|
|
+#define NWEXT_IPCFG_FBMASK 0x40
|
|
|
+#define NWEXT_IPCFG_FBGW 0x80
|
|
|
+#define NWEXT_IPCFG_ALL (NWEXT_IPCFG_INTFSTATE \
|
|
|
+ | NWEXT_IPCFG_CFGMETHOD \
|
|
|
+ | NWEXT_IPCFG_FBIP \
|
|
|
+ | NWEXT_IPCFG_FBMASK \
|
|
|
+ | NWEXT_IPCFG_FBGW \
|
|
|
+ | NWEXT_IPCFG_IP \
|
|
|
+ | NWEXT_IPCFG_MASK \
|
|
|
+ | NWEXT_IPCFG_GW)
|
|
|
+
|
|
|
+#define MAX_RESTART_SERVICE 4
|
|
|
+
|
|
|
+#define MAX_SERVICE 5
|
|
|
+
|
|
|
+/*Used to check the flag status*/
|
|
|
+#define CHECK_FLAG(in,level) ((in&level) == level)
|
|
|
+
|
|
|
+/*Used to set flag value*/
|
|
|
+#define SET_FLAG(out,level) (out|=level)
|
|
|
+
|
|
|
+/* Enable or disable Auto-Negotiation */
|
|
|
+#define AUTONEG_DISABLE 0x00
|
|
|
+#define AUTONEG_ENABLE 0x01
|
|
|
+
|
|
|
+/* Network Link modes */
|
|
|
+#define PHY_SPEED_10 10
|
|
|
+#define PHY_SPEED_100 100
|
|
|
+#define PHY_SPEED_1000 1000
|
|
|
+
|
|
|
+#define PHY_DUPLEX_HALF 0x0
|
|
|
+#define PHY_DUPLEX_FULL 0x1
|
|
|
+
|
|
|
+#define PHY_SPEED_AN_MASK 0x8000 /*Auto-Negotiation Mask for Speed*/
|
|
|
+#define PHY_DUPLEX_AN_MASK 0x4000 /*Auto-Negotiation Mask for Duplex*/
|
|
|
+
|
|
|
+
|
|
|
+/* MII registers for PHY */
|
|
|
+#define MII_BMCR 0x00 /* Basic mode control register */
|
|
|
+#define MII_BMSR 0x01 /* Basic mode status register */
|
|
|
+#define MII_PHY_ID1 0x02 /* PHY identifier 1 */
|
|
|
+#define MII_PHY_ID2 0x03 /* PHY identifier 2 */
|
|
|
+#define MII_ADVERTISE 0x04 /* Advertisement control reg */
|
|
|
+#define MII_LPA 0x05 /* Link partner ability reg */
|
|
|
+#define MII_EXPANSION 0x06 /* Expansion register */
|
|
|
+#define MII_CTRL1000 0x09 /* 1000BASE-T control */
|
|
|
+#define MII_STAT1000 0x0a /* 1000BASE-T status */
|
|
|
+
|
|
|
+/* Mask for BMCR Register settings for Speed/Duplex */
|
|
|
+#define PHY_BMCR_10_FD 0x0100
|
|
|
+#define PHY_BMCR_10_HD 0x0000
|
|
|
+#define PHY_BMCR_100_FD 0x2100
|
|
|
+#define PHY_BMCR_100_HD 0x2000
|
|
|
+#define PHY_BMCR_1000_FD 0x1140
|
|
|
+#define PHY_BMCR_AUTO_NEG 0x3000
|
|
|
+
|
|
|
+/* Mask for ADVERTISE Register settings for Speed/Duplex */
|
|
|
+#define PHY_ADV_AUTO_NEG 0x05e1
|
|
|
+#define PHY_ADV_1000_FD 0x0401
|
|
|
+
|
|
|
+/* Mask for Gigabit Control Register settings for Speed/Duplex */
|
|
|
+#define PHY_GBCR_AUTO_NEG 0x0300
|
|
|
+
|
|
|
+
|
|
|
+#pragma pack (1)
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ uint8_t AutoNegotiationEnable;
|
|
|
+ uint16_t Speed;
|
|
|
+ uint8_t Duplex;
|
|
|
+ uint8_t Interface;
|
|
|
+ uint8_t CapabilitiesSupported;
|
|
|
+} PHYConfig_T;
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ uint8_t Enable; /*Enable/Disable*/
|
|
|
+ uint8_t BondIndex; /*Index value of Bond Interface*/
|
|
|
+ uint8_t BondMode; /*Bond Mode*/
|
|
|
+ uint16_t MiiInterval; /*MII Interval*/
|
|
|
+ uint8_t Slaves; /*Each bit represents the interface Index value i.e 0-7*/
|
|
|
+ uint8_t AutoConf;
|
|
|
+} BondIface;
|
|
|
+typedef struct{
|
|
|
+ unsigned char CfgMethod; /* This field can either be NWCFGTYPE_DHCP or NWCFGTYPE_STATIC */
|
|
|
+ unsigned char MAC[6];
|
|
|
+ unsigned char Local_MAC[6];
|
|
|
+ unsigned char IPAddr[4];
|
|
|
+ unsigned char Broadcast[4];
|
|
|
+ unsigned char Mask[4];
|
|
|
+ unsigned char Gateway[4];
|
|
|
+ unsigned char BackupGateway[4];
|
|
|
+ /* If interface is enabled, value is
|
|
|
+ * NW_INTERFACE_ENABLE otherwise NW_INTERFACE_DISABLE
|
|
|
+ */
|
|
|
+ unsigned char enable;
|
|
|
+ unsigned char IFName[10];
|
|
|
+ unsigned short VLANID;
|
|
|
+ unsigned char vlanpriority;
|
|
|
+ unsigned char Master;
|
|
|
+ unsigned char Slave;
|
|
|
+ unsigned char BondIndex;
|
|
|
+} NWCFG_STRUCT;
|
|
|
+/*ipv6*/
|
|
|
+typedef struct{
|
|
|
+ unsigned char enable;
|
|
|
+ unsigned char MAC[6];
|
|
|
+ unsigned char CfgMethod; /* This field can either be NWCFGTYPE_DHCP or NWCFGTYPE_STATIC */
|
|
|
+ unsigned char LinkIPAddr[16];
|
|
|
+ unsigned char LinkPrefix;
|
|
|
+ unsigned char SiteIPAddr[16];
|
|
|
+ unsigned char SitePrefix;
|
|
|
+ unsigned char GlobalIPAddr[MAX_IPV6ADDRS][16]; //anyCast Globel address //UniCast Globel address
|
|
|
+ unsigned char GlobalPrefix[MAX_IPV6ADDRS];
|
|
|
+ unsigned char Gateway[16];
|
|
|
+ unsigned char IFName[10];
|
|
|
+} NWCFG6_STRUCT;
|
|
|
+
|
|
|
+typedef struct {
|
|
|
+ unsigned char Enable;
|
|
|
+ unsigned short MiiInterval;
|
|
|
+ unsigned char BondMode;
|
|
|
+ unsigned char Slave;
|
|
|
+} BondConf;
|
|
|
+
|
|
|
+typedef struct {
|
|
|
+ unsigned char Upslave;
|
|
|
+} ActiveConf;
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ int8_t Ifcname[16];
|
|
|
+ uint8_t Index;
|
|
|
+ uint8_t Enabled;
|
|
|
+} IfcName_T;
|
|
|
+
|
|
|
+typedef struct{
|
|
|
+ unsigned short Family;
|
|
|
+ NWCFG_STRUCT IPv4;
|
|
|
+ NWCFG6_STRUCT IPv6;
|
|
|
+} ALL_NWCFG_STRUCT;
|
|
|
+
|
|
|
+
|
|
|
+typedef struct{
|
|
|
+ NWCFG_STRUCT NwInfo[10];
|
|
|
+ int IFCount;
|
|
|
+} NWCFGS;
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ /* This field can either be NW_DUPLEX_FULL or NW_DUPLEX_HALF */
|
|
|
+ unsigned long speed;
|
|
|
+
|
|
|
+ /* This field can either be NW_DUPLEX_FULL or NW_DUPLEX_HALF */
|
|
|
+ unsigned int duplex;
|
|
|
+
|
|
|
+ /* This field can either be NW_AUTO_NEG_ON or NW_AUTO_NEG_OFF,
|
|
|
+ * Auto negotiation is applicable for both speed & duplex.
|
|
|
+ */
|
|
|
+ unsigned int autoneg;
|
|
|
+
|
|
|
+ /* This field features the link modes that are supported by the interface */
|
|
|
+ unsigned char supported;
|
|
|
+
|
|
|
+ /*Max transmission unit*/
|
|
|
+ unsigned long maxtxpkt;
|
|
|
+
|
|
|
+ unsigned long wolsupported;
|
|
|
+ unsigned long wolopts;
|
|
|
+
|
|
|
+} ETHCFG_STRUCT;
|
|
|
+
|
|
|
+typedef struct{
|
|
|
+ ETHCFG_STRUCT EthInfo[10];
|
|
|
+} ETHCFGS;
|
|
|
+
|
|
|
+
|
|
|
+typedef struct{
|
|
|
+
|
|
|
+ /* Name of the interface, example: eth0, eth1, ethernet,...*/
|
|
|
+ char IFName[10];
|
|
|
+
|
|
|
+ /*
|
|
|
+ * This field can either be NWCFGTYPE_DHCP or
|
|
|
+ * NWCFGTYPE_STATIC or NWCFGTYPE_DHCPFIRST
|
|
|
+ */
|
|
|
+ unsigned char CfgMethod;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * If interface is enabled, value is NW_INTERFACE_ENABLE
|
|
|
+ * otherwise NW_INTERFACE_DISABLE
|
|
|
+ */
|
|
|
+ unsigned char Enable;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Current IP Origin NWCFGTYPE_DHCP or NWCFGTYPE_STATIC
|
|
|
+ */
|
|
|
+ unsigned char IPOrigin;
|
|
|
+
|
|
|
+ /*
|
|
|
+ * IP assigned: If IPOrgin is DHCP, then this is DHCP IP,
|
|
|
+ * if the IPOrigin is Static, then this is Static IP address
|
|
|
+ */
|
|
|
+ unsigned char IPAddr[4];
|
|
|
+ unsigned char Mask[4];
|
|
|
+ unsigned char Gateway[4];
|
|
|
+
|
|
|
+ /*
|
|
|
+ * Manually configured Fall back (FB) IP
|
|
|
+ */
|
|
|
+ unsigned char FB_IPAddr[4];
|
|
|
+ unsigned char FB_Mask[4];
|
|
|
+ unsigned char FB_Gateway[4];
|
|
|
+
|
|
|
+} NWEXT_IPCFG;
|
|
|
+
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ /*Burned-in MAC address*/
|
|
|
+ unsigned char BurnedMAC[6];
|
|
|
+
|
|
|
+ /* Locally admin-MAC: Setting Local MAC to other than 00:00:00:00:00:00
|
|
|
+ * makes it as current MAC. If a platform does not support. If this is
|
|
|
+ * non-zero then this is current MAC while getting
|
|
|
+ */
|
|
|
+ unsigned char Local_MAC[6];
|
|
|
+
|
|
|
+} NWEXT_MACCFG;
|
|
|
+
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+
|
|
|
+ /* MAC Configuration */
|
|
|
+ NWEXT_MACCFG mac_cfg;
|
|
|
+
|
|
|
+ /* Ethernet Configuration */
|
|
|
+ ETHCFG_STRUCT eth_cfg;
|
|
|
+
|
|
|
+} NWEXT_ETHCFG;
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ unsigned char DNSDhcpEnable; /*Specifies that the DNS server IP addresses should be assigned from the DHCP server*/
|
|
|
+ unsigned char DNSServerEthIndex; /*Specifies that from which DHCP server the IP addresses should be assigned */
|
|
|
+ unsigned char DNSServer1[IP_ADDR_LEN]; /*Specifies the IP address for DNS server 1*/
|
|
|
+ unsigned char DNSServer2[IP_ADDR_LEN]; /*Specifies the IP address for DNS server 2*/
|
|
|
+ unsigned char v4v6;
|
|
|
+ unsigned char RegisterBMCFQDN[MAX_CHANNEL]; /*Register the BMC host name using FQDN method */
|
|
|
+ unsigned char DNSRegisterBMC[MAX_CHANNEL]; /*Enable registering the BMC host name on the DNS server*/
|
|
|
+ unsigned char DNSBMCHostSetting; /*Specifies host name is Automatic or Manual */
|
|
|
+ unsigned char DNSBMCHostNameLen;
|
|
|
+ unsigned char DNSBMCHostName[MAX_HOST_NAME_STRING_SIZE]; /*Specifies the DNS BMC host name*/
|
|
|
+ unsigned char DNSDomainNameDhcpEnable; /*Specifies that the DNS domain name should be assigned from the DHCP server*/
|
|
|
+ unsigned char DNSDomainNameEthIndex; /*Specifies that from which DHCP server the DNS domain name should be assigned */
|
|
|
+ unsigned char DNSDomainNameLen;
|
|
|
+ unsigned char DNSDomainName[MAX_DOMAIN_NAME_STRING_SIZE];/*The DNS domain name string*/
|
|
|
+
|
|
|
+} DNS_CONFIG;
|
|
|
+
|
|
|
+#define DNSCFG_MAX_DOMAIN_NAME_LEN 256 //with null
|
|
|
+#define DNSCFG_MAX_RAC_NAME_LEN 64
|
|
|
+
|
|
|
+/*DNS-Manual enable state*/
|
|
|
+#define DNS_MANUAL_ENABLE 0x1
|
|
|
+#define DNS_MANUAL_DISABLE 0x2
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ unsigned char dnsEnable;
|
|
|
+ unsigned char manualDNSDomain1Length;
|
|
|
+ char manualDNSDomainName1[DNSCFG_MAX_DOMAIN_NAME_LEN];
|
|
|
+ unsigned char manualDNSDomain2Length;
|
|
|
+ char manualDNSDomainName2[DNSCFG_MAX_DOMAIN_NAME_LEN];
|
|
|
+ struct in_addr manualDNSServer1;
|
|
|
+ struct in_addr manualDNSServer2;
|
|
|
+ struct in_addr manualDNSServer3;
|
|
|
+
|
|
|
+} MANUAL_DNS_CONFIG;
|
|
|
+
|
|
|
+
|
|
|
+// /*********************************/
|
|
|
+// /* DNS Configuration structures */
|
|
|
+// /*********************************/
|
|
|
+// #define DOMAIN_V4 1
|
|
|
+// #define DOMAIN_V6 2
|
|
|
+
|
|
|
+// #define CONFDNSCONF "/conf/dns.conf"
|
|
|
+// #define CONFDNSCONF_TMP "/conf/dns.conf.tmp"
|
|
|
+
|
|
|
+// typedef struct
|
|
|
+// {
|
|
|
+// uint8_t HostSetting; /*Specifies host name is Automatic or Manual */
|
|
|
+// uint8_t HostNameLen;
|
|
|
+// uint8_t HostName[MAX_HOSTNAME_LEN]; Specifies the DNS BMC host name
|
|
|
+
|
|
|
+// } HOSTNAMECONF;
|
|
|
+
|
|
|
+// typedef struct
|
|
|
+// {
|
|
|
+// uint8_t dhcpEnable;
|
|
|
+// uint8_t EthIndex;
|
|
|
+// uint8_t v4v6;
|
|
|
+// uint8_t domainname[DNSCFG_MAX_DOMAIN_NAME_LEN];
|
|
|
+// uint8_t domainnamelen;
|
|
|
+// } DOMAINCONF;
|
|
|
+
|
|
|
+// typedef struct
|
|
|
+// {
|
|
|
+// uint8_t DNSIP1[IP6_ADDR_LEN];
|
|
|
+// uint8_t DNSIP2[IP6_ADDR_LEN];
|
|
|
+// uint8_t DNSIP3[IP6_ADDR_LEN];
|
|
|
+// uint8_t DNSEnable;
|
|
|
+// uint8_t DNSDHCP;
|
|
|
+// uint8_t DNSIndex;
|
|
|
+// uint8_t IPPriority;
|
|
|
+// } DNSCONF;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/* Define the network interface */
|
|
|
+typedef enum
|
|
|
+{
|
|
|
+ PENDING=1, // Interface having configured/pending settings
|
|
|
+ ACTIVE // Interface having current/active settings
|
|
|
+}NW_INTERFACE;
|
|
|
+
|
|
|
+typedef struct
|
|
|
+{
|
|
|
+ uint8_t param;
|
|
|
+ uint8_t NwRestartNeeded;
|
|
|
+} MONSETLANPARAM_STRUCT;
|
|
|
+
|
|
|
+
|
|
|
+// typedef struct
|
|
|
+// {
|
|
|
+// NWCFG_STRUCT cfgIPv4[MAX_ETH];
|
|
|
+// NWCFG6_STRUCT cfgIPv6[MAX_ETH];
|
|
|
+// BondIface BondConfig;
|
|
|
+// PHYConfig_T PHYConfig[MAX_ETH];
|
|
|
+// unsigned short mtu_size[MAX_ETH];
|
|
|
+// HOSTNAMECONF HostnameConfig;
|
|
|
+// DOMAINCONF DomainConfig;
|
|
|
+// uint8_t regBMC_FQDN[MAX_CHANNEL];
|
|
|
+// uint8_t TypeOfService[MAX_ETH];
|
|
|
+// DNSCONF DnsIPConfig;
|
|
|
+// } DELAYEDLANRESTART_NWDATA;
|
|
|
+
|
|
|
+
|
|
|
+#pragma pack ()
|
|
|
+
|
|
|
+// /* Functions to read/write current network status */
|
|
|
+// int nwReadNWCfgs(NWCFGS *cfg, ETHCFGS *ethcfg);
|
|
|
+// int IsLinkModeSupported(ETHCFG_STRUCT *ethcfg,uint16_t speed,uint8_t duplex);
|
|
|
+// int nwGetEthInformation(ETHCFG_STRUCT *ethcfg, char * IFName);
|
|
|
+// int nwSetEthInformation(unsigned long speed, unsigned int duplex, char * IFName);
|
|
|
+// int nwWriteNWCfgNoUpDown(NWCFG_STRUCT *cfg);
|
|
|
+// int nwSetEthMTUSize(int mtu, char * IFName);
|
|
|
+
|
|
|
+// int nwSetBkupGWyAddr(unsigned char *ip,uint8_t EthIndex);
|
|
|
+// int nwGetBkupGWyAddr(unsigned char *ip,uint8_t EthIndex);
|
|
|
+// /* One should pass the buffer of size MAX_MAC_LEN to the following function */
|
|
|
+// int nwGetMACAddr(char *MAC);
|
|
|
+// int nwSetMACAddr(char *MAC, int Index);
|
|
|
+// int nwSetGateway(uint8_t* GwIP,uint8_t EthIndex);
|
|
|
+// int nwDelExistingGateway(uint8_t EthIndex);
|
|
|
+
|
|
|
+// /* Functions to set/get MDIO PHY registers */
|
|
|
+// /* These can be used by OEMs to monitor/control the speed/duplex of the PHY */
|
|
|
+// int nwGetPHYRegister(char regNo, char *IfcName);
|
|
|
+// int nwSetPHYRegister(unsigned short regValue, char regNo, char *IfcName);
|
|
|
+
|
|
|
+// /* Function to generate an IPv6 address based on EUI-64 algo */
|
|
|
+// int nwFormIPv6Addr_EUI64(uint8_t *IPv6Addr, uint8_t EthIndex, int GlobalIPv6);
|
|
|
+
|
|
|
+// int nwGetNWInformations(NWCFG_STRUCT *cfg,char *IFName);
|
|
|
+
|
|
|
+// int nwMakeIFDown(uint8_t EthIndex);
|
|
|
+// int nwMakeIFUp(uint8_t EthIndex);
|
|
|
+// extern void GetNwCfgInfo(void);
|
|
|
+// extern int GetNoofInterface(void);
|
|
|
+
|
|
|
+// /* Extended API for network*/
|
|
|
+// int GetHostEthbyIPAddr(char *IPAddr);
|
|
|
+// int GetHostEthByIPv6Addr(char *IPAddr);
|
|
|
+// int GetIfcNameByIndex(int Index, char * IfcName);
|
|
|
+// int nwGetSrcMacAddr(uint8_t* IpAddr,uint8_t EthIndex,uint8_t *MacAddr);
|
|
|
+// int nwGetSrcCacheMacAddr(uint8_t* IpAddr, uint8_t EthIndex, uint8_t *MacAddr);
|
|
|
+// int nwGetSrcMacAddr_IPV6(uint8_t* IpAddr,uint8_t *MacAddr);
|
|
|
+// int nwGetNWExtEthCfg(NWEXT_ETHCFG *cfg);
|
|
|
+// int nwGetNWInterfaceStatus(void);
|
|
|
+// int nwSetNWExtEthCfg(NWEXT_ETHCFG *cfg, int nwSetFlag);
|
|
|
+// int nwSetNWExtIPCfg (NWEXT_IPCFG *cfg, int nwSetFlag,int global_ipv6);
|
|
|
+// int GetNwLinkStatus(int fd,char *ifname);
|
|
|
+// int GetNwLinkType_mii(char *ifname);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn nwUpdateVLANInterfacesFile
|
|
|
+// *@brief This function is invoked to update vlan interfaces file
|
|
|
+// */
|
|
|
+// int nwUpdateVLANInterfacesFile(void);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn ReadVLANFile
|
|
|
+// *@brief This function is invoked to read the vlan configuration files
|
|
|
+// *@param SettingStr - Pointer to setting name that we want to read from vlan configurations file
|
|
|
+// *@param desArr - pointer to an array where the reading has to be stored
|
|
|
+// */
|
|
|
+// int ReadVLANFile(char *SettingStr, uint16_t *desArr);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn WriteVLANFile
|
|
|
+// *@brief This function is invoked to write all the vlan configuration files
|
|
|
+// *@param SettingStr - Pointer to setting name that we want to write into vlan configurations file
|
|
|
+// *@param desArr - pointer to an array where the reading has to be stored
|
|
|
+// *@param EthIndex - char value to Ethernet index
|
|
|
+// *@param val - short int to the value that has to be written
|
|
|
+// */
|
|
|
+// int WriteVLANFile(char *SettingStr, uint16_t *desArr, uint8_t EthIndex, uint16_t val);
|
|
|
+
|
|
|
+// /*ipv6*/
|
|
|
+// void ConvertIP6numToStr(unsigned char *var, unsigned int len,unsigned char *string) ;
|
|
|
+// int nwReadNWCfg_IPv6(NWCFG6_STRUCT *cfg,uint8_t EthIndex);
|
|
|
+// int GetDefaultGateway_ipv6(unsigned char *gw,uint8_t *Interface);
|
|
|
+// int nwGetResolvConf_v4_v6(char* DNS1,char*DNS2,char *DNS3, uint8_t DNSIPPriority,char* domain,unsigned char* domainnamelen);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn nwReadNWCfg_v4_v6
|
|
|
+// *@brief This function is invoked to Get the current network status of both IPv4 and IPv6 networks.
|
|
|
+// *@ If there is no need of IPv6 data means, then just pass NULL to IPv6 pointer.
|
|
|
+// *@param cfg - Pointer to Structure used to get IPv4 network configurations.
|
|
|
+// *@param cfg6 - Pointer to Structure used to get IPv6 network configurations.
|
|
|
+// *@param EthIndex - pointer to char used to store Interface Index value.
|
|
|
+// *@return Returns 0 on success and -1 on fails
|
|
|
+// */
|
|
|
+// int nwReadNWCfg_v4_v6(NWCFG_STRUCT *cfg, NWCFG6_STRUCT *cfg6, uint8_t EthIndex,int global_ipv6);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn nwWriteNWCfg_ipv4_v6
|
|
|
+// *@brief This function is invoked to set both IPv4 and IPv6 network configurations.
|
|
|
+// *@ If there is no need to write IPv6 data means, then just pass NULL to IPv6 pointer.
|
|
|
+// *@param cfg - Pointer to Structure used to set IPv4 network configurations
|
|
|
+// *@param cfg6 - Pointer to Structure used to set IPv6 network configurations
|
|
|
+// *@param EthIndex - pointer to char used to store Interface Index value.
|
|
|
+// *@return Returns 0 on success and -1 on fails
|
|
|
+// */
|
|
|
+// int nwWriteNWCfg_ipv4_v6(NWCFG_STRUCT *cfg, NWCFG6_STRUCT *cfg6, uint8_t EthIndex);
|
|
|
+
|
|
|
+
|
|
|
+// * @fn nwConfigureBonding
|
|
|
+// * @brief This function will Enable/Disable the bonding support
|
|
|
+// * @param BondCfg [in] Bonding configuration table
|
|
|
+// * @param BondIndex [in] Index value of Bond interface to be configured
|
|
|
+// * @return 0 on success, -1 on failure
|
|
|
+
|
|
|
+// int nwConfigureBonding(BondIface *BondCfg,uint8_t EthIndex,int timeoutd_sess_timeout,int global_ipv6);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn nwGetBondConf
|
|
|
+// * @brief This function will Get the bonding Configuration of Specified index
|
|
|
+// * @param BondCfg [out] Bonding configuration table
|
|
|
+// * @param BondIndex [in] Index value of Bond interface
|
|
|
+// * @return 0 on success, -1 on failure
|
|
|
+// */
|
|
|
+// int nwGetBondConf(BondIface *BondCfg,uint8_t BondIndex);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn CheckIfcEntry
|
|
|
+// * @brief This function will check the interface presence in ifcname table
|
|
|
+// * @param Index [in] index value
|
|
|
+// * @param IfcType [in] interface type
|
|
|
+// * @return 0 in success, -1 on failure
|
|
|
+// */
|
|
|
+// int CheckIfcEntry(uint8_t Index,uint8_t IfcType);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn CheckBondSlave
|
|
|
+// * @brief This function will check the given interfaces slave status
|
|
|
+// * @param EthIndex[in] interface's Ethindex value
|
|
|
+// * @returns 1 if the interface is a slave of any bond interface, otherwise 0
|
|
|
+// */
|
|
|
+// int CheckBondSlave(uint8_t EthIndex);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn CheckIfcLinkStatus
|
|
|
+// * @brief This function will check the interface's Link health
|
|
|
+// * @param Index [in] index value
|
|
|
+// * @return -1 on failure
|
|
|
+// */
|
|
|
+// int CheckIfcLinkStatus(uint8_t Index);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn InitIfcNameTable
|
|
|
+// * @brief This function is used to initialize the Ifcname table based on NIC count
|
|
|
+// * @return -1 on failure
|
|
|
+// */
|
|
|
+// int InitIfcNameTable();
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn IsKernelIPv6Enabled
|
|
|
+// *@brief This function is used to check for IPv6 support in the kernel.
|
|
|
+// *@return Returns 1 on success and 0 on fails
|
|
|
+// */
|
|
|
+// int IsKernelIPv6Enabled();
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn nwActiveSlave
|
|
|
+// * @brief This function will active the single slave for the bonding interface
|
|
|
+// * @param SlaveIndex to be activated
|
|
|
+// * @return 0 on success, -1 on failure
|
|
|
+// */
|
|
|
+// int nwActiveSlave(uint8_t BondIndex,uint8_t SlaveIndex);
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn nwGetActiveSlave
|
|
|
+// * @brief This function will gets the active interface of specified bondindex
|
|
|
+// * @param Bondindex [in] bonding index, Activeindex[out] active slaves
|
|
|
+// * @return 0 on success, -1 on failure
|
|
|
+// */
|
|
|
+// int nwGetActiveSlave(uint8_t BondIndex,uint8_t *ActiveIndex);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn Write_dhcp6c_conf
|
|
|
+// *@brief This function is used to write interface wise entries for dhcp6c.conf file.
|
|
|
+// *@return Returns 0 on success and -1 on fails
|
|
|
+// */
|
|
|
+// int Write_dhcp6c_conf();
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn IsValidGlobalIPv6Addr
|
|
|
+// *@brief This function will check the given IPv6 address as global IP address or not
|
|
|
+// *@return Return 0 on success and -1 on failure
|
|
|
+// */
|
|
|
+// int IsValidGlobalIPv6Addr(struct in6_addr * IPv6Addr);
|
|
|
+
|
|
|
+// /* DNS */
|
|
|
+// int nwSetResolvConf_v4_v6(char* dns1,char* dns2,char* dnsv3,char* domain);
|
|
|
+
|
|
|
+// int ReadDNSConfFile ( DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN);
|
|
|
+// int WriteDNSConfFile ( DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig, uint8_t *regBMC_FQDN);
|
|
|
+// int nwGetAllDNSConf( HOSTNAMECONF *HostnameConfig, DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN );
|
|
|
+// int nwSetAllDNSConf( HOSTNAMECONF *HostnameConfig, DOMAINCONF *DomainConfig, DNSCONF *DnsIPConfig,uint8_t *regBMC_FQDN );
|
|
|
+
|
|
|
+// /* Library for AMI Extended DNS command */
|
|
|
+// int nwSetHostName(char *name);
|
|
|
+// int nwGetDNSConf(unsigned char* UseDHCPForDNS,unsigned char* UseDHCPForDomain,unsigned char* DoDDNS);
|
|
|
+// int nwGetAllDNSCfg(DNS_CONFIG* dnscfg);
|
|
|
+// int nwSetDNSConf(unsigned char UseDHCPForDNS,unsigned char UseDHCPForDomain,unsigned char DoDDNS);
|
|
|
+// int nwSetAllDNSCfg_NotRestart(DNS_CONFIG* dnscfg);
|
|
|
+
|
|
|
+// int nwGetDHCPServerIP(char *dhcpServerIP);
|
|
|
+// /*!
|
|
|
+// * @brief Reading current/active network configuration using netman script
|
|
|
+// * #param[out] cfg - IP, Netmask, Gateway, Conf method(dhcp/statis)
|
|
|
+// * @returns 0 on succee , -1 on failure
|
|
|
+// */
|
|
|
+// int nwGetNwActIPCfg( NWEXT_IPCFG *cfg );
|
|
|
+// int GetIPAdrressType(uint8_t* IPAddr);
|
|
|
+
|
|
|
+// int nwSyncNWCfg_ipv4_v6(NWCFG_STRUCT *cfg,NWCFG6_STRUCT *cfg6, uint8_t EthIndex);
|
|
|
+
|
|
|
+// /**
|
|
|
+// *@fn GetIPAddrstr
|
|
|
+// *@brief This function is used to get IP address string for given ip or hostname
|
|
|
+// *@param addr - pointer to string of IP address of hostname
|
|
|
+// *@param pResIPaddr - pointer to IP address string
|
|
|
+// *@return Returns address family (AF_INET or AF_INET6) on success and -1 on failure
|
|
|
+// */
|
|
|
+
|
|
|
+// int GetIPAddrstr(unsigned char *addr, char *pResIPaddr);
|
|
|
+// int getFullyQualifiedDName(char *fqdname, uint8_t EthIndex);
|
|
|
+// int nwGetExtMACAddr(unsigned char *MAC);
|
|
|
+
|
|
|
+
|
|
|
+// /*
|
|
|
+// * @fn IsBMCNFSMode
|
|
|
+// * @brief Check whether BMC is in BMC Mode.
|
|
|
+// * @return 0 for FALSE,
|
|
|
+// * 1 for TRUE.
|
|
|
+// */
|
|
|
+// int IsBMCNFSMode();
|
|
|
+
|
|
|
+// int nwSyncBondCfg(BondIface *pBondCfg);
|
|
|
+// void GetNwStruct_v4_v6(NWCFG_STRUCT *pCFGIPv4,NWCFG6_STRUCT *pCFGIPv6);
|
|
|
+// int HandleDelayedNwRestart(DELAYEDLANRESTART_NWDATA *pDelyedLAN_NwCfgs, uint8_t Flag_SetDNS, uint8_t EthIndex);
|
|
|
+// int SetNWSpeed(PHYConfig_T *pPHYConfig, char * IFName);
|
|
|
+
|
|
|
+// int SetNWMTUSize(int mtu, char * IFName);
|
|
|
+// int SetVLANPriority(uint16_t vlanID, uint8_t VLANPriority, uint8_t TypeOfService, char *IfcName);
|
|
|
+
|
|
|
+#endif /* _NWCFG_H */
|