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
Diff: core/uip/NyLPC_cUipService.c
- Revision:
- 57:bc4330dfa62f
- Parent:
- 50:35e765380772
- Child:
- 68:f7def7eb5504
--- a/core/uip/NyLPC_cUipService.c Sat Aug 10 02:52:22 2013 +0000
+++ b/core/uip/NyLPC_cUipService.c Fri Sep 13 06:38:16 2013 +0000
@@ -95,7 +95,7 @@
struct NyLPC_TArpHeader arp;
struct NyLPC_TIPv4Header ipv4;
}data;
-};
+}PACK_STRUCT_END;
@@ -122,7 +122,7 @@
static NyLPC_TBool sendIPv4Tx(struct NyLPC_TTxBufferHeader* i_eth_buf);
static void copyAndSendIPv4Tx(const struct TEthPacket* i_buf);
-static void sendArpReqest(const struct TEthPacket* i_eth_packet);
+//static void sendArpReqest(const struct TEthPacket* i_eth_packet);
static void sendRawEthFrame(void* i_buf,NyLPC_TUInt16 i_len);
static void emacIsrHandler(unsigned long i_status);
@@ -136,7 +136,6 @@
NyLPC_TcThread_t th;
-void led(int i);
NyLPC_TBool NyLPC_cUipService_initialize(void)
{
NyLPC_TcUipService_t* inst=&_service_instance;
@@ -396,31 +395,10 @@
}
-
-
/**
- * allocTxBufで取得したメモリを"IPパケットとして"送信します。
- * @param i_eth_payload
- * [NyLPC_TTxBufferHeader][NyLPC_TEthernetIIHeader][payload]メモリの、[payload]のアドレスを指定します。
- * 通常は、NyLPC_cUipService_allocTxBufの返却したメモリを指定します。
+ * IPv4パケットのpeerIPを問い合わせるARPパケットを送信します。
*/
-
-void NyLPC_cUipService_sendIPv4Tx(void* i_eth_payload)
-{
- NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
- NyLPC_cMutex_lock(&(inst->_mutex));
- //IPパケットの送信を試行
- if(!sendIPv4Tx(((struct NyLPC_TTxBufferHeader*)(((struct NyLPC_TEthernetIIHeader*)i_eth_payload)-1))-1)){
- //ARPリクエストを代わりに送信
- sendArpReqest(((struct TEthPacket*)i_eth_payload)-1);
- }
- NyLPC_cMutex_unlock(&(inst->_mutex));
- return;
-}
-/**
- * 指定したIPアドレスに対してARPRequestを送信します。
- */
-void NyLPC_cUipService_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr)
+static void sendArpReqest(const struct NyLPC_TIPv4Addr* i_addr)
{
NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
NyLPC_TUInt16 tx_len;
@@ -431,10 +409,48 @@
}
//ARPパケットを作る。
ethbuf=(struct TEthPacket*)(inst->stx.buf);
- NyLPC_TArpHeader_setArpRequest(&(ethbuf->data.arp),inst->_ref_config->ip_addr,&(inst->_ref_config->eth_mac),*i_addr);
+ NyLPC_TArpHeader_setArpRequest(&(ethbuf->data.arp),inst->_ref_config->ip_addr,&(inst->_ref_config->eth_mac),i_addr);
tx_len=NyLPC_TEthernetIIHeader_setArpTx(&(ethbuf->header),&(inst->_ref_config->eth_mac));
//送信
inst->_ethif->sendTxEthFrame(&(inst->stx.h),tx_len);
+}
+
+
+
+
+/**
+ * allocTxBufで取得したペイロードメモリを"IPパケットとして"送信します。
+ * @param i_eth_payload
+ * [NyLPC_TTxBufferHeader][NyLPC_TEthernetIIHeader][payload]メモリの、[payload]のアドレスを指定します。
+ * 通常は、NyLPC_cUipService_allocTxBufの返却したメモリを指定します。
+ */
+
+void NyLPC_cUipService_sendIPv4Tx(void* i_eth_payload)
+{
+ NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
+ struct NyLPC_TTxBufferHeader* p=((struct NyLPC_TTxBufferHeader*)(((struct NyLPC_TEthernetIIHeader*)i_eth_payload)-1))-1;
+ NyLPC_cMutex_lock(&(inst->_mutex));
+
+ //IPパケットの送信を試行
+ if(!sendIPv4Tx(p)){
+ //ARPリクエストを代わりに送信
+ sendArpReqest(&((struct NyLPC_TIPv4Header*)i_eth_payload)->destipaddr);
+ }
+ NyLPC_cMutex_unlock(&(inst->_mutex));
+ return;
+}
+
+
+
+/**
+ * 指定したIPアドレスに対してARPRequestを送信します。
+ */
+void NyLPC_cUipService_sendArpRequest(const struct NyLPC_TIPv4Addr* i_addr)
+{
+ NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
+ NyLPC_cMutex_lock(&(inst->_mutex));
+ sendArpReqest(i_addr);
+ NyLPC_cMutex_unlock(&(inst->_mutex));
return;
}
@@ -448,6 +464,8 @@
}
+
+
/**
* 送信ペイロードメモリを返します。
* この関数は、リエントラントを許容します。
@@ -501,7 +519,7 @@
*/
/**
- * 新たにメモリを確保して、"IPv4パケットを格納した"イーサフレームを送信します。
+ * "IPv4パケットを格納した"イーサフレームを送信します。
* コール前に、必ずロックしてから呼び出してください。
*/
static void copyAndSendIPv4Tx(const struct TEthPacket* i_buf)
@@ -517,29 +535,13 @@
memcpy(inst->stx.buf,i_buf,s);
if(!sendIPv4Tx(&(inst->stx.h))){
//失敗した場合はARPリクエストに変換して再送
- sendArpReqest(i_buf);
+//@todo unchecked PASS!
+ sendArpReqest(&i_buf->data.ipv4.destipaddr);
}
return;
}
-/**
- * IPv4パケットのpeerIPを問い合わせるARPパケットを送信します。
- */
-static void sendArpReqest(const struct TEthPacket* i_eth_packet)
-{
- NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
- NyLPC_TUInt16 tx_len;
- struct TEthPacket* ethbuf;
- //ACK送信用の自己バッファが空くまで待つ
- while(inst->stx.h.is_lock){
- inst->_ethif->processTx();
- }
- //ARPパケットを作る。
- ethbuf=(struct TEthPacket*)(inst->stx.buf);
- NyLPC_TArpHeader_setArpRequest(&(ethbuf->data.arp),inst->_ref_config->ip_addr,&(inst->_ref_config->eth_mac),i_eth_packet->data.ipv4.destipaddr);
- tx_len=NyLPC_TEthernetIIHeader_setArpTx(&(ethbuf->header),&(inst->_ref_config->eth_mac));
- //送信
- inst->_ethif->sendTxEthFrame(&(inst->stx.h),tx_len);
-}
+
+
/**
* uipタスクが所有するTXバッファを使用してデータを送信します。
@@ -623,36 +625,4 @@
-//static void startEther()
-//{
-// NyLPC_TcUipService_t* inst=_NyLPC_TcUipService_inst;
-//
-// //Ethernetの起動待ち
-// while(lEMACInit(_NyLPC_TcUipService_inst->_emac_semapho,&(inst->_ref_config->eth_mac))!= pdPASS )
-// {
-// vTaskDelay( 100 / portTICK_RATE_MS );
-// }
-// //Ethernetの割込み開始設定
-// portENTER_CRITICAL();
-// {
-// LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE );
-// /* Set the interrupt priority to the max permissible to cause some
-// interrupt nesting. */
-// NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );
-//
-// /* Enable the interrupt. */
-// NVIC_EnableIRQ( ENET_IRQn );
-// }
-// portEXIT_CRITICAL();
-//}
-//
-//static void stopEther()
-//{
-// portENTER_CRITICAL();
-// {
-// LPC_EMAC->IntEnable = (~(INT_RX_DONE|INT_TX_DONE))&LPC_EMAC->IntEnable;
-// NVIC_DisableIRQ( ENET_IRQn );
-// }
-// portEXIT_CRITICAL();
-//}
MiMic Webservice library