1 /*********************************************************************************
3 * --------------------------------------------------------------------------------
5 * This file is part of MiMic
6 * Copyright (C)2011 Ryo Iizuka
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.
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.
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/>.
21 * For further information please contact.
23 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
25 *********************************************************************************/
28 * このファイルは、NyLPC_cIPv4Configクラスを定義します。
30 #ifndef NYLPC_CIPV4CONFIG_H_
31 #define NYLPC_CIPV4CONFIG_H_
34 #include "NyLPC_NetIf_ip_types.h"
38 * NyLPC_cIPv4Configクラスは、IPと、下位のネットワーク層の設定を保持します。
39 * 関連するオブジェクトが、ネットワーク設定を問い合わせる為に使います。
41 typedef struct NyLPC_TcIPv4Config NyLPC_TcIPv4Config_t;
45 #endif /* __cplusplus */
46 /**********************************************************************
48 * class NyLPC_TcIPv4Config
50 **********************************************************************/
56 * NyLPC_TcIPv4Configクラスの構造体です。
58 struct NyLPC_TcIPv4Config
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;
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))
77 * イーサネット用にコンフィギュレーションを初期化します。
80 * @param i_ether_frame_len
81 * イーサネットフレームのサイズ。この数値から、MSSのデフォルト値を計算します。
83 void NyLPC_cIPv4Config_initialzeForEthernet(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TEthAddr* i_ether_addr,NyLPC_TUInt16 i_ether_frame_len);
88 void NyLPC_cIPv4Config_initialzeCopy(NyLPC_TcIPv4Config_t* i_inst,const NyLPC_TcIPv4Config_t* i_src);
92 * デストラクタです。インスタンスを破棄して、確保している動的リソースを元に戻します。
95 * initializeに成功したインスタンスだけが指定できます。
97 #define NyLPC_cIPv4Config_finalize(i_inst)
100 * この関数は、IPのデフォルトゲートウェイを設定します。dr_addrの値を更新します。
104 * 設定するIPアドレスを格納したアドレスです。
106 void NyLPC_cIPv4Config_setDefaultRoute(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_dr_addr);
109 * この関数は、ローカルIPアドレスとネットマスクを設定します。
113 * 設定するIPアドレスを格納したアドレスです。
115 * 設定するネットマスクを格納したアドレスです。
117 void NyLPC_cIPv4Config_setIp(NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_ipaddr,const struct NyLPC_TIPv4Addr* i_netmask);
120 * この関数は、i_target_ipが、現在のIPアドレスに対するローカルアドレスであるかを返します。
126 * i_target_ipがローカルIPアドレスなら、TRUEを返します。
128 NyLPC_TBool NyLPC_cIPv4Config_isLocalIP(const NyLPC_TcIPv4Config_t* i_inst,const struct NyLPC_TIPv4Addr* i_target_ip);
132 #endif /* __cplusplus */