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

📄 ip.h

📁 此文档为采用FPGA实现的以太网MAC层
💻 H
字号:
#ifndef _IP_H#define _IP_H#include "sys.h"#include "mac.h"typedef struct{    Uint8 version;    Uint8 service;    Uint16 packetlength;    Uint16 ident;    Uint16 offset;    Uint8 timetolive;    Uint8 protocol;    Uint16 checksum;    Uint16 sourceip_h;    Uint16 sourceip_l;    Uint16 destip_h;    Uint16 destip_l;}IPHEADER;typedef struct{    Uint16 ip_address_h;    Uint16 ip_address_l;    Uint8 mac_address[6];} ARP_ENTRY;#define ENTRY_SIZE 5typedef struct{    Uint16 index;        //Holds index of next entry to fill out    ARP_ENTRY entry[ENTRY_SIZE];} ARP_TABLE;typedef struct{    Uint16 ip_h;    Uint16 ip_l;    Uint8 domain[62];} IP_TABLE_ENTRY;#define IP_TABLE_ENTRY_COUNT 5typedef struct{    Uint16 index;    IP_TABLE_ENTRY dns_server;    IP_TABLE_ENTRY iptable[IP_TABLE_ENTRY_COUNT];} IP_TABLE;#define IP_SIZE sizeof(IPHEADER)#define IP_OFFSET ETH_SIZE#define PROTOCOL_UDP 0x11#define PROTOCOL_ICMP 0x1#define PROTOCOL_TCP 0x6Uint8 ip_process(IPHEADER *packet, ETHHEADER *eth_header);//unsigned int ip_packet(unsigned char protocol, unsigned long src_ip, unsigned long dest_ip, unsigned int data_len, unsigned int *packet);Uint16 ip_packet(IPHEADER *packet, Uint16 data_len);Uint16 ip_chksum(Uint16 *buf,Uint16 len);Uint16 ip_chksum2(Uint16 *buf,Uint16 len,Uint16 *buf2,Uint16 len2);void ip_init(void);void ip_send(Uint16 dest_ip_h, Uint16 dest_ip_l, Uint16 data_len, Uint8 protocol);void arptable_add(Uint16 ip_address_h, Uint16 ip_address_l, Uint8 *mac_address);Uint16 arptable_match(Uint16 ip_address_h, Uint16 ip_address_l);#endif

⌨️ 快捷键说明

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