OSDN Git Service

update libMiMic
[mimic/MiMicSDK.git] / lib / src / netif / NyLPC_cNet.c
1
2 #include "NyLPC_cNet.h"
3 #include "./mimicip/NyLPC_cMiMicIpNetIf_protected.h"
4 #include "dhcp/NyLPC_cDhcpClient.h"
5 #include "apipa/NyLPC_cApipa.h"
6
7
8 /**
9  * 唯一のネットワークインタフェイス
10  */
11 const static struct NyLPC_TiNetInterface_Interface* netif;
12
13
14
15
16
17 void NyLPC_cNet_initialize(const struct NyLPC_TiNetInterface_Interface* i_netif)
18 {
19         NyLPC_Assert(netif==NULL);
20         netif=i_netif;
21 }
22
23 void NyLPC_cNet_start(const NyLPC_TcIPv4Config_t* i_ref_config)
24 {
25         netif->start(i_ref_config);
26     return;
27 }
28
29 void NyLPC_cNet_stop(void)
30 {
31         netif->stop();
32     return;
33 }
34
35
36
37 /**
38  * 指定したIPアドレスを要求するARPリクエストを発行します。
39  */
40 void NyLPC_cNet_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr)
41 {
42         netif->sendarprequest(i_addr);
43 }
44 /**
45  * ARPテーブルに指定したIPがあるかを返します。
46  */
47 NyLPC_TBool NyLPC_cNet_hasArpInfo(const struct NyLPC_TIPv4Addr* i_addr)
48 {
49         return netif->hasarpinfo(i_addr);
50 }
51
52 NyLPC_TBool NyLPC_cNet_isInitService(void)
53 {
54         return netif->isinitservice();
55 }
56
57 NyLPC_TiTcpSocket_t* NyLPC_cNet_createTcpSocketEx(NyLPC_TSocketType i_socktype)
58 {
59         return netif->createTcpSocketEx(i_socktype);
60 }
61 NyLPC_TiUdpSocket_t* NyLPC_cNet_createUdpSocketEx(NyLPC_TUInt16 i_port,NyLPC_TSocketType i_socktype)
62 {
63         return netif->createUdpSocetEx(i_port,i_socktype);
64 }
65 NyLPC_TiTcpListener_t* NyLPC_cNet_createTcpListenerEx(NyLPC_TUInt16 i_port)
66 {
67         return netif->createTcpListener(i_port);
68 }
69
70 const struct NyLPC_TNetInterfaceInfo* NyLPC_cNet_getInterfaceInfo(void)
71 {
72         return netif->getinterfaceinfo();
73 }
74
75
76
77 NyLPC_TBool NyLPC_cNet_requestAddrDhcp(NyLPC_TcIPv4Config_t* i_cfg,NyLPC_TInt16 i_repeat)
78 {
79     NyLPC_TBool ret;
80     NyLPC_TcDhcpClient_t sock;
81     //netを開始
82     NyLPC_cDhcpClient_initialize(&sock);
83     ret=NyLPC_cDhcpClient_requestAddr(&sock,i_cfg,i_repeat);
84     NyLPC_cDhcpClient_finalize(&sock);
85     return ret;
86 }
87
88 NyLPC_TBool NyLPC_cNet_requestAddrApipa(NyLPC_TcIPv4Config_t* i_cfg,NyLPC_TInt16 i_repeat)
89 {
90     NyLPC_TBool ret;
91     NyLPC_TcApipa_t sock;
92     //netを開始
93     NyLPC_cApipa_initialize(&sock);
94     ret=NyLPC_cApipa_requestAddr(&sock,i_cfg,i_repeat);
95     NyLPC_cApipa_finalize(&sock);
96     return ret;
97 }
98
99
100
101