OSDN Git Service

add mbed.html
[mimic/MiMicSDK.git] / lib / src / netif / NyLPC_cIPv4Config.h
1 /*********************************************************************************
2  * PROJECT: MiMic
3  * --------------------------------------------------------------------------------
4  *
5  * This file is part of MiMic
6  * Copyright (C)2011 Ryo Iizuka
7  *
8  * MiMic is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published
10  * by the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  * For further information please contact.
22  *  http://nyatla.jp/
23  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
24  *
25  *********************************************************************************/
26 /**
27  * @file
28  * このファイルは、NyLPC_cIPv4Configクラスを定義します。
29  */
30 #ifndef NYLPC_CIPV4CONFIG_H_
31 #define NYLPC_CIPV4CONFIG_H_
32
33
34 #include "NyLPC_NetIf_ip_types.h"
35
36 /**
37  * クラス型を定義します。
38  * NyLPC_cIPv4Configクラスは、IPと、下位のネットワーク層の設定を保持します。
39  * 関連するオブジェクトが、ネットワーク設定を問い合わせる為に使います。
40  */
41 typedef struct NyLPC_TcIPv4Config NyLPC_TcIPv4Config_t;
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif /* __cplusplus */
46 /**********************************************************************
47  *
48  * class NyLPC_TcIPv4Config
49  *
50  **********************************************************************/
51
52
53
54
55 /**
56  * NyLPC_TcIPv4Configクラスの構造体です。
57  */
58 struct NyLPC_TcIPv4Config
59 {
60     /** イーサネットアドレスを格納します。 */
61     struct NyLPC_TEthAddr eth_mac;
62     /** IPアドレスを格納します。Network orderです。 */
63     struct NyLPC_TIPv4Addr ip_addr;
64     /** ネットマスクを格納します。Network orderです。 */
65     struct NyLPC_TIPv4Addr netmask;
66     /** デフォルトゲートウェイアドレスを格納します。Network orderです。 */
67     struct NyLPC_TIPv4Addr dr_addr;
68     /** デフォルトMMSサイズです。送信パケットのMSS値、受信パケットのデフォルトMSS値として使います。 */
69     NyLPC_TUInt16 default_mss;
70 };
71
72 #define NyLPC_TcIPv4Config_getEtherMac000120203(v)(((v)->eth_mac.addr[0]<<24)|((v)->eth_mac.addr[1]<<16)|((v)->eth_mac.addr[2]<<8)|((v)->eth_mac.addr[3]<<0))
73 #define NyLPC_TcIPv4Config_getEtherMac0405xxxx(v) (((v)->eth_mac.addr[4]<<24)|((v)->eth_mac.addr[5]<<16))
74
75 /**
76  * コンストラクタです。
77  * イーサネット用にコンフィギュレーションを初期化します。
78  * @param i_inst
79  * 初期化するインスタンスです。
80  * @param i_ether_frame_len
81  * イーサネットフレームのサイズ。この数値から、MSSのデフォルト値を計算します。
82  */
83 void NyLPC_cIPv4Config_initialzeForEthernet(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TEthAddr* i_ether_addr,NyLPC_TUInt16 i_ether_frame_len);
84
85 /**
86  * コピーコンストラクタ
87  */
88 void NyLPC_cIPv4Config_initialzeCopy(NyLPC_TcIPv4Config_t* i_inst,const NyLPC_TcIPv4Config_t* i_src);
89
90
91 /**
92  * デストラクタです。インスタンスを破棄して、確保している動的リソースを元に戻します。
93  * @param i_inst
94  * 破棄するインスタンスです。
95  * initializeに成功したインスタンスだけが指定できます。
96  */
97 #define NyLPC_cIPv4Config_finalize(i_inst)
98
99 /**
100  * この関数は、IPのデフォルトゲートウェイを設定します。dr_addrの値を更新します。
101  * @param i_inst
102  * 操作するインスタンスです。
103  * @param i_dr_addr
104  * 設定するIPアドレスを格納したアドレスです。
105  */
106 void NyLPC_cIPv4Config_setDefaultRoute(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_dr_addr);
107
108 /**
109  * この関数は、ローカルIPアドレスとネットマスクを設定します。
110  * @param i_inst
111  * 操作するインスタンスです。
112  * @param i_ipaddr
113  * 設定するIPアドレスを格納したアドレスです。
114  * @param i_netmask
115  * 設定するネットマスクを格納したアドレスです。
116  */
117 void NyLPC_cIPv4Config_setIp(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_ipaddr,const struct NyLPC_TIPv4Addr* i_netmask);
118
119 /**
120  * この関数は、i_target_ipが、現在のIPアドレスに対するローカルアドレスであるかを返します。
121  * @param i_inst
122  * 操作するインスタンスです。
123  * @param i_target_ip
124  * 確認するIPアドレスです。
125  * @return
126  * i_target_ipがローカルIPアドレスなら、TRUEを返します。
127  */
128 NyLPC_TBool NyLPC_cIPv4Config_isLocalIP(const NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_target_ip);
129
130 #ifdef __cplusplus
131 }
132 #endif /* __cplusplus */
133
134 #endif
135