#ifndef NETCONFIG_H_ #define NETCONFIG_H_ #include "ipconfig.h" #include "brconfig.h" #define PORT_MAX_VLAN (10) #define IPV6_ADDR_LOOPBACK 0x0010U #define IPV6_ADDR_LINKLOCAL 0x0020U #define IPV6_ADDR_SITELOCAL 0x0040U #define IPV6_ADDR_COMPATv4 0x0080U /* CMDs currently supported */ #define ETHTOOL_GSET 0x00000001 /* DEPRECATED, Get settings. * Please use ETHTOOL_GLINKSETTINGS*/ #define ETHTOOL_GLINK 0x0000000a #define ETHTOOL_GLINKSETTINGS 0x0000004c /* Get ethtool_link_settings */ #define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (127) #define ETHTOOL_DECLARE_LINK_MODE_MASK(name) \ uint name[ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32] /* 事件通知数据结构 */ struct _net_ifnum { int wan_num; int lan_num; }; typedef struct _net_ifnum net_ifnum_t; #if 0 struct _ethtool_value { uint cmd; uint data; }; typedef struct _ethtool_value ethtool_value_t; struct ethtool_cmd { uint cmd; uint supported; uint advertising; uint16 speed; uchar duplex; uchar port; uchar phy_address; uchar transceiver; uchar autoneg; uchar mdio_support; uint maxtxpkt; uint maxrxpkt; uint16 speed_hi; uchar eth_tp_mdix; uchar eth_tp_mdix_ctrl; uint lp_advertising; uint reserved[2]; }; struct ethtool_link_settings { uint cmd; uint speed; uchar duplex; uchar port; uchar phy_address; uchar autoneg; uchar mdio_support; uchar eth_tp_mdix; uchar eth_tp_mdix_ctrl; uchar link_mode_masks_nwords; uchar transceiver; uchar reserved1[3]; uint reserved[7]; uint link_mode_masks[0]; }; #endif struct ethtool_link_data{ struct ethtool_link_settings req; uint link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32]; }; struct user_net_device_stats { unsigned long long rx_packets; /* total packets received */ unsigned long long tx_packets; /* total packets transmitted */ unsigned long long rx_bytes; /* total bytes received */ unsigned long long tx_bytes; /* total bytes transmitted */ unsigned long rx_errors; /* bad packets received */ unsigned long tx_errors; /* packet transmit problems */ unsigned long rx_dropped; /* no space in linux buffers */ unsigned long tx_dropped; /* no space available in linux */ unsigned long rx_multicast; /* multicast packets received */ unsigned long rx_compressed; unsigned long tx_compressed; unsigned long collisions; /* detailed rx_errors: */ unsigned long rx_length_errors; unsigned long rx_over_errors; /* receiver ring buff overflow */ unsigned long rx_crc_errors; /* recved pkt with crc error */ unsigned long rx_frame_errors; /* recv'd frame alignment error */ unsigned long rx_fifo_errors; /* recv'r fifo overrun */ unsigned long rx_missed_errors; /* receiver missed packet */ /* detailed tx_errors */ unsigned long tx_aborted_errors; unsigned long tx_carrier_errors; unsigned long tx_fifo_errors; unsigned long tx_heartbeat_errors; unsigned long tx_window_errors; }; struct interface { struct interface *next, *prev; char name[IFNAMSIZ]; /* interface name */ short type; /* if type */ short flags; /* various flags */ int metric; /* routing metric */ int mtu; /* MTU value */ int tx_queue_len; /* transmit queue length */ struct ifmap map; /* hardware setup */ struct sockaddr addr; /* IP address */ struct sockaddr dstaddr; /* P-P IP address */ struct sockaddr broadaddr; /* IP broadcast address */ struct sockaddr netmask; /* IP network mask */ struct sockaddr ipxaddr_bb; /* IPX network address */ struct sockaddr ipxaddr_sn; /* IPX network address */ struct sockaddr ipxaddr_e3; /* IPX network address */ struct sockaddr ipxaddr_e2; /* IPX network address */ struct sockaddr ddpaddr; /* Appletalk DDP address */ struct sockaddr ecaddr; /* Econet address */ int has_ip; int has_ipx_bb; int has_ipx_sn; int has_ipx_e3; int has_ipx_e2; int has_ax25; int has_ddp; int has_econet; char hwaddr[32]; /* HW address */ int statistics_valid; struct user_net_device_stats stats; /* statistics */ int keepalive; /* keepalive value for SLIP */ int outfill; /* outfill value for SLIP */ }; ret_code if_ioctl(int af, unsigned long request, caddr_t ifreq, int *ret); ret_code if_get_linkstat(if_info_t *if_info, int *code); ret_code if_get_maxspeed(if_info_t *if_info, int *code); ret_code if_get_hwaddr(if_info_t *if_info, int *code); ret_code if_set_up(char *ifname, int *code); ret_code if_set_down(char *ifname, int *code); ret_code if_set_prefix(ip_config_t *ip_conf, int *code); ret_code if_set_prefix6(uint config_type, ip_config_t *ip_conf, int *code); ret_code if_get_prefix(if_info_t *if_conf, int *code); ret_code if_num_init(); ret_code net_main(); int if_lan_num(); int if_wan_num(); int if_wan_get(char ifname[MAX_IF_NUM][INTERFACE_NAMSIZ], int max_port); int if_lan_get(char ifname[MAX_IF_NUM][INTERFACE_NAMSIZ], int max_port); int if_get_allport(struct ifreq *ifreq, int max_port); int if_get_prefix6(if_info_t *if_conf); #endif