OSDN Git Service

NyLPC_cTcpSocketへTCP送信パケットライタを統合
[mimic/MiMicSDK.git] / lib / src / uip / NyLPC_uip.h
index 0afc80c..ed36601 100644 (file)
@@ -54,8 +54,8 @@
  */\r
 #ifndef NyLPC_uip_h\r
 #define NyLPC_uip_h\r
-#include "../include/NyLPC_stdlib.h"\r
 #include "../include/NyLPC_config.h"\r
+#include "../include/NyLPC_stdlib.h"\r
 #include "NyLPC_uip_ethernet.h"\r
 \r
 #ifdef __cplusplus\r
@@ -67,6 +67,10 @@ extern "C" {
 #define UIP_PROTO_UDP   17\r
 #define UIP_PROTO_ICMP6 58\r
 \r
+#define ARP_REQUEST 1\r
+#define ARP_REPLY   2\r
+#define ARP_HWTYPE_ETH 1\r
+\r
 \r
 #ifndef PACK_STRUCT_END\r
        #define PACK_STRUCT_END __attribute((packed))\r
@@ -88,6 +92,10 @@ struct NyLPC_TIPv4Addr
 }PACK_STRUCT_END;\r
 extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_ZERO;\r
 extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_ALL;\r
+extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_BROADCAST;\r
+extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_MULTICAST;\r
+extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_MULTICAST_MASK;\r
+extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_APIPA_MASK;\r
 \r
 /**\r
  * addr1とaddr2が全く同じであるかをテストします。\r
@@ -108,8 +116,14 @@ extern const struct NyLPC_TIPv4Addr NyLPC_TIPv4Addr_ALL;
  NyLPC_TIpv4Addr_set(&ip,1,2,3,4);\r
  \endcode\r
  */\r
-#define NyLPC_TIPv4Addr_set(s,a0,a1,a2,a3) (s).v=NyLPC_htonl((0xff000000&(a0<<24))|(0x00ff0000&(a1<<16))|(0x0000ff00&(a2<<8))|(0x000000ff&(a3)))\r
-#define NyLPC_TIPv4Addr_pack(a0,a1,a2,a3) {NyLPC_HTONL((0xff000000&(a0<<24))|(0x00ff0000&(a1<<16))|(0x0000ff00&(a2<<8))|(0x000000ff&(a3)))}\r
+#define NyLPC_TIPv4Addr_set(s,a0,a1,a2,a3) (s)->v=NyLPC_htonl((0xff000000&(((NyLPC_TUInt32)(a0))<<24))|(0x00ff0000&(((NyLPC_TUInt32)(a1))<<16))|(0x0000ff00&(((NyLPC_TUInt32)(a2))<<8))|(0x000000ff&((NyLPC_TUInt32)(a3))))\r
+#define NyLPC_TIPv4Addr_pack(a0,a1,a2,a3) {NyLPC_HTONL((0xff000000&(((NyLPC_TUInt32)(a0))<<24))|(0x00ff0000&(((NyLPC_TUInt32)(a1))<<16))|(0x0000ff00&(((NyLPC_TUInt32)(a2))<<8))|(0x000000ff&((NyLPC_TUInt32)(a3))))}\r
+\r
+/**\r
+ * IPアドレスを文字列に変換して返します。\r
+ */\r
+NyLPC_TInt16 NyLPC_TIPv4Addr_toString(const struct NyLPC_TIPv4Addr* i_ip,NyLPC_TChar* i_buf);\r
+\r
 \r
 \r
 \r
@@ -131,19 +145,6 @@ NyLPC_TUInt16 NyLPC_uip_chksum(NyLPC_TUInt16 sum, const NyLPC_TUInt8 *data, NyLP
  */\r
 #define UIP_DEFAULT_IP_TTL 64\r
 \r
-/**\r
- * RTOの最大値。ms単位である。\r
- * 64sが標準値である。\r
- */\r
-#define UIP_IP_RTO_MAX_RTO 64000\r
-\r
-/**\r
- * RTOの初期値。ms単位である。\r
- * 伝送路の特性に合わせて調整すること。\r
- */\r
-#define UIP_IP_RTOP_INITIAL 3000\r
-\r
-#define UIP_IP_RTO_MINIMUM 100\r
 \r
 \r
 /**\r
@@ -154,21 +155,7 @@ NyLPC_TUInt16 NyLPC_uip_chksum(NyLPC_TUInt16 sum, const NyLPC_TUInt8 *data, NyLP
  */\r
 #define UIP_MAXRTX      8\r
 \r
-/**\r
- * The maximum number of times a SYN segment should be retransmitted\r
- * before a connection request should be deemed to have been\r
- * unsuccessful.\r
- *\r
- * This should not need to be changed.\r
- */\r
-#define UIP_MAXSYNRTX      5\r
-/**\r
- * How long a connection should stay in the TIME_WAIT state.\r
- *\r
- * This configiration option has no real implication, and it should be\r
- * left untouched.\r
- */\r
-#define UIP_TIME_WAIT_TIMEOUT 120\r
+\r
 \r
 \r
 \r
@@ -180,7 +167,7 @@ NyLPC_TUInt16 NyLPC_uip_chksum(NyLPC_TUInt16 sum, const NyLPC_TUInt8 *data, NyLP
 #              define NyLPC_ntohl(n) (n)\r
 #              define NyLPC_HTONS(n) (n)\r
 #              define NyLPC_NTOHS(n) (n)\r
-#   else /* UIP_BYTE_ORDER == UIP_BIG_ENDIAN */\r
+#   else\r
 #              define NyLPC_htonl(n) NyLPC_TUInt32_bswap(n)\r
 #              define NyLPC_ntohl(n) NyLPC_TUInt32_bswap(n)\r
 #              define NyLPC_htons(n) NyLPC_TUInt16_bswap(n)\r
@@ -269,7 +256,7 @@ NyLPC_TUInt16 NyLPC_TIPv4Header_makeTcpChecksum(
 /**\r
  * IPヘッダの長さを返す。\r
  */\r
-#define NyLPC_TIPv4Header_getHeaderLength(i_iph) ((i_iph->vhl & 0x0f)*4)\r
+#define NyLPC_TIPv4Header_getHeaderLength(i_iph) (((i_iph)->vhl & 0x0f)*4)\r
 /**\r
  * IPパケット全体の長さを返す。
  */\r
@@ -375,6 +362,11 @@ struct NyLPC_TUdpHeader
        NyLPC_TUInt16 udpchksum;\r
 } PACK_STRUCT_END;\r
 \r
+/**\r
+ * UDPヘッダの長さを返す。\r
+ */\r
+#define NyLPC_TUdpHeader_getHeaderLength(i_struct) (8)\r
+\r
 /**********************************************************************\r
  *\r
  * struct NyLPC_TIcmpipHeader\r
@@ -416,11 +408,14 @@ struct NyLPC_TArpHeader
 } PACK_STRUCT_END;\r
 \r
 \r
+/**\r
+ * i_req_addrを問い合わせるARP_REQUESTを生成します。\r
+ */\r
 void NyLPC_TArpHeader_setArpRequest(\r
        struct NyLPC_TArpHeader* i_struct,\r
        const struct NyLPC_TIPv4Addr i_saddr,\r
        const struct NyLPC_TEthAddr* i_srceth,\r
-       const struct NyLPC_TIPv4Addr i_daddr);\r
+       const struct NyLPC_TIPv4Addr* i_req_addr);\r
 \r
 \r
 typedef struct NyLPC_TcEthernetIIPayload NyLPC_TcEthernetIIPayload_t;\r