OSDN Git Service

APIPAの為のAPI追加
[mimic/MiMicSDK.git] / lib / src / uip / NyLPC_cUipService_protected.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 \r
27 #ifndef NyLPC_uipService_H\r
28 #define NyLPC_uipService_H\r
29 #include "NyLPC_cUipService.h"\r
30 #include "../driver/uip/EthDev.h"\r
31 #include "../driver/uip/EthDev_LPC17xx.h"\r
32 \r
33 /**********************************************************************\r
34  *\r
35  * NyLPC_TcUipService_t\r
36  *\r
37  **********************************************************************/\r
38 #ifdef __cplusplus\r
39 extern "C" {\r
40 #endif /* __cplusplus */\r
41 \r
42 #define NyLPC_TcUipService_SIZE_OF_REPLY_BUF 128\r
43 \r
44 \r
45 struct NyLPC_TcUipService\r
46 {\r
47         const NyLPC_TcIPv4Config_t* _ref_config;\r
48         NyLPC_TUInt16   _status;                        /**< ステータスビット*/\r
49         void*                   _task_cmd;                      /**< タスク操作用コマンド*/\r
50         NyLPC_TcSemaphore_t _emac_semapho;      /** EMACの制御用セマフォです。*/\r
51         NyLPC_TcStopwatch_t _arp_sw;            /**<ARP用のストップウォッチ*/\r
52         NyLPC_TcStopwatch_t _periodic_sw;       /**<周期実行用のストップウォッチ*/\r
53         /** ARP処理インスタンス*/\r
54         NyLPC_TcIPv4Arp_t _arp;\r
55         /** TCPv4処理インスタンス*/\r
56         NyLPC_TcIPv4_t _tcpv4;\r
57         /** ICOMP処理インスタンス*/\r
58         NyLPC_TcIPv4IComp_t _icomp;\r
59         /** (Ethernetメモリ排他制御用)*/\r
60         NyLPC_TcMutex_t _mutex;\r
61         const struct TiEthernetDevice* _ethif;\r
62         /** ipタスクが使う小サイズ送信バッファ*/\r
63         struct\r
64         {\r
65                 struct NyLPC_TTxBufferHeader h;\r
66                 NyLPC_TUInt8 buf[NyLPC_TcUipService_SIZE_OF_REPLY_BUF];\r
67         }stx;\r
68 };\r
69 \r
70 \r
71 /** 唯一のサービスインスタンス - Single service instance*/\r
72 extern NyLPC_TcUipService_t* _NyLPC_TcUipService_inst;\r
73 \r
74 /**\r
75  * サービスが初期化済みならtrueです。 - true if service was initialized.\r
76  */\r
77 #define NyLPC_TcUipService_isInitService() (_NyLPC_TcUipService_inst!=NULL)\r
78 /**\r
79  * サービスが稼働中か返します。\r
80  */\r
81 #define NyLPC_cUipService_isRun() NyLPC_TUInt16_isBitOn(_NyLPC_TcUipService_inst->_status,NyLPC_TcUipService_STATUS_RUN)\r
82 \r
83 \r
84 /**********************************************************************\r
85  * コントロールビットの定義\r
86  **********************************************************************/\r
87 //サービスは実行中\r
88 #define NyLPC_TcUipService_STATUS_RUN           0x0001\r
89 //サービスは停止中\r
90 #define NyLPC_TcUipService_STATUS_STOP          0x0002\r
91 \r
92 \r
93 \r
94 #define INST_TYPE_NyLPC_Unknown 0\r
95 #define INST_TYPE_NyLPC_TcTcpListener 1\r
96 #define INST_TYPE_NyLPC_TcTcpSocket 2\r
97 \r
98 \r
99 /**********************************************************************\r
100  * cTcpSocketからコールする関数\r
101  **********************************************************************/\r
102 \r
103 \r
104 \r
105 /**\r
106  * IPv4パケットをネットワークに送信します。\r
107  * この関数は、リエントラントを許容します。\r
108  * @param i_eth_payload\r
109  * NyLPC_cUipService_getTxFrame、または、NyLPC_cUipService_recvIPv4Rxで得たバッファに、\r
110  * IPv4パケットを書きこんだものを指定してください。\r
111  */\r
112 void NyLPC_cUipService_sendIPv4Tx(void* i_eth_payload);\r
113 \r
114 /**\r
115  * 送信ペイロードメモリを返します。\r
116  * この関数は、リエントラントを許容します。\r
117  * @param i_hint\r
118  * 取得したいメモリサイズを指定します。(このサイズは、イーサネットヘッダのサイズを含みません。)\r
119  * このサイズよりも小さなサイズが割り当てられることがあります。\r
120  * @param o_size\r
121  * 取得メモリのイーサネットヘッダを除いたペイロード部分の長さ\r
122  * @return\r
123  * 成功:IPペイロードのためのメモリブロックを返します。/失敗:NULL\r
124  * メモリは、[TEthPacket][payload]の構造で返されます。\r
125  */\r
126 void* NyLPC_cUipService_allocTxBuf(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size);\r
127 \r
128 /**\r
129  * allocTxbufで確保したメモリを開放します。\r
130  */\r
131 void* NyLPC_cUipService_releaseTxBuf(void* i_buf);\r
132 \r
133 /**\r
134  * 指定したIPアドレスを要求するARPリクエストを発行します。\r
135  */\r
136 void NyLPC_cUipService_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr);\r
137 \r
138 /**\r
139  * ARPテーブルに指定したIPがあるかを返します。\r
140  */\r
141 NyLPC_TBool NyLPC_cUipService_hasArpInfo(const struct NyLPC_TIPv4Addr* i_addr);\r
142 \r
143 \r
144 void NyLPC_cTcpSocket_periodic(\r
145         NyLPC_TcTcpSocket_t* i_inst);\r
146 \r
147 \r
148 \r
149 \r
150 #ifdef __cplusplus\r
151 }\r
152 #endif /* __cplusplus */\r
153 \r
154 #endif\r