📄 ip.h
字号:
/*********************************************************************
*
* IP Defs for Microchip TCP/IP Stack
*
*********************************************************************
* FileName: IP.h
* Dependencies: StackTsk.h
* MAC.h
* Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F
* Complier: Microchip C18 v3.02 or higher
* Microchip C30 v2.01 or higher
* Company: Microchip Technology, Inc.
*
* Software License Agreement
*
* This software is owned by Microchip Technology Inc. ("Microchip")
* and is supplied to you for use exclusively as described in the
* associated software agreement. This software is protected by
* software and other intellectual property laws. Any use in
* violation of the software license may subject the user to criminal
* sanctions as well as civil liability. Copyright 2006 Microchip
* Technology Inc. All rights reserved.
*
* This software is provided "AS IS." MICROCHIP DISCLAIMS ALL
* WARRANTIES, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, NOT LIMITED
* TO MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
* INFRINGEMENT. Microchip shall in no event be liable for special,
* incidental, or consequential damages.
*
*
* Author Date Comment
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Nilesh Rajbharti 4/27/01 Original (Rev 1.0)
* Nilesh Rajbharti 2/9/02 Cleanup
* Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail)
********************************************************************/
#ifndef IP_H
#define IP_H
#include "..\Include\StackTsk.h"
#include "..\Include\MAC.h"
#define IP_PROT_ICMP (1)
#define IP_PROT_TCP (6)
#define IP_PROT_UDP (17)
/*
* IP packet header definition
*/
typedef struct _IP_HEADER
{
BYTE VersionIHL;
BYTE TypeOfService;
WORD TotalLength;
WORD Identification;
WORD FragmentInfo;
BYTE TimeToLive;
BYTE Protocol;
WORD HeaderChecksum;
IP_ADDR SourceAddress;
IP_ADDR DestAddress;
} IP_HEADER;
/*********************************************************************
* Function: BOOL IPIsTxReady(BOOL HighPriority)
*
* PreCondition: None
*
* Input: None
*
* Output: TRUE if transmit buffer is empty
* FALSE if transmit buffer is not empty
*
* Side Effects: None
*
* Note: None
*
********************************************************************/
#define IPIsTxReady(HighPriority) MACIsTxReady(HighPriority)
/*********************************************************************
* Macro: IPSetTxBuffer(a, b)
*
* PreCondition: None
*
* Input: a - Buffer identifier
* b - Offset
*
* Output: Next Read/Write access to transmit buffer 'a'
* set to offset 'b'
*
* Side Effects: None
*
* Note: None
*
********************************************************************/
#define IPSetTxBuffer(a, b) MACSetTxBuffer(a, b+sizeof(IP_HEADER))
/*********************************************************************
* Function: WORD IPPutHeader( IP_ADDR *Dest,
* BYTE Protocol,
* WORD Identifier,
* WORD DataLen)
*
* PreCondition: IPIsTxReady() == TRUE
*
* Input: Src - Destination node address
* Protocol - Current packet protocol
* Identifier - Current packet identifier
* DataLen - Current packet data length
*
* Output: Handle to current packet - For use by
* IPSendByte() function.
*
* Side Effects: None
*
* Note: Only one IP message can be transmitted at any
* time.
* Caller may not transmit and receive a message
* at the same time.
*
********************************************************************/
WORD IPPutHeader(NODE_INFO *remote,
BYTE protocol,
WORD len);
/*********************************************************************
* Macro: IPPutArray(a, b)
*
* PreCondition: IPIsTxReady() == TRUE
*
* Input: a - Data buffer
* b - Buffer length
*
* Output: None
*
* Side Effects: None
*
* Note: Data is copied to IP data area.
*
********************************************************************/
#define IPPutArray(a, b) MACPutArray(a, b)
/*********************************************************************
* Function: BOOL IPGetHeader( IP_ADDR *localIP,
* NODE_INFO *remote,
* BYTE *Protocol,
* WORD *len)
*
* PreCondition: MACGetHeader() == TRUE
*
* Input: localIP - Local node IP Address as received
* in current IP header.
* If this information is not required
* caller may pass NULL value.
* remote - Remote node info
* Protocol - Current packet protocol
* len - Current packet data length
*
* Output: TRUE, if valid packet was received
* FALSE otherwise
*
* Side Effects: None
*
* Note: Only one IP message can be received.
* Caller may not transmit and receive a message
* at the same time.
*
********************************************************************/
BOOL IPGetHeader(IP_ADDR *localIP,
NODE_INFO *remote,
BYTE *protocol,
WORD *len);
/*********************************************************************
* Macro: IPDiscard()
*
* PreCondition: MACGetHeader() == TRUE
*
* Input: None
*
* Output: Current packet is discarded and buffer is
* freed-up
*
* Side Effects: None
*
* Note: None
*
********************************************************************/
#define IPDiscard() MACDiscard()
/*********************************************************************
* Macro: IPGetArray(a, b)
*
* PreCondition: MACGetHeader() == TRUE
*
* Input: a - Data buffer
* b - Buffer length
*
* Output: None
*
* Side Effects: None
*
* Note: Data is copied from IP data to given buffer
*
********************************************************************/
#define IPGetArray(a, b) MACGetArray(a, b)
/*********************************************************************
* Function: IPSetRxBuffer(WORD Offset)
*
* PreCondition: IPHeaderLen must have been intialized by
* IPGetHeader() or IPPutHeader()
*
* Input: Offset from beginning of IP data field
*
* Output: Next Read/Write access to receive buffer is
* set to Offset
*
* Side Effects: None
*
* Note: None
*
********************************************************************/
void IPSetRxBuffer(WORD Offset);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -