00001 00002 00003 00029 /********************************************************************* 00030 * Copyright (C) 2002-2008 Microchip Technology Inc. All rights 00031 * reserved. 00032 * 00033 * Microchip licenses to you the right to use, modify, copy, and 00034 * distribute: 00035 * (i) the Software when embedded on a Microchip microcontroller or 00036 * digital signal controller product ("Device") which is 00037 * integrated into Licensee's product; or 00038 * (ii) ONLY the Software driver source files ENC28J60.c and 00039 * ENC28J60.h ported to a non-Microchip device used in 00040 * conjunction with a Microchip ethernet controller for the 00041 * sole purpose of interfacing with the ethernet controller. 00042 * 00043 * You should refer to the license agreement accompanying this 00044 * Software for additional information regarding your rights and 00045 * obligations. 00046 * 00047 * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT 00048 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT 00049 * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A 00050 * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL 00051 * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR 00052 * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF 00053 * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS 00054 * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE 00055 * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER 00056 * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT 00057 * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. 00058 * 00059 * 00060 * Author Date Comment 00061 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00062 * Nilesh Rajbharti 3/19/01 Original (Rev 1.0) 00063 ********************************************************************/ 00064 #ifndef __UDP_H 00065 #define __UDP_H 00066 00067 // Stores a UDP Port Number 00068 typedef WORD UDP_PORT; 00069 00070 // Provides a handle to a UDP Socket 00071 typedef BYTE UDP_SOCKET; 00072 00073 // Stores information about a current UDP socket 00074 typedef struct _UDP_SOCKET_INFO 00075 { 00076 NODE_INFO remoteNode; // IP and MAC of remote node 00077 UDP_PORT remotePort; // Remote node's UDP port number 00078 UDP_PORT localPort; // Local UDP port number, or INVALID_UDP_PORT when free 00079 } UDP_SOCKET_INFO; 00080 00081 00082 #define INVALID_UDP_SOCKET (0xffu) // Indicates a UDP socket that is not valid 00083 #define INVALID_UDP_PORT (0ul) // Indicates a UDP port that is not valid 00084 00085 /**************************************************************************** 00086 Section: 00087 External Global Variables 00088 ***************************************************************************/ 00089 #if !defined(__UDP_C) 00090 extern UDP_SOCKET activeUDPSocket; 00091 extern UDP_SOCKET_INFO UDPSocketInfo[MAX_UDP_SOCKETS]; 00092 extern WORD UDPTxCount; 00093 extern WORD UDPRxCount; 00094 #endif 00095 00096 // Stores the header of a UDP packet 00097 typedef struct _UDP_HEADER 00098 { 00099 UDP_PORT SourcePort; // Source UDP port 00100 UDP_PORT DestinationPort; // Destination UDP port 00101 WORD Length; // Length of data 00102 WORD Checksum; // UDP checksum of the data 00103 } UDP_HEADER; 00104 00105 /**************************************************************************** 00106 Section: 00107 Function Prototypes 00108 ***************************************************************************/ 00109 void UDPInit(void); 00110 void UDPTask(void); 00111 00112 UDP_SOCKET UDPOpen(UDP_PORT localPort, NODE_INFO *remoteNode, UDP_PORT remotePort); 00113 void UDPClose(UDP_SOCKET s); 00114 BOOL UDPProcess(NODE_INFO *remoteNode, IP_ADDR *localIP, WORD len); 00115 00116 void UDPSetTxBuffer(WORD wOffset); 00117 void UDPSetRxBuffer(WORD wOffset); 00118 WORD UDPIsPutReady(UDP_SOCKET s); 00119 BOOL UDPPut(BYTE v); 00120 WORD UDPPutArray(BYTE *cData, WORD wDataLen); 00121 BYTE* UDPPutString(BYTE *strData); 00122 void UDPFlush(void); 00123 00124 // ROM function variants for PIC18 00125 #if defined(__18CXX) 00126 WORD UDPPutROMArray(ROM BYTE *cData, WORD wDataLen); 00127 ROM BYTE* UDPPutROMString(ROM BYTE *strData); 00128 #else 00129 #define UDPPutROMArray(a,b) UDPPutArray((BYTE*)a,b) 00130 #define UDPPutROMString(a) UDPPutString((BYTE*)a) 00131 #endif 00132 00133 WORD UDPIsGetReady(UDP_SOCKET s); 00134 BOOL UDPGet(BYTE *v); 00135 WORD UDPGetArray(BYTE *cData, WORD wDataLen); 00136 void UDPDiscard(void); 00137 00138 // MODIFIX: Added the following function prototypes 00139 WORD UDPGetPutOffset(void); 00140 WORD UDPGetGetOffset(void); 00141 00142 #endif
1.5.5