1 /*********************************************************************************
\r
3 * --------------------------------------------------------------------------------
\r
5 * This file is part of MiMic
\r
6 * Copyright (C)2011 Ryo Iizuka
\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
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
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
21 * For further information please contact.
\r
23 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
\r
25 *********************************************************************************/
\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
33 /**********************************************************************
\r
35 * NyLPC_TcUipService_t
\r
37 **********************************************************************/
\r
40 #endif /* __cplusplus */
\r
42 #define NyLPC_TcUipService_SIZE_OF_REPLY_BUF 128
\r
45 struct NyLPC_TcUipService
\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
54 NyLPC_TcIPv4Arp_t _arp;
\r
56 NyLPC_TcIPv4_t _tcpv4;
\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
65 struct NyLPC_TTxBufferHeader h;
\r
66 NyLPC_TUInt8 buf[NyLPC_TcUipService_SIZE_OF_REPLY_BUF];
\r
71 /** 唯一のサービスインスタンス - Single service instance*/
\r
72 extern NyLPC_TcUipService_t* _NyLPC_TcUipService_inst;
\r
75 * サービスが初期化済みならtrueです。 - true if service was initialized.
\r
77 #define NyLPC_TcUipService_isInitService() (_NyLPC_TcUipService_inst!=NULL)
\r
81 #define NyLPC_cUipService_isRun() NyLPC_TUInt16_isBitOn(_NyLPC_TcUipService_inst->_status,NyLPC_TcUipService_STATUS_RUN)
\r
84 /**********************************************************************
\r
86 **********************************************************************/
\r
88 #define NyLPC_TcUipService_STATUS_RUN 0x0001
\r
90 #define NyLPC_TcUipService_STATUS_STOP 0x0002
\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
99 /**********************************************************************
\r
100 * cTcpSocketからコールする関数
\r
101 **********************************************************************/
\r
106 * IPv4パケットをネットワークに送信します。
\r
107 * この関数は、リエントラントを許容します。
\r
108 * @param i_eth_payload
\r
109 * NyLPC_cUipService_getTxFrame、または、NyLPC_cUipService_recvIPv4Rxで得たバッファに、
\r
110 * IPv4パケットを書きこんだものを指定してください。
\r
112 void NyLPC_cUipService_sendIPv4Tx(void* i_eth_payload);
\r
116 * この関数は、リエントラントを許容します。
\r
118 * 取得したいメモリサイズを指定します。(このサイズは、イーサネットヘッダのサイズを含みません。)
\r
119 * このサイズよりも小さなサイズが割り当てられることがあります。
\r
121 * 取得メモリのイーサネットヘッダを除いたペイロード部分の長さ
\r
123 * 成功:IPペイロードのためのメモリブロックを返します。/失敗:NULL
\r
124 * メモリは、[TEthPacket][payload]の構造で返されます。
\r
126 void* NyLPC_cUipService_allocTxBuf(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size);
\r
129 * allocTxbufで確保したメモリを開放します。
\r
131 void* NyLPC_cUipService_releaseTxBuf(void* i_buf);
\r
134 * 指定したIPアドレスを要求するARPリクエストを発行します。
\r
136 void NyLPC_cUipService_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr);
\r
139 * ARPテーブルに指定したIPがあるかを返します。
\r
141 NyLPC_TBool NyLPC_cUipService_hasArpInfo(const struct NyLPC_TIPv4Addr* i_addr);
\r
144 void NyLPC_cTcpSocket_periodic(
\r
145 NyLPC_TcTcpSocket_t* i_inst);
\r
152 #endif /* __cplusplus */
\r