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

📄 ethernet.h

📁 阿根廷教授编写的嵌入式internet的实验教程的高质量代码
💻 H
字号:
/******************************************************************************************
   Ethernet.h (v1.0)
-------------------------------------------------------------------------------------
This code is from the book:
"Embedded Internet: TCP/IP Basics, Implementation and Applications" by Sergio Scaglia
[Pearson Education, 2006 - ISBN: 0-32-130638-4]

This code is copyright (c) 2006 by Sergio Scaglia, and it may only be used for educational
purposes.  For commercial use, please contact me at sscaglia@intramarket.com.ar
For more information and updates, please visit www.embeddedinternet.org
******************************************************************************************/

#ifndef __Ethernet_H
#define __Ethernet_H

#define ARP_PROTOCOL	    0x0806
#define IP_PROTOCOL	    0x0800
#define ICMP_PROTOCOL	    1
#define UDP_PROTOCOL	    17
#define TCP_PROTOCOL	    6
	
#define HTONS(n) ((((unsigned short)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
#define FRAMEr   ((struct ethernet_hdr *)&rx_buf[0])
#define FRAMEt   ((struct ethernet_hdr *)&tx_buf[0])

#pragma pack(1)
struct ethernet_hdr {
  char destination[6];
  char source[6];
  unsigned short protocol;
};
#pragma pack()


extern char MyMAC[];
extern char MyIP[];
extern char Gateway[];
extern char SubNetMask[];


void ethernet_init(void);
void ethernet_poll(void);
void ethernet_send(unsigned short protocol, unsigned short len);

#endif

⌨️ 快捷键说明

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