Line No. | Rev | Author | Line |
---|---|---|---|
1 | 32 | kaklik | /********************************************************************* |
2 | * |
||
3 | * UDP Module Defs for Microchip TCP/IP Stack |
||
4 | * |
||
5 | ********************************************************************* |
||
6 | * FileName: UDP.h |
||
7 | * Dependencies: StackTsk.h |
||
8 | * MAC.h |
||
9 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
10 | * Compiler: Microchip C32 v1.05 or higher |
||
11 | * Microchip C30 v3.12 or higher |
||
12 | * Microchip C18 v3.30 or higher |
||
13 | * HI-TECH PICC-18 PRO 9.63PL2 or higher |
||
14 | * Company: Microchip Technology, Inc. |
||
15 | * |
||
16 | * Software License Agreement |
||
17 | * |
||
18 | * Copyright (C) 2002-2009 Microchip Technology Inc. All rights |
||
19 | * reserved. |
||
20 | * |
||
21 | * Microchip licenses to you the right to use, modify, copy, and |
||
22 | * distribute: |
||
23 | * (i) the Software when embedded on a Microchip microcontroller or |
||
24 | * digital signal controller product ("Device") which is |
||
25 | * integrated into Licensee's product; or |
||
26 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
27 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
28 | * used in conjunction with a Microchip ethernet controller for |
||
29 | * the sole purpose of interfacing with the ethernet controller. |
||
30 | * |
||
31 | * You should refer to the license agreement accompanying this |
||
32 | * Software for additional information regarding your rights and |
||
33 | * obligations. |
||
34 | * |
||
35 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
36 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
37 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
38 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
39 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
40 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
41 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
42 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
43 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
44 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
45 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
46 | * |
||
47 | * |
||
48 | * Author Date Comment |
||
49 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
50 | * Nilesh Rajbharti 3/19/01 Original (Rev 1.0) |
||
51 | ********************************************************************/ |
||
52 | #ifndef __UDP_H |
||
53 | #define __UDP_H |
||
54 | |||
55 | // Stores a UDP Port Number |
||
56 | typedef WORD UDP_PORT; |
||
57 | |||
58 | // Provides a handle to a UDP Socket |
||
59 | typedef BYTE UDP_SOCKET; |
||
60 | |||
61 | // Stores information about a current UDP socket |
||
62 | typedef struct |
||
63 | { |
||
64 | NODE_INFO remoteNode; // IP and MAC of remote node |
||
65 | UDP_PORT remotePort; // Remote node's UDP port number |
||
66 | UDP_PORT localPort; // Local UDP port number, or INVALID_UDP_PORT when free |
||
67 | } UDP_SOCKET_INFO; |
||
68 | |||
69 | |||
70 | #define INVALID_UDP_SOCKET (0xffu) // Indicates a UDP socket that is not valid |
||
71 | #define INVALID_UDP_PORT (0ul) // Indicates a UDP port that is not valid |
||
72 | |||
73 | /**************************************************************************** |
||
74 | Section: |
||
75 | External Global Variables |
||
76 | ***************************************************************************/ |
||
77 | #if !defined(__UDP_C) |
||
78 | extern UDP_SOCKET activeUDPSocket; |
||
79 | extern UDP_SOCKET_INFO UDPSocketInfo[MAX_UDP_SOCKETS]; |
||
80 | extern WORD UDPTxCount; |
||
81 | extern WORD UDPRxCount; |
||
82 | #endif |
||
83 | |||
84 | // Stores the header of a UDP packet |
||
85 | typedef struct |
||
86 | { |
||
87 | UDP_PORT SourcePort; // Source UDP port |
||
88 | UDP_PORT DestinationPort; // Destination UDP port |
||
89 | WORD Length; // Length of data |
||
90 | WORD Checksum; // UDP checksum of the data |
||
91 | } UDP_HEADER; |
||
92 | |||
93 | /**************************************************************************** |
||
94 | Section: |
||
95 | Function Prototypes |
||
96 | ***************************************************************************/ |
||
97 | void UDPInit(void); |
||
98 | void UDPTask(void); |
||
99 | |||
100 | UDP_SOCKET UDPOpen(UDP_PORT localPort, NODE_INFO *remoteNode, UDP_PORT remotePort); |
||
101 | void UDPClose(UDP_SOCKET s); |
||
102 | BOOL UDPProcess(NODE_INFO *remoteNode, IP_ADDR *localIP, WORD len); |
||
103 | |||
104 | void UDPSetTxBuffer(WORD wOffset); |
||
105 | void UDPSetRxBuffer(WORD wOffset); |
||
106 | WORD UDPIsPutReady(UDP_SOCKET s); |
||
107 | BOOL UDPPut(BYTE v); |
||
108 | WORD UDPPutArray(BYTE *cData, WORD wDataLen); |
||
109 | BYTE* UDPPutString(BYTE *strData); |
||
110 | void UDPFlush(void); |
||
111 | |||
112 | // ROM function variants for PIC18 |
||
113 | #if defined(__18CXX) |
||
114 | WORD UDPPutROMArray(ROM BYTE *cData, WORD wDataLen); |
||
115 | ROM BYTE* UDPPutROMString(ROM BYTE *strData); |
||
116 | #else |
||
117 | #define UDPPutROMArray(a,b) UDPPutArray((BYTE*)a,b) |
||
118 | #define UDPPutROMString(a) UDPPutString((BYTE*)a) |
||
119 | #endif |
||
120 | |||
121 | WORD UDPIsGetReady(UDP_SOCKET s); |
||
122 | BOOL UDPGet(BYTE *v); |
||
123 | WORD UDPGetArray(BYTE *cData, WORD wDataLen); |
||
124 | void UDPDiscard(void); |
||
125 | |||
126 | #endif |
Powered by WebSVN v2.8.3