Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c
r321 r331 2 2 * TINET (UDP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 71 71 #include <kernel.h> 72 72 #include <sil.h> 73 #include <t_syslog.h> 73 74 #include "kernel_cfg.h" 75 #include "tinet_cfg.h" 74 76 75 77 #endif /* of #ifdef TARGET_KERNEL_ASP */ … … 80 82 #include <t_services.h> 81 83 #include "kernel_id.h" 84 #include "tinet_id.h" 82 85 83 86 #endif /* of #ifdef TARGET_KERNEL_JSP */ … … 91 94 #include <net/ethernet.h> 92 95 #include <net/net.h> 96 #include <net/net_endian.h> 93 97 #include <net/net_buf.h> 94 98 #include <net/net_count.h> … … 96 100 97 101 #include <netinet/in.h> 98 #include <netinet6/in6.h>99 102 #include <netinet/in_var.h> 100 103 #include <netinet/in_itron.h> … … 102 105 #include <netinet/ip_var.h> 103 106 #include <netinet/ip_icmp.h> 104 #include <netinet6/in6_var.h>105 #include <netinet/ip6.h>106 #include <netinet6/ip6_var.h>107 #include <netinet6/nd6.h>108 #include <netinet/icmp6.h>109 107 #include <netinet/udp.h> 110 108 #include <netinet/udp_var.h> 109 #include <netinet/ip_igmp.h> 110 111 #include <net/if_var.h> 111 112 112 113 #ifdef SUPPORT_UDP … … 116 117 */ 117 118 119 #if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0) 120 118 121 static uint16_t udp_port_auto = UDP_PORT_FIRST_AUTO; /* 自動割り当て番号 */ 119 122 123 #endif /* of #if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0) */ 124 120 125 /* 121 * udp_alloc_auto_port -- 自動割り当てポート番号を設定する。126 * IPv6 と IPv4 で引数が異なる関数のコンパイル 122 127 */ 123 128 124 ER 125 udp_alloc_auto_port (T_UDP_CEP *cep) 126 { 127 int_t ix; 128 uint16_t portno, portno_start; 129 #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 129 130 130 portno_start = udp_port_auto; 131 do { 132 portno = udp_port_auto ++; 133 if (udp_port_auto > UDP_PORT_LAST_AUTO) 134 udp_port_auto = UDP_PORT_FIRST_AUTO; 131 #if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR) 135 132 136 syscall(wai_sem(SEM_UDP_CEP)); 137 for (ix = tmax_udp_ccepid; ix -- > 0; ) { 138 if (VALID_UDP_CEP(&udp_cep[ix]) && udp_cep[ix].myaddr.portno == portno) { 139 portno = UDP_PORTANY; 140 break; 141 } 142 } 133 #define UDP_IS_DSTADDR_ACCEPT udpn_is_dstaddr_accept 143 134 144 if (portno != UDP_PORTANY) { 145 cep->myaddr.portno = portno; 146 syscall(sig_sem(SEM_UDP_CEP)); 147 return E_OK; 148 } 149 syscall(sig_sem(SEM_UDP_CEP)); 135 #else /* of #if defined(_IP4_CFG) */ 150 136 151 } while (portno_start != udp_port_auto); 137 #define UDP_IS_DSTADDR_ACCEPT udp6_is_dstaddr_accept 152 138 153 return E_NOID; 154 } 139 #endif /* of #if defined(_IP4_CFG) */ 155 140 156 /* 157 * udp_alloc_port -- 指定されたポート番号を設定する。 158 */ 141 #define UDP_SEND_DATA udp6_send_data 142 #define UDP_CAN_SND udp6_can_snd 143 #define UDP_CAN_RCV udp6_can_rcv 144 #define UDP_ALLOC_AUTO_PORT udp6_alloc_auto_port 145 #define UDP_ALLOC_PORT udp6_alloc_port 146 #define UDP_FIND_CEP udp6_find_cep 147 #define UDP_NOTIFY udp6_notify 148 #define TMAX_UDP_CEPID tmax_udp6_cepid 149 #define UDP_CEP udp6_cep 150 #define T_UDP_CEP T_UDP6_CEP 151 #define T_IPEP T_IPV6EP 152 #define API_PROTO API_PROTO_IPV6 159 153 160 ER 161 udp_alloc_port (T_UDP_CEP *cep, uint16_t portno) 162 { 163 int_t ix; 154 #include <netinet6/udp6_subr.c> 155 #include <netinet/udpn_subr.c> 164 156 165 syscall(wai_sem(SEM_UDP_CEP)); 166 for (ix = tmax_udp_ccepid; ix -- > 0; ) 167 if (VALID_UDP_CEP(&udp_cep[ix]) && udp_cep[ix].myaddr.portno == portno) { 168 syscall(sig_sem(SEM_UDP_CEP)); 169 return E_PAR; 170 } 171 cep->myaddr.portno = portno; 172 syscall(sig_sem(SEM_UDP_CEP)); 173 return E_OK; 174 } 157 #undef UDP_SEND_DATA 158 #undef UDP_CAN_SND 159 #undef UDP_CAN_RCV 160 #undef UDP_ALLOC_AUTO_PORT 161 #undef UDP_ALLOC_PORT 162 #undef UDP_FIND_CEP 163 #undef UDP_NOTIFY 164 #undef UDP_IS_DSTADDR_ACCEPT 165 #undef TMAX_UDP_CEPID 166 #undef UDP_CEP 167 #undef T_UDP_CEP 168 #undef T_IPEP 169 #undef API_PROTO 170 171 #endif /* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */ 172 173 #if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \ 174 ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR))) 175 176 #define UDP_IS_DSTADDR_ACCEPT udp4_is_dstaddr_accept 177 178 #define UDP_SEND_DATA udp4_send_data 179 #define UDP_CAN_SND udp4_can_snd 180 #define UDP_CAN_RCV udp4_can_rcv 181 #define UDP_ALLOC_AUTO_PORT udp4_alloc_auto_port 182 #define UDP_ALLOC_PORT udp4_alloc_port 183 #define UDP_FIND_CEP udp4_find_cep 184 #define UDP_NOTIFY udp4_notify 185 #define TMAX_UDP_CEPID tmax_udp4_cepid 186 #define T_UDP_CEP T_UDP4_CEP 187 #define UDP_CEP udp4_cep 188 #define T_IPEP T_IPV4EP 189 #define API_PROTO API_PROTO_IPV4 190 191 #include <netinet/udp4_subr.c> 192 #include <netinet/udpn_subr.c> 193 194 #endif /* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */ 175 195 176 196 #endif /* of #ifdef SUPPORT_UDP */
Note:
See TracChangeset
for help on using the changeset viewer.