Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
Revision 56:d38b6ce8c63b, committed 2013-08-10
- Comitter:
- nyatla
- Date:
- Sat Aug 10 02:52:22 2013 +0000
- Parent:
- 55:5f993fccc09c
- Child:
- 57:bc4330dfa62f
- Commit message:
- sync MiMic core library r306; fix DHCP problem;
Changed in this revision
--- a/core/NyLPC_cMiMicEnv.h Fri Aug 09 08:37:59 2013 +0000 +++ b/core/NyLPC_cMiMicEnv.h Sat Aug 10 02:52:22 2013 +0000 @@ -13,7 +13,7 @@ #endif /* __cplusplus */ -#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.51" +#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.52" #ifdef __cplusplus
--- a/core/net/dhcp/NyLPC_cDhcpClient.c Fri Aug 09 08:37:59 2013 +0000
+++ b/core/net/dhcp/NyLPC_cDhcpClient.c Sat Aug 10 02:52:22 2013 +0000
@@ -93,15 +93,17 @@
}
return NyLPC_TBool_FALSE;
}
-static NyLPC_TBool NyLPC_TDhcpHeader_parseDHCPOFFER(const NyLPC_TUInt8* i_buf,NyLPC_TUInt16 i_len,NyLPC_TUInt32 i_xid,NyLPC_TcIPv4Config_t* result)
+static NyLPC_TBool NyLPC_TDhcpHeader_parseDHCPOFFER(const NyLPC_TUInt8* i_buf,NyLPC_TUInt16 i_len,NyLPC_TUInt32 i_xid,NyLPC_TcDhcpClient_t* i_inst)
{
struct NyLPC_TDhcpHeader* p=(struct NyLPC_TDhcpHeader*)i_buf;
//XIDのチェック
if(p->xid!=NyLPC_HTONL(i_xid)){
return NyLPC_TBool_FALSE;
}
- //サーバ情報をIPへ保存
- if(!getUInt32Option(i_buf,i_len,DHCP_OPT_ID_SERVER_ID,&result->ip_addr.v)){
+ //OFFERのclient IPアドレスをresultへ保存情報の保存
+ i_inst->_result->ip_addr.v=p->yiaddr;
+ //SERVER IDを保存
+ if(!getUInt32Option(i_buf,i_len,DHCP_OPT_ID_SERVER_ID,&i_inst->_offerserver.v)){
return NyLPC_TBool_FALSE;
}
return NyLPC_TBool_TRUE;
@@ -133,19 +135,20 @@
p->hlen=6;
p->xid=NyLPC_HTONL(i_xid);
p->chaddr.emac=*emac;
+ p->flags=NyLPC_HTONS(0x8000);
memcpy(i_buf+sizeof(struct NyLPC_TDhcpHeader),
"\x63\x82\x53\x63" //4
"\x35\x01\x01" //3 MESSAGE TYPE
"\x37\x03\x01\x03\x06" //5 REQUEST LIST(1,3,6)
- "\x3d\x07\x00\x00\x00\x00\x00\x00\x10" //9 CLIENT INDIFIRE
+ "\x3d\x07\x01\x00\x00\x00\x00\x00\x00" //9 CLIENT INDIFIRE
"\xff",4+3+5+9+1);
//emacの上書き
- memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+2),emac->addr,6);
+ memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+3),emac->addr,6);
//送信するパケットの長さ
*o_len=sizeof(struct NyLPC_TDhcpHeader)+4+3+5+9+1;
return;
}
-static void NyLPC_TDhcpHeader_setDHCPREQUEST(char* i_buf,NyLPC_TUInt32 i_xid,const struct NyLPC_TIPv4Addr* i_sid,const struct NyLPC_TEthAddr* emac,NyLPC_TUInt16* o_len)
+static void NyLPC_TDhcpHeader_setDHCPREQUEST(char* i_buf,NyLPC_TUInt32 i_xid,const struct NyLPC_TIPv4Addr* i_sid,const struct NyLPC_TIPv4Addr* i_reqid,const struct NyLPC_TEthAddr* emac,NyLPC_TUInt16* o_len)
{
struct NyLPC_TDhcpHeader* p=(struct NyLPC_TDhcpHeader*)i_buf;
memset(i_buf,0,sizeof(struct NyLPC_TDhcpHeader));
@@ -154,19 +157,23 @@
p->hlen=6;
p->xid=NyLPC_HTONL(i_xid);
p->chaddr.emac=*emac;
+ p->flags=NyLPC_HTONS(0x8000);
memcpy(i_buf+sizeof(struct NyLPC_TDhcpHeader),
"\x63\x82\x53\x63" //4
"\x35\x01\x03" //3 MESSAGE TYPE
"\x37\x03\x01\x03\x06" //5 REQUEST LIST(1,3,6)
- "\x3d\x07\x00\x00\x00\x00\x00\x00\x10" //9 CLIENT INDIFIRE
+ "\x3d\x07\x01\x00\x00\x00\x00\x00\x00" //9 CLIENT INDIFIRE
"\x36\x04\x00\x00\x00\x00" // 6 SERVER ID
- "\xff",4+3+5+9+6+1);
+ "\x32\x04\x00\x00\x00\x00" // 6 Reqested IP
+ "\xff",4+3+5+9+6+6+1);
//emacの上書き
- memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+2),emac->addr,6);
+ memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+3),emac->addr,6);
//sidの上書き
memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+9+2),i_sid,4);
+ //reqidの上書き
+ memcpy((i_buf+sizeof(struct NyLPC_TDhcpHeader)+4+3+5+9+6+2),i_reqid,4);
//送信するパケットの長さ
- *o_len=sizeof(struct NyLPC_TDhcpHeader)+4+3+5+9+6+1;
+ *o_len=sizeof(struct NyLPC_TDhcpHeader)+4+3+5+9+6+6+1;
return;
}
@@ -244,7 +251,7 @@
if(buf==NULL || s<hint){
return NyLPC_TBool_FALSE;
}
- NyLPC_TDhcpHeader_setDHCPREQUEST(buf,i_sock->txid,&(i_sock->_result->ip_addr),&i_sock->_result->eth_mac,&s);
+ NyLPC_TDhcpHeader_setDHCPREQUEST(buf,i_sock->txid,&(i_sock->_offerserver),&(i_sock->_result->ip_addr),&i_sock->_result->eth_mac,&s);
i_sock->_status=TcDhcpSock_ST_WAIT_ACK;
if(!NyLPC_cUdpSocket_psend(&i_sock->super,&NyLPC_TIPv4Addr_BROADCAST,67,buf,s)){
NyLPC_cUdpSocket_releaseSendBuf(&i_sock->super,buf);
@@ -333,7 +340,7 @@
if(mt!=DHCP_OPT_ID_MESSAGETYPE_OFFER){
return NyLPC_TBool_FALSE;
}
- if(!NyLPC_TDhcpHeader_parseDHCPOFFER(i_buf,i_info->size,inst->txid,inst->_result)){
+ if(!NyLPC_TDhcpHeader_parseDHCPOFFER(i_buf,i_info->size,inst->txid,inst)){
return NyLPC_TBool_FALSE;
}
inst->_status=TcDhcpSock_ST_WAIT_OFFER_OK;
--- a/core/net/dhcp/NyLPC_cDhcpClient.h Fri Aug 09 08:37:59 2013 +0000
+++ b/core/net/dhcp/NyLPC_cDhcpClient.h Sat Aug 10 02:52:22 2013 +0000
@@ -39,6 +39,8 @@
NyLPC_TcIPv4Config_t* _result;
NyLPC_TUInt32 txid;
volatile NyLPC_TUInt16 _status;
+ //offer情報
+ struct NyLPC_TIPv4Addr _offerserver;
};
MiMic Webservice library