📄 ip.h
字号:
/**
* \addtogroup t4socket T4 Socket API Layer
* @{
*/
/**
* \addtogroup iplayer IP Layer Configuration Function
* @{
*/
/**
* \file ip.h
* \brief IP Layer Function Declaration Header File.
* \author Xiaofei Rui <xfrui@fameg.com>
*/
/*
******************************************************************************
*
Copyright (c) 2006 FameG Shanghai, Inc. All rights reserved.
*
This is unpublished proprietary source code of FameG Shanghai, Inc.
*
The copyright notice above does not evidence any actual or intended
*
publication of such source code.
******************************************************************************
*/
/*
******************************************************************************
*
Project: T4 Hardware TCP/IP
*
Filename: ip.h
*
Date: 28/02/2006
*
Purpose: IP Layer Function Declaration
*
Author: Xiaofei Rui
******************************************************************************
*/
#ifndef __IP_H__
#define __IP_H__
#include "kernel/system.h"
/*****************************************************************************
* CONSTANT DEFINES *
*****************************************************************************/
#define IP_HLEN 20 /**< IP Header length \hideinitializer */
#define IP_OPTLEN 40 /**< IP option length \hideinitializer */
/*****************************************************************************
* MACROS *
*****************************************************************************/
/*****************************************************************************
* DATA TYPES *
*****************************************************************************/
/**
* a union of IP address in two formats.
*/
union ip_addr_u
{
UINT32 bit32; /**< IP address in 32bit format. */
UINT8 bit8[4]; /**< IP address in 4byte format. */
};
/** The IP header structure. */
typedef struct ip_hdr_t{
/* IP header. */
UINT8 vhl, /**< IP version and header length. */
tos, /**< Type of Service. */
len[2], /**< The total length of the packet. */
ipid[2], /**< Identification of a packet. */
ipoffset[2], /**< Flags and fragment offset. */
ttl, /**< Time to Live. */
proto; /**< Protocol of the packet capsulated in IP packet. */
UINT16 ipchksum; /**< Checksum of the IP packet. */
UINT16 srcipaddr[2], /**< Source IP address of a IP packet. */
destipaddr[2]; /**< Destination IP adress of a IP packet. */
}ip_hdr;
/** The UDP header structure. */
typedef struct udp_hdr_t{
/* UDP header. */
UINT16 srcport, /**< Source port of a UDP packet. */
destport, /**< Destination port of a UDP packet. */
len, /**< Total length of a UDP packet. */
chksum; /**< Checksum of a UDP packet. */
} udp_hdr;
/** The TCP header structure. */
typedef struct tcp_hdr_t{
/* TCP header. */
UINT16 srcport, /**< Source port of a UDP packet. */
destport; /**< Destination port of a UDP packet. */
UINT32 seq, /**< Sequence number */
ack; /**< Acknowledgment Number */
UINT16 offset, /**< TCP data offset. */
win, /**< TCP window size. */
chksum, /**< TCP checksum */
urgptr; /**< TCP urgent pointer.*/
} tcp_hdr;
/*****************************************************************************
* FUNCTIONS DECLARATION *
*****************************************************************************/
extern INT8 ip_SetSrcIP(UINT32 ipaddr);
extern UINT32 ip_GetSrcIP(void);
extern void ip_SetGW(UINT32 gwaddr);
extern UINT32 ip_GetGW(void);
extern void ip_SetNetMask(UINT32 mask);
extern UINT32 ip_GetNetMask(void);
extern void ip_GWCtrl(BOOL clr, UINT8 timeoutval);
//extern void ip_ChksumCtrl(BOOL ipchkgen, BOOL udpchkgen);
extern UINT16 ip_chksum(UINT16 *sdata, UINT16 len);
#if IP_REASSEMBLY
//extern UINT16 ip_reass(void);
extern UINT16 ip_reass(UINT8 *rx_buf);
#endif /* IP_REASSEMBLY */
/*****************************************************************************
* GLOBAL VARIABLES DECLARATION *
*****************************************************************************/
#if IP_REASSEMBLY
extern UINT8 ip_reassbuf[IP_REASS_BUFSIZE];
extern UINT8 ip_reasstmr;
#endif /* IP_REASSEMBLY */
#endif /* __IP_H__ */
/** @} */
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -