Ignore:
Timestamp:
Jan 21, 2018, 12:10:09 AM (6 years ago)
Author:
coas-nagasima
Message:

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c

    r321 r331  
    22 *  TINET (TCP/IP Protocol Stack)
    33 *
    4  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
     4 *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
    55 *                   Tomakomai National College of Technology, JAPAN
    66 *
     
    7373#include <t_syslog.h>
    7474#include "kernel_cfg.h"
     75#include "tinet_cfg.h"
    7576
    7677#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8182#include <t_services.h>
    8283#include "kernel_id.h"
     84#include "tinet_id.h"
    8385
    8486#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9294#include <net/ethernet.h>
    9395#include <net/net.h>
     96#include <net/net_endian.h>
    9497#include <net/net_buf.h>
    9598#include <net/net_count.h>
    9699
    97100#include <netinet/in.h>
    98 #include <netinet6/in6.h>
    99101#include <netinet/in_var.h>
    100102#include <netinet/in_itron.h>
     
    102104#include <netinet/ip_var.h>
    103105#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>
    109106#include <netinet/udp.h>
    110107#include <netinet/udp_var.h>
     
    115112
    116113/*
    117  *  関数
    118  */
    119 
    120 static void udp_output (T_UDP_CEP *cep);
    121 
    122 /*
    123  *  UDP 出力タスク
    124  *  ノンブロッキングコールを組み込んだとき使用する。
    125  */
    126 
    127 static void
    128 udp_output (T_UDP_CEP *cep)
    129 {
    130         T_NET_BUF       *output;
    131         T_UDP_HDR       *udph;
    132         ER_UINT         error;
    133 
    134 #ifdef UDP_CFG_OUT_CHECKSUM
    135         uint16_t        sum;
    136 #endif  /* of #ifdef UDP_CFG_OUT_CHECKSUM */
    137 
    138         /* IP データグラムを割り当てる。*/
    139         if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + cep->snd_len), 0,
    140                                      &cep->snd_p_dstaddr->ipaddr,
    141                                      &cep->myaddr.ipaddr,
    142                                      IPPROTO_UDP, IP_DEFTTL,
    143                                      NBA_SEARCH_ASCENT, TMO_UDP_OUTPUT)) != E_OK) {
    144                 goto err_ret;
    145                 }
    146 
    147         /* UDP ヘッダに情報を設定する。*/
    148         udph            = GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET);
    149         udph->sport     = htons(cep->myaddr.portno);
    150         udph->dport     = htons(cep->snd_p_dstaddr->portno);
    151         udph->ulen      = htons(UDP_HDR_SIZE + cep->snd_len);
    152         udph->sum       = 0;
    153 
    154         /* データをコピーする。*/
    155         memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET),
    156                cep->snd_data, (size_t)cep->snd_len);
    157 
    158 #ifdef UDP_CFG_OUT_CHECKSUM
    159 
    160         sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET,
    161                        (uint_t)(UDP_HDR_SIZE + cep->snd_len));
    162 
    163         /* 計算したチェックサムの値が 0 なら 0xffff を入れる。*/
    164         if (sum == 0)
    165                 sum = UINT_C(0xffff);
    166         udph->sum = sum;
    167 
    168 #endif/* of #ifdef UDP_CFG_OUT_CHECKSUM */
    169 
    170         /* ネットワークバッファ長を調整する。*/
    171         output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE + cep->snd_len);
    172 
    173         /* ネットワーク層 (IP) の出力関数を呼び出す。*/
    174         if ((error = IP_OUTPUT(output, TMO_UDP_OUTPUT)) != E_OK)
    175                 goto err_ret;
    176 
    177 
    178         NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
    179 
    180         if (IS_PTR_DEFINED(cep->callback)) {
    181 
    182                 if (error == E_OK)
    183                         error = cep->snd_len;
    184 
    185 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    186 
    187                 (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
    188 
    189 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    190 
    191                 (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
    192 
    193 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    194 
    195                 }
    196         else
    197                 syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
    198         cep->snd_p_dstaddr = NULL;
    199         return;
    200 
    201 err_ret:
    202         NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
    203         if (IS_PTR_DEFINED(cep->callback)) {
    204 
    205 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    206 
    207                 (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)E_NOMEM);
    208 
    209 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    210 
    211                 error = E_NOMEM;
    212                 (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
    213 
    214 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    215 
    216                 }
    217         else
    218                 syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
    219         cep->snd_p_dstaddr = NULL;
    220         return;
    221         }
     114 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
     115 */
     116
     117#undef  IN_GET_DATAGRAM
     118
     119#if defined(_IP6_CFG)
     120
     121#define UDP_OUTPUT              udp6_output
     122#define GET_UDP_CEPID           GET_UDP6_CEPID
     123#define T_UDP_CEP               T_UDP6_CEP
     124#define API_PROTO               API_PROTO_IPV6
     125
     126#if defined(_IP4_CFG)
     127#define IN_GET_DATAGRAM         inn_get_datagram
     128#else
     129#define IN_GET_DATAGRAM         in6_get_datagram
     130#endif
     131
     132#include <netinet/udpn_output.c>
     133
     134#undef  UDP_OUTPUT
     135#undef  GET_UDP_CEPID
     136#undef  T_UDP_CEP
     137#undef  API_PROTO
     138#undef  IN_GET_DATAGRAM
     139
     140#endif  /* of #if defined(_IP6_CFG)  */
     141
     142#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
     143
     144#define UDP_OUTPUT              udp4_output
     145#define GET_UDP_CEPID           GET_UDP4_CEPID
     146#define T_UDP_CEP               T_UDP4_CEP
     147#define API_PROTO               API_PROTO_IPV4
     148
     149#define IN_GET_DATAGRAM         in4_get_datagram
     150
     151#include <netinet/udpn_output.c>
     152
     153#endif  /* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
    222154
    223155/*
     
    236168
    237169
    238 #if defined(SUPPORT_INET6) && !defined(SUPPORT_TCP)
     170#if defined(_IP6_CFG) && !defined(SUPPORT_TCP)
    239171
    240172        /* IPv6 のステートレス・アドレス自動設定を実行する。*/
    241173        in6_if_up(IF_GET_IFNET());
    242174
    243 #endif  /* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_TCP) */
     175#endif  /* of #if defined(_IP6_CFG) && !defined(SUPPORT_TCP) */
    244176
    245177        while (true) {
     
    248180                syscall(wai_sem(SEM_UDP_POST_OUTPUT));
    249181
    250                 for (ix = tmax_udp_ccepid; ix -- > 0; ) {
    251 
    252                         if (udp_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
    253                                 udp_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
    254                                 udp_output(&udp_cep[ix]);
     182#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
     183
     184                for (ix = tmax_udp6_cepid; ix -- > 0; ) {
     185
     186                        if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
     187                                udp6_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
     188                                udp6_output(&udp6_cep[ix]);
    255189                                }
    256190                        }
     191
     192#endif  /* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
     193
     194#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
     195
     196                for (ix = tmax_udp4_cepid; ix -- > 0; ) {
     197
     198                        if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
     199                                udp4_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
     200                                udp4_output(&udp4_cep[ix]);
     201                                }
     202                        }
     203
     204#endif  /* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
     205
    257206                }
    258207        }
Note: See TracChangeset for help on using the changeset viewer.