OSDN Git Service

aaa85fe6b8d442c07e939de7c07a139bb984de13
[mimic/MiMicSDK.git] / lib / src / uip / NyLPC_cIPv4Arp.h
1 /*********************************************************************************\r
2  * PROJECT: MiMic\r
3  * --------------------------------------------------------------------------------\r
4  *\r
5  * This file is part of MiMic\r
6  * Copyright (C)2011 Ryo Iizuka\r
7  *\r
8  * MiMic is free software: you can redistribute it and/or modify\r
9  * it under the terms of the GNU Lesser General Public License as published\r
10  * by the Free Software Foundation, either version 3 of the License, or\r
11  * (at your option) any later version.\r
12  *\r
13  * This program is distributed in the hope that it will be useful,\r
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
16  * GNU General Public License for more details.\r
17  *\r
18  * You should have received a copy of the GNU Lesser General Public License\r
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
20  *\r
21  * For further information please contact.\r
22  *      http://nyatla.jp/\r
23  *      <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>\r
24  *\r
25  *\r
26  * Parts of this file were leveraged from uIP:\r
27  *\r
28  * Copyright (c) 2001-2003, Adam Dunkels.\r
29  * All rights reserved.\r
30  *\r
31  * Redistribution and use in source and binary forms, with or without\r
32  * modification, are permitted provided that the following conditions\r
33  * are met:\r
34  * 1. Redistributions of source code must retain the above copyright\r
35  *    notice, this list of conditions and the following disclaimer.\r
36  * 2. Redistributions in binary form must reproduce the above copyright\r
37  *    notice, this list of conditions and the following disclaimer in the\r
38  *    documentation and/or other materials provided with the distribution.\r
39  * 3. The name of the author may not be used to endorse or promote\r
40  *    products derived from this software without specific prior\r
41  *    written permission.\r
42  *\r
43  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\r
44  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
45  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
46  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY\r
47  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
48  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE\r
49  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
50  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
51  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
52  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
53  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
54  */\r
55 #ifndef NYLPC_CIPV4ARP_H_\r
56 #define NYLPC_CIPV4ARP_H_\r
57 #include "NyLPC_cIPv4Config.h"\r
58 \r
59 #ifdef __cplusplus\r
60 extern "C" {\r
61 #endif /* __cplusplus */\r
62 \r
63 \r
64 struct NyLPC_TArpTableItem\r
65 {\r
66         struct NyLPC_TIPv4Addr ipaddr;\r
67         struct NyLPC_TEthAddr ethaddr;\r
68         NyLPC_TUInt8 time;\r
69 };\r
70 \r
71 /**********************************************************************\r
72  *\r
73  * class NyLPC_TcIPv4Config\r
74  *\r
75  **********************************************************************/\r
76 \r
77 \r
78 #define NyLPC_TcIPv4Arp_ARPTAB_SIZE 8\r
79 \r
80 \r
81 typedef struct NyLPC_TcIPv4Arp NyLPC_TcIPv4Arp_t;\r
82 \r
83 /**\r
84  * NyLPC_TcIPv4クラスの構造体です。\r
85  */\r
86 struct NyLPC_TcIPv4Arp\r
87 {\r
88         const NyLPC_TcIPv4Config_t* _cfg;\r
89         NyLPC_TUInt8 arptime;\r
90         NyLPC_TUInt8 tmpage;\r
91         struct NyLPC_TArpTableItem arp_table[NyLPC_TcIPv4Arp_ARPTAB_SIZE];\r
92 };\r
93 \r
94 void NyLPC_cIPv4Arp_initialize(NyLPC_TcIPv4Arp_t* i_inst,const NyLPC_TcIPv4Config_t* i_ref_config);\r
95 #define NyLPC_cIPv4Arp_finalize(i_inst)\r
96 void NyLPC_cIPv4Arp_periodic(NyLPC_TcIPv4Arp_t* i_inst);\r
97 void NyLPC_cIPv4Arp_incomingIp(NyLPC_TcIPv4Arp_t* i_inst,const struct NyLPC_TEthernetIIHeader* i_eth,struct NyLPC_TIPv4Addr i_ip_src);\r
98 /**\r
99  * ARPメッセージを処理します。\r
100  * @param o_tx_len\r
101  * 戻り値がある場合そのサイズ\r
102  * @return\r
103  * 応答パケットを格納したcUipService_allocBufで確保したメモリ\r
104  */\r
105 void* NyLPC_cIPv4Arp_rx(NyLPC_TcIPv4Arp_t* i_inst,const struct NyLPC_TArpHeader* i_arp, NyLPC_TUInt16 i_len, NyLPC_TUInt16* o_tx_len);\r
106 const struct NyLPC_TEthAddr* NyLPC_cIPv4Arp_IPv4toEthAddr(NyLPC_TcIPv4Arp_t* i_inst,const struct NyLPC_TIPv4Addr i_ip_addr);\r
107 \r
108 \r
109 #ifdef __cplusplus\r
110 }\r
111 #endif /* __cplusplus */\r
112 \r
113 \r
114 \r
115 #endif /* NYLPC_CIPV4ARP_H_ */\r