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/ip_icmp.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 *
     
    7676#include <t_syslog.h>
    7777#include "kernel_cfg.h"
     78#include "tinet_cfg.h"
    7879
    7980#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8384#include <s_services.h>
    8485#include <t_services.h>
     86#include "tinet_id.h"
    8587
    8688#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9597#include <net/ppp_ipcp.h>
    9698#include <net/net.h>
     99#include <net/net_endian.h>
    97100#include <net/net_buf.h>
    98101#include <net/net_timer.h>
     
    106109#include <netinet/icmp_var.h>
    107110#include <netinet/tcp.h>
    108 #include <netinet/tcp_timer.h>
    109111#include <netinet/tcp_var.h>
     112#include <netinet/udp_var.h>
     113
     114#include <net/if_var.h>
     115
     116#if defined(_IP4_CFG)
    110117
    111118/*
     
    130137static void icmp_unreach (T_NET_BUF *input, uint_t ihoff);
    131138
     139#if defined(NUM_REDIRECT_ROUTE_ENTRY)
    132140#if NUM_REDIRECT_ROUTE_ENTRY > 0
    133141
     
    135143
    136144#endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     145#endif  /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
    137146
    138147/*
     
    147156        T_IP4_HDR       *ip4h;
    148157        T_ICMP4_HDR     *icmp4h;
    149         T_IN4_ADDR      addr;
     158        T_IFNET         *ifp = IF_GET_IFNET();
    150159
    151160        NET_COUNT_MIB(icmp_stats.icmpInEchos, 1);
    152161
    153         /* メッセージの型をエコー要求 (8) から エコー応答 (0) に     */
    154         /* 変更して送り返す。                                    */
    155 
    156         icmp4h = GET_ICMP4_HDR(input, ihoff);
    157         icmp4h->type = ICMP4_ECHO_REPLY;
    158 
    159         /* IP ヘッダの宛先と発信元を交換する。*/
    160         ip4h      = GET_IP4_HDR(input);
    161         addr      = ip4h->src;
    162         ip4h->src = ip4h->dst;
    163         ip4h->dst = addr;
    164 
    165         /* チェックサムを計算する。*/
    166         icmp4h->sum = 0;
    167         icmp4h->sum = in_cksum(icmp4h,
    168                                (uint_t)(((input->len - GET_IF_IP4_HDR_SIZE(input)) + 3) >> 2 << 2));
    169 
    170         /* 送信する。*/
    171         NET_COUNT_ICMP4(net_count_icmp4.out_octets,
    172                        input->len - GET_IF_IP4_HDR_SIZE(input));
    173         NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
    174         NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
    175         NET_COUNT_MIB(icmp_stats.icmpOutEchoReps, 1);
    176         ip_output(input, TMO_ICMP_OUTPUT);
     162        /* IPv4 アドレスが未定義の時は応答しない。*/
     163        if (!IN4_IS_ADDR_ANY(&ifp->in4_ifaddr.addr)) {
     164
     165                /*
     166                 *  メッセージの型をエコー要求 (8) から
     167                 *  エコー応答 (0) に変更して送り返す。
     168                 */
     169
     170                icmp4h = GET_ICMP4_HDR(input, ihoff);
     171                icmp4h->type = ICMP4_ECHO_REPLY;
     172
     173                /*
     174                 *  宛先アドレスは受信したメッセージの送信元アドレス。
     175                 *  送信元アドレスは自 IPv4 アドレス。
     176                 */
     177                ip4h      = GET_IP4_HDR(input);
     178                ip4h->dst = ip4h->src;
     179                ip4h->src = htonl(ifp->in4_ifaddr.addr);
     180
     181                /* チェックサムを計算する。*/
     182                icmp4h->sum = 0;
     183                icmp4h->sum = in_cksum(icmp4h,
     184                                       (uint_t)(((input->len - GET_IF_IP4_HDR_SIZE(input)) + 3) >> 2 << 2));
     185
     186                /* 送信する。*/
     187                NET_COUNT_ICMP4(net_count_icmp4.out_octets,
     188                               input->len - GET_IF_IP4_HDR_SIZE(input));
     189                NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
     190                NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
     191                NET_COUNT_MIB(icmp_stats.icmpOutEchoReps, 1);
     192                ip_output(input, TMO_ICMP_OUTPUT);
     193                }
    177194        }
    178195
     
    212229        code  = GET_ICMP4_HDR(input, ihoff)->code;
    213230        error = code2error[code];
    214         if (ip4h->proto == IPPROTO_TCP) {
    215 
    216 #ifdef SUPPORT_TCP
     231
     232        /* 最終ヘッダが TCP/UDP のみ対応する。*/
     233        if (ip4h->proto == IPPROTO_TCP || ip4h->proto == IPPROTO_UDP) {
    217234
    218235                memcpy(GET_IP4_HDR(input), ip4h, input->len - (IP4_HDR_SIZE + ICMP4_HDR_SIZE));
    219236                input->len -= IP4_HDR_SIZE + ICMP4_HDR_SIZE;
    220                 tcp_notify(input, error);
    221 
    222 #endif  /* of #ifdef SUPPORT_TCP */
     237
     238#if defined(SUPPORT_TCP)
     239
     240                if (ip4h->proto == IPPROTO_TCP)
     241                        tcp_notify(input, error);
     242
     243#endif  /* of #if defined(SUPPORT_TCP) */
     244
     245#if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0
     246
     247                if (ip4h->proto == IPPROTO_UDP)
     248                        udp4_notify(input, error);
     249
     250#endif  /* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
    223251
    224252                }
     
    227255        }
    228256
     257#if defined(NUM_REDIRECT_ROUTE_ENTRY)
    229258#if NUM_REDIRECT_ROUTE_ENTRY > 0
    230259
     
    264293
    265294#endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     295#endif  /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
    266296
    267297/*
     
    314344        case ICMP4_ECHO_REPLY:
    315345
    316 #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY
     346#if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY)
    317347
    318348                icmp_echo_reply(input, *offp);
    319349
    320 #endif  /* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
     350#endif  /* of #if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY) */
    321351
    322352                break;
     
    326356        case ICMP4_REDIRECT:
    327357
     358#if defined(NUM_REDIRECT_ROUTE_ENTRY)
    328359#if NUM_REDIRECT_ROUTE_ENTRY > 0
    329360
     
    338369
    339370#endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     371#else   /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
     372
     373                addr = ntohl(icmp4h->data.addr);
     374                syslog(LOG_INFO, "[ICMP] redirect ignored, addr: %s.", ip2str(NULL, &addr));
     375
     376#endif  /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
    340377
    341378                break;
     
    371408
    372409        ip4h  = GET_IP4_HDR(input);
    373         ip4hl = GET_IP4_HDR_SIZE(ip4h);
     410        ip4hl = GET_IP4_HDR_SIZE(input);
    374411
    375412        /* 送信用の IP データグラムを獲得する。*/
     
    378415        else
    379416                len = 8;
    380 
     417       
    381418        saddr = ntohl(ip4h->src);
    382419        if (in4_get_datagram(&output, (uint_t)(ICMP4_HDR_SIZE + ip4hl + len), 0,
     
    417454
    418455#endif  /* of #ifdef ICMP_REPLY_ERROR */
     456
     457#endif  /* of #if defined(_IP4_CFG) */
Note: See TracChangeset for help on using the changeset viewer.