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

📄 ethernet.h

📁 SimpleGraphicOperatingSystem 32位图形化操作系统 多进程 支持FAT32 详见www.sgos.net.cn
💻 H
字号:
#ifndef ETHERNET_H_
#define ETHERNET_H_

#include <Type.h>
//! IP packet type.
#define ETH_FRAME_IP		0x0800
//! ARP packet type.
#define ETH_FRAME_ARP		0x0806
//! Size of an ethernet address (a.k.a. MAC).
#define ETH_ADDR_LEN		6
//! Size of the ethernet header.
#define ETH_HEAD_LEN		14
//! Minimum ethernet packet size.
#define ETH_MIN_LEN		60
//! Maximum ethernet packet size.
#define ETH_FRAME_LEN		1514
//! Ethernet MTU (Maximum transfer unit).
#define ETH_MTU			(ETH_FRAME_LEN - ETH_HEAD_LEN)

//! Send and receive buffers size.
#define ETH_RECV_BUF_DIM	10

//! Physical packet structure.
typedef struct _PhyPacket
{
	//! The packet size.
	int length;
	//! The packet content.
	unsigned char data[ETH_FRAME_LEN];
} PhyPacket, *PPhyPacket;

//! The ethernet buffer structure.
typedef struct _EthernetBuffer
{
	//! The packets pointers.
	PhyPacket packet[ETH_RECV_BUF_DIM];
	//! The position of the next packet received.
	int read;
	//! The position of the next packet to be sent.
	int write;
	//! The amount of packets in the buffer.
	int count;
} EthernetBuffer, *PEthernetBuffer;

//!NetEthernet Ethernet Layer
//! An ethernet packet structure.
typedef struct _EthernetPacket
{
	//! Destination MAC address.
	t_8  destination[ETH_ADDR_LEN];
	//! Source MAC address.
	t_8  source[ETH_ADDR_LEN];
	//! The packet type.
	t_16 type;
	//! The packet content.
	t_8 data[1];
}  __attribute__ ((packed)) EthernetPacket, *PEthernetPacket;

typedef struct _NetCard{
    t_8 macAddress[6];
    void* card;
    int (*sendPocket)( void* card, const char* data, int len );
}NetCard, *PNetCard;

#endif // ETHERNET_H_

⌨️ 快捷键说明

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