1 | // DSWifi Project - sgIP Internet Protocol Stack Implementation |
---|
2 | // Copyright (C) 2005-2006 Stephen Stair - sgstair@akkit.org - http://www.akkit.org |
---|
3 | /****************************************************************************** |
---|
4 | DSWifi Lib and test materials are licenced under the MIT open source licence: |
---|
5 | Copyright (c) 2005-2006 Stephen Stair |
---|
6 | |
---|
7 | Permission is hereby granted, free of charge, to any person obtaining a copy of |
---|
8 | this software and associated documentation files (the "Software"), to deal in |
---|
9 | the Software without restriction, including without limitation the rights to |
---|
10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
---|
11 | of the Software, and to permit persons to whom the Software is furnished to do |
---|
12 | so, subject to the following conditions: |
---|
13 | |
---|
14 | The above copyright notice and this permission notice shall be included in all |
---|
15 | copies or substantial portions of the Software. |
---|
16 | |
---|
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
---|
23 | SOFTWARE. |
---|
24 | ******************************************************************************/ |
---|
25 | #ifndef SGIP_ARP_H |
---|
26 | #define SGIP_ARP_H |
---|
27 | |
---|
28 | #include "sgIP_Config.h" |
---|
29 | #include "sgIP_memblock.h" |
---|
30 | #include "sgIP_Hub.h" |
---|
31 | |
---|
32 | #define SGIP_ARP_FLAG_ACTIVE 0x0001 |
---|
33 | #define SGIP_ARP_FLAG_HAVEHWADDR 0x0002 |
---|
34 | |
---|
35 | typedef struct SGIP_ARP_RECORD { |
---|
36 | unsigned short flags, retrycount; |
---|
37 | unsigned long idletime; |
---|
38 | sgIP_Hub_HWInterface * linked_interface; |
---|
39 | sgIP_memblock * queued_packet; |
---|
40 | int linked_protocol; |
---|
41 | unsigned long protocol_address; |
---|
42 | char hw_address[SGIP_MAXHWADDRLEN]; |
---|
43 | } sgIP_ARP_Record; |
---|
44 | |
---|
45 | |
---|
46 | typedef struct SGIP_HEADER_ARP { |
---|
47 | unsigned short hwspace; // ethernet=1; |
---|
48 | unsigned short protocol; |
---|
49 | unsigned char hw_addr_len; |
---|
50 | unsigned char protocol_addr_len; |
---|
51 | unsigned short opcode; // request=1, reply=2 |
---|
52 | unsigned char addresses[8+12]; // sender HW, sender Protocol, dest HW, dest Protocol |
---|
53 | } sgIP_Header_ARP; |
---|
54 | |
---|
55 | #define SGIP_HEADER_ARP_BASESIZE 8 |
---|
56 | |
---|
57 | #ifdef __cplusplus |
---|
58 | extern "C" { |
---|
59 | #endif |
---|
60 | |
---|
61 | extern void sgIP_ARP_Init(void); |
---|
62 | extern void sgIP_ARP_Timer100ms(void); |
---|
63 | extern void sgIP_ARP_FlushInterface(sgIP_Hub_HWInterface * hw); |
---|
64 | |
---|
65 | extern int sgIP_ARP_ProcessIPFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb); |
---|
66 | extern int sgIP_ARP_ProcessARPFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb); |
---|
67 | extern int sgIP_ARP_SendProtocolFrame(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb, unsigned short protocol, unsigned long destaddr); |
---|
68 | |
---|
69 | extern int sgIP_ARP_SendARPResponse(sgIP_Hub_HWInterface * hw, sgIP_memblock * mb); |
---|
70 | extern int sgIP_ARP_SendGratARP(sgIP_Hub_HWInterface * hw); |
---|
71 | extern int sgIP_ARP_SendARPRequest(sgIP_Hub_HWInterface * hw, int protocol, unsigned long protocol_addr); |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | #ifdef __cplusplus |
---|
76 | }; |
---|
77 | #endif |
---|
78 | |
---|
79 | |
---|
80 | #endif |
---|