⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 net_ipv4.h

📁 em86xx 完整启动程序,支持网络下载与串通下载
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************** Copyright (c) 2002-2004  Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//* This file is part of the boot loader *//* * net_ipv4.h * * UDP/IP protocol implementation (net_ipv4.c) * BOOTP/DHCP service (net_ipv4_bootp.c) * TFTP service (net_ipv4_tftp.c) */#ifndef __BOOTLOADER_NET_IPV4_H#define __BOOTLOADER_NET_IPV4_H#include "system.h"/* * Basic TCP / IP related definitions * Some of these definitions are from /usr/include/netinet/in.h *//* Standard well-defined IP protocols. : RFC 790 */enum {    IPPROTO_IP = 0,                     /* Dummy protocol for TCP.  */    IPPROTO_ICMP = 1,                   /* Internet Control Message Protocol.  */    IPPROTO_IGMP = 2,                   /* Internet Group Management Protocol. */    IPPROTO_TCP = 6,                    /* Transmission Control Protocol.  */    IPPROTO_UDP = 17,                   /* User Datagram Protocol.  */    IPPROTO_RAW = 255,                  /* Raw IP packets.  */    IPPROTO_MAX};/* Standard well-known ports.  */enum {    IPPORT_ECHO = 7,                    /* Echo service.  */    IPPORT_DISCARD = 9,                 /* Discard transmissions service.  */    IPPORT_SYSTAT = 11,                 /* System status service.  */    IPPORT_DAYTIME = 13,                /* Time of day service.  */    IPPORT_NETSTAT = 15,                /* Network status service.  */    IPPORT_FTP = 21,                    /* File Transfer Protocol.  */    IPPORT_TELNET = 23,                 /* Telnet protocol.  */    IPPORT_SMTP = 25,                   /* Simple Mail Transfer Protocol.  */    IPPORT_TIMESERVER = 37,             /* Timeserver service.  */    IPPORT_WHOIS = 43,                  /* Internet Whois service.  */    IPPORT_DOMAINSERVER = 53,           /* Domain name server */    IPPORT_BOOTP_SERVER = 67,           /* Bootstrap Protocol service */    IPPORT_BOOTP_CLIENT = 68,           /* Bootstrap Protocol service */    IPPORT_TFTP = 69,                   /* Trivial File Transfer Protocol.  */    IPPORT_FINGER = 79,                 /* Finger service.  */    IPPORT_SUNRPC = 111,                /* SUN Remote Procedure Call protocol */    /* Ports less than this value are reserved for privileged processes.  */    IPPORT_RESERVED = 1024,    /* Ports greater this value are reserved for (non-privileged) servers.  */    IPPORT_USERRESERVED = 5000};/*  * Internet address  * Some of these definitions are from /usr/include/netinet/in.h */typedef uint32_t in_addr_t;#define INADDR_TO_STR(ipaddr)   ((unsigned char *) &(ipaddr))#define INADDR_FROM_STR(ipaddr) (*(in_addr_t *) ipaddr)#define INADDR_FROM_4INTS(a, b, c, d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))// Definitions of the bits in an Internet address integer.// On subnets, host and network parts are found according// to the subnet mask, not these masks.#define IN_CLASSA(a)            ((((long int) (a)) & 0x80000000) == 0)#define IN_CLASSA_NET           0xff000000#define IN_CLASSA_NSHIFT        24#define IN_CLASSA_HOST          (0xffffffff & ~IN_CLASSA_NET)#define IN_CLASSA_MAX           128#define IN_CLASSB(a)            ((((long int) (a)) & 0xc0000000) == 0x80000000)#define IN_CLASSB_NET           0xffff0000#define IN_CLASSB_NSHIFT        16#define IN_CLASSB_HOST          (0xffffffff & ~IN_CLASSB_NET)#define IN_CLASSB_MAX           65536#define IN_CLASSC(a)            ((((long int) (a)) & 0xe0000000) == 0xc0000000)#define IN_CLASSC_NET           0xffffff00#define IN_CLASSC_NSHIFT        8#define IN_CLASSC_HOST          (0xffffffff & ~IN_CLASSC_NET)#define IN_CLASSD(a)            ((((long int) (a)) & 0xf0000000) == 0xe0000000)#define IN_MULTICAST(a)         IN_CLASSD(a)#define IN_MULTICAST_NET        0xF0000000/* Address to accept any incoming messages. */#define INADDR_ANY              ((unsigned long int) 0x00000000)/* Address to send to all hosts. */#define INADDR_BROADCAST        ((unsigned long int) 0xffffffff)/* Address indicating an error return. */#define INADDR_NONE             ((unsigned long int) 0xffffffff)/* Address internally used as invalid address */#define INADDR_INVALID          ((unsigned long int) 0x00000000)/* * Ethernet related definitions * Some of the definitions are from /usr/include/linux/if_ether.h */// IEEE 802.3 Ethernet magic constants.  The frame sizes omit the preamble// and FCS/CRC (frame check sequence). #define ETH_ALEN                6       /* Octets in one ethernet addr   */#define ETH_HLEN                14      /* Total octets in header.   */#define ETH_ZLEN                60      /* Min. octets in frame sans FCS */#define ETH_DATA_LEN            1500    /* Max. octets in payload    */#define ETH_FRAME_LEN           1514    /* Max. octets in frame sans FCS */#define ETH_BUF_LEN             1536    /* buffer */// ethernet protocol ID#define ETH_P_LOOP              0x0060  /* Ethernet Loopback packet */#define ETH_P_IP                0x0800  /* Internet Protocol packet */#define ETH_P_ARP               0x0806  /* Address Resolution packet    */#define ETH_P_RARP              0x8035  /* Reverse Addr Res packet  */// ethernet packet headertypedef struct ethhdr {    uint8_t h_dest[ETH_ALEN];           /* destination eth addr */    uint8_t h_source[ETH_ALEN];         /* source ether addr    */    uint16_t h_proto;                   /* packet type ID field */} __attribute__((packed)) ethhdr_t;/* * ARP related definitions * Some of the definitions are from /usr/include/linux/if_arp.h */// ARP retry maximum count#define MAX_ARP_RETRIES         2// index in the arptable#define ARP_CLIENT              0       /* local address */ #define ARP_GATEWAY             1       /* gateway */#define ARP_DNS                 2       /* DNS server */#define ARP_USER                3       /* from this, general purpose ARP slot */#define MAX_ARPTABLE            16      /* size of internal ARP table buffer */// internal data structure containing ARP listtypedef struct arptable {    in_addr_t ipaddr;                   // IP address in network byte order    in_addr_t netmask;                  // network mask in network byte order    uint8_t node[6];                    // hardware address} __attribute__((packed)) arptable_t;extern arptable_t g_arptable[];/* ARP protocol HARDWARE identifiers. */#define ARPHRD_ETHER            1       /* Ethernet 10Mbps      *//* ARP protocol opcodes. */#define ARPOP_REQUEST           1       /* ARP request          */#define ARPOP_REPLY             2       /* ARP reply            */#define ARPOP_RREQUEST          3       /* RARP request         */#define ARPOP_RREPLY            4       /* RARP reply           */typedef struct arprequest {    uint16_t ar_hrd;                    /* format of hardware address */    uint16_t ar_pro;                    /* format of protocol address */    uint8_t ar_hln;                     /* length of hardware address */    uint8_t ar_pln;                     /* length of protocol address */    uint16_t ar_op;                     /* ARP opcode (command) */    // Ethernet ARP packet data     uint8_t ar_sha[6];                  /* sender hardware address */    in_addr_t ar_sip;                   /* sender IP address */    uint8_t ar_tha[6];                  /* target hardware address */    in_addr_t ar_tip;                   /* target IP address */} __attribute__((packed)) arprequest_t;/* * IP related definitions * Some of the definitions are from /usr/include/linux/ip.h */// IP packet headertypedef struct iphdr {#ifdef CONFIG_BIGENDIAN    uint8_t version : 4;    uint8_t ihl : 4;#else    uint8_t ihl : 4;    uint8_t version : 4;#endif    uint8_t tos;                        /* */    uint16_t tot_len;                   /* size of header + body */    uint16_t id;                        /* */    uint16_t frag_off;                  /* */    uint8_t ttl;                        /* */    uint8_t protocol;                   /* */    uint16_t check;                     /* checksum of IP header */    in_addr_t saddr;                    /* */    in_addr_t daddr;                    /* */} __attribute__((packed)) iphdr_t;/* * ICMP related definitions * Some of these definitions are from /usr/include/linux/icmp.h * RFC 792 */// ICMP type#define ICMP_ECHOREPLY      0           /* Echo Reply               */#define ICMP_DEST_UNREACH   3           /* Destination Unreachable  */#define ICMP_SOURCE_QUENCH  4           /* Source Quench            */#define ICMP_REDIRECT       5           /* Redirect (change route)  */#define ICMP_ECHO           8           /* Echo Request             */#define ICMP_TIME_EXCEEDED  11          /* Time Exceeded            */#define ICMP_PARAMETERPROB  12          /* Parameter Problem        */#define ICMP_TIMESTAMP      13          /* Timestamp Request        */#define ICMP_TIMESTAMPREPLY 14          /* Timestamp Reply          */#define ICMP_INFO_REQUEST   15          /* Information Request      */#define ICMP_INFO_REPLY     16          /* Information Reply        */#define ICMP_ADDRESS        17          /* Address Mask Request     */#define ICMP_ADDRESSREPLY   18          /* Address Mask Reply       */#define NR_ICMP_TYPES       18// ICMP data length #define MAX_ICMP_DATA       128// ICMP packet header and body

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -