Jun Furutani / libMiMic

Fork of libMiMic by Ryo Iizuka

Committer:
nyatla
Date:
Thu May 29 14:29:15 2014 +0000
Revision:
69:8c5f220441f5
Parent:
50:35e765380772
r354????; LPC4088?????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 37:fc4b4fd6a649 1 /*********************************************************************************
nyatla 37:fc4b4fd6a649 2 * PROJECT: MiMic
nyatla 37:fc4b4fd6a649 3 * --------------------------------------------------------------------------------
nyatla 37:fc4b4fd6a649 4 *
nyatla 37:fc4b4fd6a649 5 * This file is part of MiMic
nyatla 37:fc4b4fd6a649 6 * Copyright (C)2011 Ryo Iizuka
nyatla 37:fc4b4fd6a649 7 *
nyatla 37:fc4b4fd6a649 8 * MiMic is free software: you can redistribute it and/or modify
nyatla 37:fc4b4fd6a649 9 * it under the terms of the GNU Lesser General Public License as published
nyatla 37:fc4b4fd6a649 10 * by the Free Software Foundation, either version 3 of the License, or
nyatla 37:fc4b4fd6a649 11 * (at your option) any later version.
nyatla 37:fc4b4fd6a649 12 *
nyatla 37:fc4b4fd6a649 13 * This program is distributed in the hope that it will be useful,
nyatla 37:fc4b4fd6a649 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nyatla 37:fc4b4fd6a649 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
nyatla 37:fc4b4fd6a649 16 * GNU General Public License for more details.
nyatla 37:fc4b4fd6a649 17 *
nyatla 37:fc4b4fd6a649 18 * You should have received a copy of the GNU Lesser General Public License
nyatla 37:fc4b4fd6a649 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
nyatla 37:fc4b4fd6a649 20 *
nyatla 37:fc4b4fd6a649 21 * For further information please contact.
nyatla 37:fc4b4fd6a649 22 * http://nyatla.jp/
nyatla 37:fc4b4fd6a649 23 * <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
nyatla 37:fc4b4fd6a649 24 *
nyatla 37:fc4b4fd6a649 25 *********************************************************************************/
nyatla 2:b96c1e90d120 26 #include "NyLPC_cNet.h"
nyatla 37:fc4b4fd6a649 27 #include "dhcp/NyLPC_cDhcpClient.h"
nyatla 50:35e765380772 28 #include "../uip/NyLPC_cUipService_protected.h"
nyatla 37:fc4b4fd6a649 29
nyatla 2:b96c1e90d120 30
nyatla 2:b96c1e90d120 31
nyatla 2:b96c1e90d120 32 void NyLPC_cNet_initialize(NyLPC_TcNet_t* i_inst)
nyatla 2:b96c1e90d120 33 {
nyatla 2:b96c1e90d120 34 //uipサービス初期化。いろいろ利用可能に。
nyatla 50:35e765380772 35 if(!NyLPC_TcUipService_isInitService()){
nyatla 50:35e765380772 36 NyLPC_cUipService_initialize();
nyatla 50:35e765380772 37 }
nyatla 2:b96c1e90d120 38 }
nyatla 2:b96c1e90d120 39
nyatla 2:b96c1e90d120 40 void NyLPC_cNet_start(NyLPC_TcNet_t* i_inst,const NyLPC_TcNetConfig_t* i_ref_config)
nyatla 2:b96c1e90d120 41 {
nyatla 37:fc4b4fd6a649 42 NyLPC_cUipService_start(&(i_ref_config->super));
nyatla 2:b96c1e90d120 43 return;
nyatla 37:fc4b4fd6a649 44 }
nyatla 37:fc4b4fd6a649 45
nyatla 37:fc4b4fd6a649 46 void NyLPC_cNet_stop(NyLPC_TcNet_t* i_inst)
nyatla 37:fc4b4fd6a649 47 {
nyatla 37:fc4b4fd6a649 48 NyLPC_cUipService_stop();
nyatla 69:8c5f220441f5 49 return;
nyatla 37:fc4b4fd6a649 50 }
nyatla 37:fc4b4fd6a649 51
nyatla 37:fc4b4fd6a649 52 /**
nyatla 37:fc4b4fd6a649 53 * NyLPC_TcIPv4Config_tをDHCPで更新します。
nyatla 37:fc4b4fd6a649 54 * この関数をコールする時は、サービスは停止中でなければなりません。
nyatla 37:fc4b4fd6a649 55 * @param i_cfg
nyatla 37:fc4b4fd6a649 56 * 更新するi_cfg構造体。
nyatla 37:fc4b4fd6a649 57 * emac,default_mssは設定済である必要があります。他のフィールド値は不定で構いません。
nyatla 37:fc4b4fd6a649 58 * 更新されるフィールドは、ip,netmast,default_rootの3つです。
nyatla 37:fc4b4fd6a649 59 * @return
nyatla 37:fc4b4fd6a649 60 * 更新に成功した場合TRUE
nyatla 37:fc4b4fd6a649 61 */
nyatla 37:fc4b4fd6a649 62 NyLPC_TBool NyLPC_cNet_requestAddrDhcp(NyLPC_TcNet_t* i_net,NyLPC_TcIPv4Config_t* i_cfg,NyLPC_TInt16 i_repeat)
nyatla 37:fc4b4fd6a649 63 {
nyatla 37:fc4b4fd6a649 64 NyLPC_TBool ret;
nyatla 37:fc4b4fd6a649 65 NyLPC_TcDhcpClient_t sock;
nyatla 37:fc4b4fd6a649 66 //netを開始
nyatla 37:fc4b4fd6a649 67 NyLPC_cDhcpClient_initialize(&sock);
nyatla 37:fc4b4fd6a649 68 ret=NyLPC_cDhcpClient_requestAddr(&sock,i_cfg,i_repeat);
nyatla 37:fc4b4fd6a649 69 NyLPC_cDhcpClient_finalize(&sock);
nyatla 37:fc4b4fd6a649 70 return ret;
nyatla 37:fc4b4fd6a649 71 }
nyatla 37:fc4b4fd6a649 72 /**
nyatla 37:fc4b4fd6a649 73 * NyLPC_TcIPv4Config_tをAPIPAで更新します。
nyatla 37:fc4b4fd6a649 74 * この関数をコールする時は、サービスは停止中でなければなりません。
nyatla 37:fc4b4fd6a649 75 * @param i_cfg
nyatla 37:fc4b4fd6a649 76 * 更新するi_cfg構造体。
nyatla 37:fc4b4fd6a649 77 * emac,default_mssは設定済である必要があります。他のフィールド値は不定で構いません。
nyatla 37:fc4b4fd6a649 78 * 更新されるフィールドは、ip,netmast,default_rootの3つです。
nyatla 37:fc4b4fd6a649 79 * @return
nyatla 37:fc4b4fd6a649 80 * 更新に成功した場合TRUE
nyatla 37:fc4b4fd6a649 81 */
nyatla 37:fc4b4fd6a649 82 NyLPC_TBool NyLPC_cNet_requestAddrApipa(NyLPC_TcNet_t* i_net,NyLPC_TcIPv4Config_t* i_cfg,NyLPC_TInt16 i_repeat)
nyatla 37:fc4b4fd6a649 83 {
nyatla 37:fc4b4fd6a649 84 NyLPC_TBool ret;
nyatla 37:fc4b4fd6a649 85 NyLPC_TcApipa_t sock;
nyatla 37:fc4b4fd6a649 86 //netを開始
nyatla 37:fc4b4fd6a649 87 NyLPC_cApipa_initialize(&sock);
nyatla 37:fc4b4fd6a649 88 ret=NyLPC_cApipa_requestAddr(&sock,i_cfg,i_repeat);
nyatla 37:fc4b4fd6a649 89 NyLPC_cApipa_finalize(&sock);
nyatla 37:fc4b4fd6a649 90 return ret;
nyatla 37:fc4b4fd6a649 91 }