📄 udp.h
字号:
/******************************************************************
* udp.h:
*
* Copyright (c) 2001 Atmel Corporation.
* All Rights Reserved.
*
* You are autorized to use, copy and distribute this software only at
* a single site (the term "site" meaning a single company location).
* This copyright notice must be included in any copy, modification
* or portion of this software merged into another program.
*
* This software is licenced solely for use with Atmel AVR micro
* controller family. The software may not be modified to execute on
* any other microcontroller architectures
*
* This software is provided "as is"; Without warranties either express
* or implied, including any warranty regarding merchantability,
* fitness for a particular purpose or noninfringement.
*
* In no event shall Atmel or its suppliers be liable for any special,
* indirect,incidential or concequential damages resulting from the
* use or inability to use this software.
*
* Revision history:
*
* January 17, 2001: Version 1.0 Created by JB
* July 13, 2001 Version 1.2 JB
* - Changed to IAR compiler V2.25
* - Renamed flash file functions to avoid conflict with
* standard file I/O names
* - Bug fixes in HTTP
* - Speed optimization in TCP
*
*
*******************************************************************/
//frame offset
#define UDP_SENDER_PORT 0
#define UDP_TARGET_PORT 1
#define UDP_LENGTH 2
#define UDP_CHECKSUM 3
#define UDP_DATA 4
#define UDP_HEADER_LENGTH 8
#define UDP_HEADER_START 17 //start index of udp-header in frame
#define UDP_PSEUDO_HEADER_LENGTH 12 //pseudo header length
#define UDP_MAX_DATA_LENGTH 1400 //max UDP data size on ethernet is 1472 bytes
#define UDP_NUM_BUF 1 //number of udp-buffers
/* udp-buffer structure */
typedef struct{
unsigned int dataLength; //length of data
unsigned int hisIP0; //destination ip
unsigned int hisIP1; //destination ip
unsigned int hisPort; //destination port
unsigned int myPort; //source port
unsigned char data[UDP_MAX_DATA_LENGTH]; //data
}UDPB;
/*
UDP-User interface.
*/
/*If data is availible, it is copied to appBuffer and 1 is returned, zero is returned otherwise*/
unsigned char readUDP(unsigned int port,UDPB * appBuffer);
/*returns number of bytes sent*/
unsigned int sendUDP(unsigned char *data, unsigned int dataLength,unsigned int hisIP0,unsigned int hisIP1,unsigned int myPort,unsigned int hisPort);
/*
Lower level interface.
*/
void receiveUDP(unsigned int UPDStart,unsigned int UDPLength,unsigned int hisIP0,unsigned int hisIP1,unsigned int myIP0,unsigned int myIP1);//UDPLENGTH is in bytes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -