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

Location:
EcnlProtoTool/trunk/asp3_dcre/tinet
Files:
80 added
13 deleted
165 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet

    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#   Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
     
    6363
    6464#
     65#  TINET 1.7 以降は、ネットワーク層の指定を変更した。
     66#
     67
     68ifeq ($(SUPPORT_INET6),true)
     69        TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
     70endif
     71
     72ifeq ($(SUPPORT_INET4),true)
     73        TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
     74endif
     75
     76ifeq ($API_CFG_IP4MAPPED_ADDR,true)
     77        TINET_CDEFS := $(TINET_CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
     78endif
     79
     80ifeq ($(SUPPORT_IGMP),true)
     81        TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_IGMP
     82endif
     83
     84#
    6585#  ネットワークサービスに関する定義
    6686#
    67 TINET_DIR = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet
    68 
     87
     88#  汎用通信機能
     89
     90TINET_DIRS = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet:$(TINET_ROOT)/netinet6
    6991TINET_COBJS := $(TINET_COBJS) \
    70                net_buf.o net_count.o net_subr.o net_timer.o \
    71                in_subr.o tinet_cfg.o route_cfg.o
    72 
    73 ifeq ($(SUPPORT_INET4),true)
    74 
    75         TINET_COBJS := $(TINET_COBJS) \
    76                        ip_input.o ip_output.o ip_icmp.o
    77         TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/ip.cfg
    78         TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
    79 
    80 endif
    81 
    82 ifeq ($(SUPPORT_INET6),true)
    83 
    84         TINET_DIR := $(TINET_DIR):$(TINET_ROOT)/netinet6
    85         TINET_COBJS := $(TINET_COBJS) \
    86                        in6.o in6_ifattach.o nd6_rtr.o \
    87                        in6_subr.o ip6_input.o icmp6.o \
    88                        dest6.o route6.o frag6.o \
    89                        ah_input.o esp_input.o \
    90                        nd6.o nd6_nbr.o ip6_output.o scope6.o
    91         TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet6/ip6.cfg
    92         TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
    93 
    94 endif
     92               net_buf.o net_count.o net_subr.o net_timer.o if.o \
     93               in_subr.o route_cfg.o
     94TINET_CFG_COBJS := $(TINET_CFG_COBJS) tinet_cfg.o
     95
     96#  IPv6
     97
     98TINET_COBJS := $(TINET_COBJS) \
     99               in6.o in6_ifattach.o nd6_rtr.o \
     100               in6_subr.o ip6_input.o icmp6.o \
     101               dest6.o route6.o frag6.o \
     102               ah_input.o esp_input.o \
     103               nd6.o nd6_nbr.o ip6_output.o scope6.o
     104TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet6/ip6.cfg
     105
     106#  IPv4
     107
     108TINET_COBJS := $(TINET_COBJS) \
     109               ip_input.o ip_output.o ip_icmp.o ip_igmp.o in4_subr.o
     110TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/ip.cfg
     111
     112#  loop back
    95113
    96114ifeq ($(NET_IF),loop)
     
    102120endif
    103121
     122#  ppp
     123
    104124ifeq ($(NET_IF),ppp)
    105125
    106126        TINET_COBJS := $(TINET_COBJS) \
    107127                       ppp.o ppp_hdlc.o ppp_lcp.o ppp_fsm.o \
    108                        ppp_auth.o ppp_ipcp.o ppp_upap.o
     128                       ppp_auth.o ppp_upap.o
    109129        TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/ppp.cfg
    110130        TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_PPP
     131
     132#  IPv6用 cp
     133        TINET_COBJS := $(TINET_COBJS) ppp_ipv6cp.o
     134
     135#  IPv4用 cp
     136        TINET_COBJS := $(TINET_COBJS) ppp_ipcp.o
    111137
    112138ifeq ($(PPP_CFG_MODEM),true)
     
    143169endif
    144170
     171#  ethernet
     172
    145173ifeq ($(NET_IF),ether)
    146174
    147         TINET_COBJS := $(TINET_COBJS) if.o ethernet.o
    148         TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/ethernet.cfg
     175        TINET_COBJS := $(TINET_COBJS) ethernet.o if6_ether.o if_ether.o
     176        TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) \
     177                            $(TINET_ROOT)/net/ethernet.cfg \
     178                            $(TINET_ROOT)/netinet/if_ether.cfg
    149179        TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_ETHER
    150 
    151         ifeq ($(SUPPORT_INET4),true)
    152 
    153                 TINET_COBJS := $(TINET_COBJS) if_ether.o
    154                 TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/if_ether.cfg
    155 
    156         endif
    157 
    158         ifeq ($(SUPPORT_INET6),true)
    159 
    160                 TINET_COBJS := $(TINET_COBJS) if6_ether.o
    161 
    162         endif
    163 
    164 
    165180        include $(TINET_ROOT)/netdev/$(NET_DEV)/Makefile.tinet
    166181
    167182endif
     183
     184#  TCP
    168185
    169186ifeq ($(SUPPORT_TCP),true)
     
    177194endif
    178195
     196#  UDP
     197
    179198ifeq ($(SUPPORT_UDP),true)
    180199
     
    193212
    194213        ifeq ($(SUPPORT_TCP),true)
    195 
    196214                TINET_COBJS := $(TINET_COBJS) tcp_usrreq.o
    197 
    198215        endif
    199216
    200217        ifeq ($(SUPPORT_UDP),true)
    201 
    202                 TINET_COBJS := $(TINET_COBJS) udp_usrreq.o
    203 
     218                TINET_COBJS := $(TINET_COBJS) udp_usrreq.o udp_usrreq_nblk.o
    204219        endif
    205220
     
    207222
    208223        ifeq ($(SUPPORT_TCP),true)
    209 
    210224                TINET_LCSRCS := $(TINET_LCSRCS) tcp_usrreq.c
    211 
    212225        endif
    213226
    214227        ifeq ($(SUPPORT_UDP),true)
    215 
    216                 TINET_LCSRCS := $(TINET_LCSRCS) udp_usrreq.c
    217 
     228                TINET_LCSRCS := $(TINET_LCSRCS) udp_usrreq.c udp_usrreq_nblk.c
    218229        endif
    219230
     
    248259                tcp_set_opt.o tcp_get_opt.o
    249260
    250 udp_usrreq =    udp_can_snd.o udp_can_rcv.o udp_can_cep.o \
    251                 udp_cre_cep.o udp_del_cep.o \
    252                 udp_snd_dat.o udp_rcv_dat.o udp_send_data.o \
    253                 udp_set_opt.o udp_get_opt.o
     261udp_usrreq =    udp_can_cep.o udp_send_data.o \
     262                udp_can_snd.o udp_can_rcv.o \
     263                udp_snd_dat.o udp_rcv_dat.o \
     264                udp_set_opt.o udp_get_opt.o \
     265                udp_cre_cep.o udp_del_cep.o
     266
     267udp_usrreq_nblk = \
     268                udp_can_snd_nblk.o udp_can_rcv_nblk.o \
     269                udp_snd_dat_nblk.o udp_rcv_dat_nblk.o
    254270
    255271#
     
    257273#  オブジェクトファイルの依存関係の定義
    258274#
    259 $(tcp_usrreq) $(tcp_usrreq:.o=.s) $(tcp_usrreq:.o=.d): tcp_usrreq.c
    260 $(udp_usrreq) $(udp_usrreq:.o=.s) $(udp_usrreq:.o=.d): udp_usrreq.c udp_usrreq_nblk.c
     275$(tcp_usrreq) $(tcp_usrreq:.o=.s) $(tcp_usrreq:.o=.d): tcp_usrreq.c tcpn_usrreq.c
     276$(udp_usrreq) $(udp_usrreq:.o=.s) $(udp_usrreq:.o=.d): udp_usrreq.c udpn_usrreq.c
     277$(udp_usrreq_nblk) $(udp_usrreq_nblk:.o=.s) $(udp_usrreq_nblk:.o=.d): udp_usrreq_nblk.c
    261278
    262279#
     
    271288ifeq ($(TARGET_KERNEL),ASP)
    272289
    273 TINET_CFG = $(APPLDIR)/tinet_$(APPLNAME).cfg
    274 TINET_CFG_OUT = tinet_cfg.c tinet_cfg.h
     290TINET_CFG_OUT = tinet_cfg.c tinet_cfg.h tinet_kern.cfg
    275291TINET_KERNEL_CFG :=     $(TINET_KERNEL_CFG) \
    276292                        $(TINET_ROOT)/tinet_asp.cfg $(TINET_ROOT)/net/net_asp.cfg
     
    305321ifeq ($(TARGET_KERNEL),ASP)
    306322
    307         SYSSVC_DIRS := $(SYSSVC_DIRS):$(TINET_DIR)
     323        SYSSVC_DIRS := $(SYSSVC_DIRS):$(TINET_DIRS)
    308324        SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
    309325        SYSSVC_COBJS := $(SYSSVC_COBJS) $(TINET_COBJS)
     
    311327        SYSSVC_LIBS := $(SYSSVC_LIBS) $(LIBTINET) -lc
    312328
     329        CFG_COBJS := $(CFG_COBJS) $(TINET_CFG_COBJS)
     330
    313331        CLEAN_FILES := $(CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
    314332
     
    319337        MTASK_CFG := $(MTASK_CFG) $(TINET_CFG)
    320338        MTASK_KERNEL_CFG := $(MTASK_KERNEL_CFG) $(TINET_KERNEL_CFG)
    321         MTASK_DIR := $(MTASK_DIR):$(TINET_DIR)
     339        MTASK_DIR := $(MTASK_DIRS):$(TINET_DIRS)
    322340        MTASK_LCSRCS := $(MTASK_LCSRCS) $(TINET_LCSRCS)
    323341        MTASK_ASMOBJS := $(MTASK_ASMOBJS)
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ether_var.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.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 *
     
    6363#include <net/if_arp.h>
    6464#include <net/net.h>
     65#include <net/net_endian.h>
    6566#include <net/net_var.h>
    6667#include <net/net_buf.h>
     
    7172#include <netinet/in_var.h>
    7273#include <netinet/if_ether.h>
     74
    7375#include <netinet6/if6_ether.h>
    7476#include <netinet6/nd6.h>
    7577
    7678#include <net/if_var.h>
    77 #include <net/if6_var.h>
    7879
    7980#ifdef SUPPORT_ETHER
     
    8384 */
    8485
    85 #if defined(SUPPORT_INET4)
     86#if defined(_IP4_CFG)
    8687
    8788const uint8_t ether_broad_cast_addr[ETHER_ADDR_LEN] = {
     
    9091        };
    9192
    92 #endif  /* of #if defined(SUPPORT_INET4) */
     93#endif  /* of #if defined(_IP4_CFG) */
    9394
    9495/*
     
    9899/* ネットワークインタフェース構造体 */
    99100
    100 #if defined(SUPPORT_INET4)
    101 
    102 static T_IFNET ether_ifnet = {
    103         NULL,                   /* ネットワークインタフェースのソフトウェア情報       */
    104         {
    105                 IPV4_ADDR_LOCAL,        /* IPv4 アドレス            */
    106                 IPV4_ADDR_LOCAL_MASK,   /* サブネットマスク             */
    107                 },
    108         };
    109 
    110 #endif  /* of #if defined(SUPPORT_INET4) */
    111 
    112 #if defined(SUPPORT_INET6)
    113 
    114 static T_IFNET ether_ifnet = {
    115         NULL,                   /* ネットワークインタフェースのソフトウェア情報       */
    116         {0},                    /* IPv6 アドレス情報                          */
    117         {0},                    /* マルチキャスト IPv6 アドレス                    */
    118         0,                              /* フラグ                                  */
    119         };
    120 
    121 #endif  /* of #if defined(SUPPORT_INET6) */
     101static T_IFNET ether_ifnet;
    122102
    123103#ifdef SUPPORT_MIB
    124104
    125 /*
    126  *  SNMP の 管理情報ベース (MIB)
    127  */
     105/*  SNMP の 管理情報ベース (MIB) */
    128106
    129107T_IF_STATS if_stats;
     
    158136
    159137/*
     138 *  ether_srand -- 乱数を初期値を返す。
     139 */
     140
     141uint32_t
     142ether_srand (void)
     143{
     144        T_IF_SOFTC      *ic;
     145        uint32_t        rval;
     146
     147        ic = IF_ETHER_NIC_GET_SOFTC();
     148        rval  = (ic->ifaddr.lladdr[2] << 24)
     149              + (ic->ifaddr.lladdr[3] << 16)
     150              + (ic->ifaddr.lladdr[4] <<  8)
     151              + (ic->ifaddr.lladdr[5]      );
     152
     153#ifdef ETHER_CFG_COLLECT_ADDR
     154
     155        rval += (ether_collect_addr.lladdr[2] << 24)
     156              + (ether_collect_addr.lladdr[3] << 16)
     157              + (ether_collect_addr.lladdr[4] <<  8)
     158              + (ether_collect_addr.lladdr[5]      );
     159
     160#endif  /* of #ifdef ETHER_CFG_COLLECT_ADDR */
     161
     162        return rval;
     163        }
     164
     165/*
    160166 *  ether_get_ifnet -- ネットワークインタフェース構造体を返す。
    161167 */
     
    167173        }
    168174
    169 #if defined(SUPPORT_INET6)
     175#if defined(_IP6_CFG)
    170176
    171177/*
     
    174180
    175181ER
    176 ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr)
     182ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr)
    177183{
    178184        /* マルチキャストアドレスかチェックする。*/
     
    186192        }
    187193
    188 #endif  /* of #if defined(SUPPORT_INET6) */
     194#endif  /* of #if defined(_IP6_CFG) */
    189195
    190196/**
     
    203209      }
    204210#endif /* LWIP_ARP */
     211
     212#if LWIP_IGMP
     213      /* resend IGMP memberships */
     214      if (ether->_flags & IF_FLAG_IGMP) {
     215        igmp_report_groups(ether);
     216      }
     217#endif /* LWIP_IGMP */
    205218    }
    206219    if (ether->link_callback) {
     
    262275
    263276ER
    264 ether_output (T_NET_BUF *output, void *dst, T_IF_ADDR *gw, TMO tmout)
     277ether_output (T_NET_BUF *output, const void *dst, T_IF_ADDR *gw, TMO tmout)
    265278{
    266279        T_IF_SOFTC      *ic;
     
    275288        switch(ntohs(eth->type)) {
    276289
    277 #if defined(SUPPORT_INET4)
     290#if defined(_IP4_CFG)
    278291
    279292        case ETHER_TYPE_IP:             /* IPv4 */
     
    292305                break;
    293306
    294 #endif  /* of #if defined(SUPPORT_INET4) */
    295 
    296 #if defined(SUPPORT_INET6)
     307#endif  /* of #if defined(_IP4_CFG) */
     308
     309#if defined(_IP6_CFG)
    297310
    298311        case ETHER_TYPE_IPV6:           /* IPv6 */
    299                 error = nd6_storelladdr((T_ETHER_ADDR*)GET_ETHER_HDR(output)->dhost,
    300                                         (T_IN6_ADDR*)dst, gw);
     312                error = nd6_storelladdr((T_ETHER_ADDR*)eth->dhost,
     313                                        (const T_IN6_ADDR*)dst, gw);
    301314                if (error == E_OK)
    302315                        error = ether_raw_output(output, tmout);
     
    311324                break;
    312325
    313 #endif  /* of #if defined(SUPPORT_INET6) */
     326#endif  /* of #if defined(_IP6_CFG) */
    314327
    315328        default:
     
    398411        ID              tskid;
    399412        uint16_t        proto;
     413        uint8_t         rcount = 0;
    400414
    401415        /* ネットワークインタフェース管理を初期化する。*/
    402416        ifinit();
     417
     418        /* イーサネットネットワークインタフェース管理を初期化する。*/
     419
     420#if defined(_IP4_CFG)
     421
     422        ether_ifnet.in4_ifaddr.addr = IPV4_ADDR_LOCAL;          /* IPv4 アドレス            */
     423        ether_ifnet.in4_ifaddr.mask = IPV4_ADDR_LOCAL_MASK;     /* サブネットマスク             */
     424
     425#endif  /* of #if defined(_IP4_CFG) */
    403426
    404427        /* NIC を初期化する。*/
     
    418441                           tskid, mac2str(NULL, ic->ifaddr.lladdr));
    419442
    420 #if defined(SUPPORT_INET4)
     443#if defined(_IP4_CFG)
    421444
    422445        /* ARP を初期化する。*/
    423446        arp_init();
    424447
    425 #endif  /* of #if defined(SUPPORT_INET4) */
     448#endif  /* of #if defined(_IP4_CFG) */
    426449
    427450        ether_ifnet.ic = ic;
     451
     452        /* 乱数生成を初期化する。*/
     453        net_srand(0);
    428454
    429455        while (true) {
    430456                syscall(wai_sem(ic->semid_rxb_ready));
    431457                if ((input = IF_ETHER_NIC_READ(ic)) != NULL) {
    432                         NET_COUNT_ETHER(net_count_ether.in_octets, input->len);
     458                        NET_COUNT_ETHER(net_count_ether.in_octets,  input->len);
    433459                        NET_COUNT_MIB(if_stats.ifInOctets, input->len + 8);
    434460                        NET_COUNT_ETHER(net_count_ether.in_packets, 1);
     
    436462                        proto = ntohs(eth->type);
    437463
     464                        /* 乱数生成を初期化する。*/
     465                        if (rcount == 0) {
     466
     467#ifdef ETHER_CFG_COLLECT_ADDR
     468                                memcpy(ether_collect_addr.lladdr, eth->shost,
     469                                sizeof(ether_collect_addr.lladdr));
     470#endif  /* of #ifdef ETHER_CFG_COLLECT_ADDR */
     471
     472                                net_srand(0);
     473                                }
     474                        rcount ++;
     475
     476
    438477#ifdef SUPPORT_MIB
    439478                        if ((*eth->dhost & ETHER_MCAST_ADDR) == 0) {
     
    445484#endif  /* of #ifdef SUPPORT_MIB */
    446485
    447 #if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL)
     486#if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL)
    448487
    449488                        if ((*eth->dhost & ETHER_MCAST_ADDR) && *eth->dhost != 0xff) {
     
    464503                                }
    465504
    466 #endif  /* of #if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) */
     505#endif  /* of #if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL) */
    467506
    468507                        switch(proto) {
    469508
    470 #if defined(SUPPORT_INET4)
     509#if defined(_IP4_CFG)
    471510
    472511                        case ETHER_TYPE_IP:             /* IP   */
     
    478517                                break;
    479518
    480 #endif  /* of #if defined(SUPPORT_INET4) */
    481 
    482 #if defined(SUPPORT_INET6)
     519#endif  /* of #if defined(_IP4_CFG) */
     520
     521#if defined(_IP6_CFG)
    483522
    484523                        case ETHER_TYPE_IPV6:           /* IPv6 */
     
    486525                                break;
    487526
    488 #endif  /* of #if defined(SUPPORT_INET6) */
     527#endif  /* of #if defined(_IP6_CFG) */
    489528
    490529                        default:
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h

    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 *
     
    9898#endif  /* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
    9999
     100#if defined(__RX)
     101
     102#pragma pack
     103typedef struct t_ether_header {
     104
     105#if IF_ETHER_NIC_HDR_ALIGN != 0
     106
     107        uint8_t         align[IF_ETHER_NIC_HDR_ALIGN];  /* アライン調整 */
     108
     109#endif  /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
     110
     111        uint8_t         dhost[ETHER_ADDR_LEN];
     112        uint8_t         shost[ETHER_ADDR_LEN];
     113        uint16_t        type;
     114        } T_ETHER_HDR;
     115#pragma packoption
     116
     117#elif defined(TOPPERS_S810_CLG3_85)     /* of #if defined(__RX) */
     118
     119typedef struct t_ether_header {
     120
     121#if IF_ETHER_NIC_HDR_ALIGN != 0
     122
     123        uint8_t         align[IF_ETHER_NIC_HDR_ALIGN];  /* アライン調整 */
     124
     125#endif  /* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
     126
     127        uint8_t         dhost[ETHER_ADDR_LEN];
     128        uint8_t         shost[ETHER_ADDR_LEN];
     129        uint16_t        type;
     130        } T_ETHER_HDR;
     131
     132#else   /* of #if defined(__RX) */
     133
    100134typedef struct t_ether_header {
    101135
     
    111145        } __attribute__((packed, aligned(2)))T_ETHER_HDR;
    112146
     147#endif  /* of #if defined(__RX) */
     148
    113149#define GET_ETHER_HDR(nbuf)             ((T_ETHER_HDR*)((nbuf)->buf))
    114150
     
    140176#define IF_HDR_ALIGN            2                       /* ヘッダのアライン単位                           */
    141177#define IF_MTU                  1500                    /* インタフェースの MTU                         */
     178#define IF_MIN_LEN              ETHER_MIN_LEN           /* インターフェースフレームの最短長             */
    142179
    143180#define IF_OUTPUT(o,d,g,t)      ether_output(o,d,g,t)   /* インタフェースの出力関数                 */
     
    148185                                                        /* ソフトウェア情報から MAC アドレスを取り出す     */
    149186#define IF_GET_IFNET()          ether_get_ifnet()       /* ネットワークインタフェース構造体を返す。         */
    150 #define IF_TYPE                 IFT_ETHER               /* インターフェースの型                           */
     187#define IF_TYPE                 IFT_ETHER               /* インタフェースの型                            */
     188#define IF_SRAND()              ether_srand()   /* インタフェースの乱数初期値                        */
    151189
    152190/* IPv4 関係 */
    153191
    154 #define IF_PROTO_IP             ETHER_TYPE_IP           /* インタフェースの IP プロトコル指定          */
     192#define IF_PROTO_IP             ETHER_TYPE_IP           /* インタフェースの IPv4 プロトコル指定                */
    155193#define IF_PROTO_ARP            ETHER_TYPE_ARP          /* インタフェースの ARP プロトコル指定         */
    156194
     
    160198#define IF_MADDR_INIT           { { { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 } } }
    161199                                                        /* インタフェースのマルチキャストアドレス配列の初期化    */
    162 #define IF_PROTO_IPV6           ETHER_TYPE_IPV6         /* インタフェースの IP プロトコル指定                  */
     200#define IF_PROTO_IPV6           ETHER_TYPE_IPV6         /* インタフェースの IPv6 プロトコル指定                        */
    163201#define IF_ADDMULTI(s)          IF_ETHER_NIC_ADDMULTI(s)
    164202                                                        /* マルチキャストアドレスの登録                               */
     
    215253        T_IF_ADDR               ifaddr;                 /* ネットワークインタフェースのアドレス   */
    216254        uint16_t                timer;                  /* 送信タイムアウト                     */
    217         T_IF_ETHER_NIC_SOFTC    *sc;    /* ディバイス依存のソフトウェア情報     */
     255        T_IF_ETHER_NIC_SOFTC    *sc;                    /* ディバイス依存のソフトウェア情報     */
    218256        ID                      semid_txb_ready;        /* 送信セマフォ                               */
    219257        ID                      semid_rxb_ready;        /* 受信セマフォ                               */
    220258
    221 #ifdef SUPPORT_INET6
     259#ifdef _IP6_CFG
    222260
    223261        T_IF_ADDR       maddrs[MAX_IF_MADDR_CNT];       /* マルチキャストアドレスリスト       */
    224262
    225 #endif  /* of #ifdef SUPPORT_INET6 */
     263#endif  /* of #ifdef _IP6_CFG */
    226264        };
    227265
     
    231269#define IF_FLAG_LINK_UP                 0x10U
    232270
    233 #ifdef SUPPORT_INET6
     271/*
     272 *  変数
     273 */
     274
     275#ifdef ETHER_CFG_COLLECT_ADDR
     276
     277T_ETHER_ADDR ether_collect_addr;
     278
     279#endif  /* of #ifdef ETHER_CFG_COLLECT_ADDR */
     280
     281/*
     282 *  関数
     283 */
     284
     285#ifdef _IP6_CFG
    234286
    235287/* 前方参照 */
     
    243295#endif  /* of #ifndef T_IN6_ADDR_DEFINED */
    244296
    245 /*
    246  *  関数
    247  */
    248 
    249 extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr);
    250 
    251 #endif  /* of #ifdef SUPPORT_INET6 */
    252 
    253 /*
    254  *  関数
    255  */
     297extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr);
     298
     299#endif  /* of #ifdef _IP6_CFG */
    256300
    257301extern T_IFNET *ether_get_ifnet (void);
    258 extern ER ether_output (T_NET_BUF *data, void *dst, T_IF_ADDR *gw, TMO tmout);
     302extern ER ether_output (T_NET_BUF *data, const void *dst, T_IF_ADDR *gw, TMO tmout);
    259303extern ER ether_raw_output (T_NET_BUF *data, TMO tmout);
     304extern uint32_t ether_srand (void);
    260305
    261306/** Function prototype for netif status- or link-callback functions. */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.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 *
     
    8686
    8787#include <net/if.h>
     88#include <net/if_ppp.h>
     89#include <net/if_loop.h>
    8890#include <net/ethernet.h>
    8991#include <net/if_arp.h>
    9092#include <net/net.h>
     93#include <net/net_endian.h>
    9194#include <net/net_timer.h>
     95
     96#include <netinet/in.h>
     97#include <netinet/in_var.h>
    9298
    9399#include <netinet6/in6.h>
    94100#include <netinet6/in6_var.h>
    95101
    96 #include <net/if6_var.h>
     102#include <net/if_var.h>
    97103
    98104#ifdef SUPPORT_ETHER
     
    133139        }
    134140
    135 #ifdef SUPPORT_INET6
     141#endif /* of #ifdef SUPPORT_ETHER */
     142
     143#ifdef _IP6_CFG
    136144
    137145/*
     
    142150if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type)
    143151{
     152#if MAX_IF_MADDR_CNT > 0
     153
    144154        T_IF_ADDR       llmaddr;
    145155        ER              error = E_OK;
     
    152162
    153163                /* IPv6 マルチキャストアドレスを登録する。*/
    154                 ifp->in_maddrs[ix] = *(T_IN6_ADDR*)maddr;
     164                ifp->in6_maddrs[ix] = *(T_IN6_ADDR*)maddr;
    155165
    156166                /* インタフェースのアドレスに変換し、登録する。*/
     
    162172
    163173        return IF_ADDMULTI(ifp->ic);
     174
     175#else   /* of #if MAX_IF_MADDR_CNT > 0 */
     176
     177        return E_OK;
     178
     179#endif  /* of #if MAX_IF_MADDR_CNT > 0 */
    164180        }
    165181
    166 #endif  /* of #ifdef SUPPORT_INET6 */
    167 
    168 #endif /* of #ifdef SUPPORT_ETHER */
     182#endif  /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if6_var.h

    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 *
     
    6868#define _IF6_VAR_H_
    6969
    70 #ifdef SUPPORT_INET6
    71 
    7270/*
    7371 *  ネットワークインタフェース構造体
    7472 */
    7573
     74#if defined(_IP6_CFG)
     75
     76#if defined(_IP4_CFG)
     77
    7678struct t_ifnet {
    7779        T_IF_SOFTC      *ic;            /* ネットワークインタフェースのソフトウェア情報       */
    78         T_IN6_IFADDR    in_ifaddrs[NUM_IN6_IFADDR_ENTRY];
     80        T_IN6_IFADDR    in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
    7981                                        /* IPv6 アドレス情報                          */
    80         T_IN6_ADDR      in_maddrs [MAX_IN6_MADDR_CNT];
     82        T_IN6_ADDR      in6_maddrs [MAX_IN6_MADDR_CNT];
    8183                                        /* マルチキャスト IPv6 アドレス                    */
     84        T_IN4_IFADDR    in4_ifaddr;     /* IPv4 アドレス情報                          */
     85        ether_status_callback_fn link_callback;
    8286        uint8_t         flags;          /* フラグ                                  */
    8387        };
     88
     89#else   /* of #if defined(_IP4_CFG) */
     90
     91struct t_ifnet {
     92        T_IF_SOFTC      *ic;            /* ネットワークインタフェースのソフトウェア情報       */
     93        T_IN6_IFADDR    in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
     94                                        /* IPv6 アドレス情報                          */
     95        T_IN6_ADDR      in6_maddrs [MAX_IN6_MADDR_CNT];
     96                                        /* マルチキャスト IPv6 アドレス                    */
     97        ether_status_callback_fn link_callback;
     98        uint8_t         flags;          /* フラグ                                  */
     99        };
     100
     101#endif  /* of #if defined(_IP4_CFG) */
     102
     103#else   /* of #if defined(_IP6_CFG) */
     104
     105#if defined(_IP4_CFG)
     106
     107struct t_ifnet {
     108        T_IF_SOFTC      *ic;            /* ネットワークインタフェースのソフトウェア情報       */
     109        T_IN4_IFADDR    in4_ifaddr;     /* IPv4 アドレス情報                          */
     110        ether_status_callback_fn link_callback;
     111        uint8_t         flags;          /* フラグ                                  */
     112        };
     113
     114#endif  /* of #if defined(_IP4_CFG) */
     115
     116#endif  /* of #if defined(_IP6_CFG) */
    84117
    85118#ifndef T_IFNET_DEFINED
     
    90123
    91124#endif  /* of #ifndef T_IFNET_DEFINED */
     125
     126#if defined(_IP6_CFG)
    92127
    93128/*
     
    103138extern ER if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type);
    104139
    105 #endif  /* of #ifdef SUPPORT_INET6 */
     140#endif  /* of #if defined(_IP6_CFG) */
    106141
    107142#endif  /* of #ifndef _IF6_VAR_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_llc.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.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 *
     
    9191#include <net/if_loop.h>
    9292#include <net/net.h>
     93#include <net/net_endian.h>
    9394#include <net/net_buf.h>
    9495#include <net/net_count.h>
     
    9899#include <netinet/ip.h>
    99100#include <netinet/ip_var.h>
    100 #include <netinet/ip6.h>
    101 #include <netinet6/ip6_var.h>
    102101#include <netinet/tcp.h>
    103102#include <netinet/udp.h>
    104103
    105104#include <net/if_var.h>
    106 #include <net/if6_var.h>
    107105
    108106#ifdef SUPPORT_LOOP
     
    124122/* ネットワークインタフェース構造体 */
    125123
    126 #if defined(SUPPORT_INET4)
     124#if defined(_IP6_CFG)
     125
     126static T_IFNET loop_ifnet = {
     127        NULL,                   /* ネットワークインタフェースのソフトウェア情報       */
     128        {},                     /* IPv6 アドレス情報                          */
     129        {},                     /* マルチキャスト IPv6 アドレス                    */
     130        };
     131
     132#elif defined(_IP4_CFG) /* of #if defined(_IP6_CFG) */
    127133
    128134static T_IFNET loop_ifnet = {
     
    134140        };
    135141
    136 #endif  /* of #if defined(SUPPORT_INET4) */
    137 
    138 #if defined(SUPPORT_INET6)
    139 
    140 static T_IFNET loop_ifnet = {
    141         NULL,                   /* ネットワークインタフェースのソフトウェア情報       */
    142         {},                     /* IPv6 アドレス情報                          */
    143         {},                     /* マルチキャスト IPv6 アドレス                    */
    144         };
    145 
    146 #endif  /* of #if defined(SUPPORT_INET6) */
     142#endif  /* of #if defined(_IP6_CFG) */
    147143
    148144/*
     
    213209                        NET_COUNT_LOOP(net_count_loop.in_packets, 1);
    214210
    215 #if defined(SUPPORT_INET4)
     211#if defined(_IP4_CFG)
    216212
    217213                        /* IPv4 入力関数を呼び出す */
     
    219215                                ip_input(input);
    220216
    221 #endif  /* of #if defined(SUPPORT_INET4) */
    222 
    223 #if defined(SUPPORT_INET6)
     217#endif  /* of #if defined(_IP4_CFG) */
     218
     219#if defined(_IP6_CFG)
    224220
    225221                        /* IPv6 入力関数を呼び出す */
     
    227223                                ip6_input(input);
    228224
    229 #endif  /* of #if defined(SUPPORT_INET6) */
     225#endif  /* of #if defined(_IP6_CFG) */
    230226
    231227                        }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.h

    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 *
     
    9191#define IF_SET_PROTO(b,p)                               /* インタフェースのプロトコル設定関数    */
    9292#define IF_GET_IFNET()          loop_get_ifnet()        /* ネットワークインタフェース構造体を返す。         */
     93#define IF_SRAND()              (0)                     /* インターフェースの乱数初期値                       */
    9394
    9495/* IPv4 関係 */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_ppp.h

    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 *
     
    5959
    6060/*
     61 *  PPP アドレスの定義(ダミー)
     62 */
     63
     64typedef struct t_ppp_addr {
     65        uint8_t         lladdr[0];
     66        } T_PPP_ADDR;
     67
     68/*
    6169 *  インタフェースの選択マクロ
    6270 */
    6371
    64 #define T_IF_HDR                T_PPP_HDR       /* インタフェースのヘッダ                  */
    65 #define IF_HDR_ALIGN            2               /* ヘッダのアライン単位                   */
    66 #define IF_MTU                  DEF_PPP_MTU     /* インタフェースの MTU                 */
    67                                                 /* インタフェースの IPv4 アドレス           */
    68 #define IF_PROTO_IP             PPP_IP          /* インタフェースの IP プロトコル指定  */
     72#define T_IF_HDR                T_PPP_HDR               /* インタフェースのヘッダ          */
     73#define T_IF_ADDR               T_PPP_ADDR              /* インタフェースのアドレス                 */
     74#define IF_HDR_ALIGN            2                       /* ヘッダのアライン単位                   */
     75#define IF_MTU                  DEF_PPP_MTU             /* インタフェースの MTU                 */
    6976
    7077#define IF_OUTPUT(o,d,g,t)      ppp_output(o,t)         /* インタフェースの出力関数         */
    7178#define IF_RAW_OUTPUT(o,t)      ppp_output(o,t)         /* インタフェースの出力関数、アドレス解決無し*/
     79#define IF_SET_PROTO(b,p)       (*GET_PPP_HDR(b) = htons(p))
    7280                                                        /* インタフェースのプロトコル設定関数    */
    73 #define IF_SET_PROTO(b,p)       (*GET_PPP_HDR(b) = htons(p))
    74 #define IF_GET_IFNET()          ppp_get_ifnet()         /* ネットワークインタフェース構造体を返す。         */
     81#define IF_SOFTC_TO_IFADDR(s)   ((T_IF_ADDR*)(s)->ifaddr.lladdr)
     82                                                        /* ソフトウェア情報から PPP アドレスを取り出す     */
     83#define IF_GET_IFNET()          ppp_get_ifnet()         /* ネットワークインタフェース構造体を返す。*/
     84#define IF_SRAND()              (0)                     /* インターフェースの乱数初期値                       */
     85
     86/* IPv4 関係 */
     87
     88#define IF_PROTO_IP             PPP_IP                  /* インタフェースの IPv4 プロトコル指定        */
     89
     90/* IPv6 関係 */
     91
     92#define MAX_IF_MADDR_CNT        0                       /* インタフェースのマルチキャストアドレス配列の最大サイズ*/
     93#define IF_PROTO_IPV6           PPP_IPV6                /* インタフェースの IPv6 プロトコル指定        */
     94#define IF_IN6_NEED_CACHE(i)    (false)                 /* 近隣探索キャッシュを使用する。      */
     95#define IF_IN6_IFID(i,a)        get_rand_ifid(i,a)      /* インタフェース識別子の設定                */
     96#define IF_IN6_RESOLVE_MULTICAST(i,m)   {}              /* インタフェースのマルチキャストアドレスへの変換              */
    7597
    7698/*
     
    120142 */
    121143
    122 struct t_if_softc { };
     144struct t_if_softc {
     145        T_IF_ADDR       ifaddr;         /* ネットワークインタフェースのアドレス   */
     146        };
    123147
    124148/*
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_types.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_var.h

    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 *
     
    6868#define _IF_VAR_H_
    6969
    70 #if defined(SUPPORT_INET4)
    71 
    72 /*
    73  *  ネットワークインタフェース構造体
    74  */
    75 
    76 struct t_ifnet {
    77         T_IF_SOFTC      *ic;            /* ネットワークインタフェースのソフトウェア情報       */
    78         T_IN4_IFADDR    in_ifaddr;      /* IPv4 アドレス情報                          */
    79         ether_status_callback_fn link_callback;
    80         uint8_t         flags;          /* フラグ                                  */
    81         };
    82 
    83 #ifndef T_IFNET_DEFINED
    84 
    85 typedef struct t_ifnet T_IFNET;
    86 
    87 #define T_IFNET_DEFINED
    88 
    89 #endif  /* of #ifndef T_IFNET_DEFINED */
    90 
    91 #endif  /* of #if defined(SUPPORT_INET4) */
     70#include <net/if6_var.h>
    9271
    9372#ifdef SUPPORT_MIB
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.cfg

    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 *
     
    4141
    4242CRE_TSK(NET_TIMER_TASK, {
    43                 TA_NULL,
     43                TA_HLNG,
    4444                0,
    4545                net_timer_task,
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.h

    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 *
     
    6969
    7070/*
    71  *  バイトオーダの定義
    72  */
    73 
    74 #define _NET_CFG_LITTLE_ENDIAN  1234
    75 #define _NET_CFG_BIG_ENDIAN     4321
    76 
    77 #ifdef TARGET_KERNEL_ASP
    78 
    79 #if defined(SIL_ENDIAN_LITTLE)
    80 
    81 #define _NET_CFG_BYTE_ORDER     _NET_CFG_LITTLE_ENDIAN
    82 
    83 #elif defined(SIL_ENDIAN_BIG)
    84 
    85 #define _NET_CFG_BYTE_ORDER     _NET_CFG_BIG_ENDIAN
    86 
    87 #else   /* of #if defined(SIL_ENDIAN_BIG) */
    88 
    89 #error "SIL_ENDIAN expected."
    90 
    91 #endif  /* of #if defined(SIL_ENDIAN_BIG) */
    92 
    93 #endif  /* of #ifdef TARGET_KERNEL_ASP */
    94 
    95 #ifdef TARGET_KERNEL_JSP
    96 
    97 #if SIL_ENDIAN == SIL_ENDIAN_LITTLE
    98 
    99 #define _NET_CFG_BYTE_ORDER     _NET_CFG_LITTLE_ENDIAN
    100 
    101 #elif SIL_ENDIAN == SIL_ENDIAN_BIG      /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
    102 
    103 #define _NET_CFG_BYTE_ORDER     _NET_CFG_BIG_ENDIAN
    104 
    105 #else   /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
    106 
    107 #error "SIL_ENDIAN expected."
    108 
    109 #endif  /* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
    110 
    111 #endif  /* of #ifdef TARGET_KERNEL_JSP */
    112 
    113 /*
    114  *  バイトオーダ変換の定義
    115  */
    116 
    117 #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
    118 
    119 #define ntohs(n)                ((uint16_t)n)
    120 #define htons(h)                ((uint16_t)h)
    121 #define ntohl(n)                ((uint32_t)n)
    122 #define htonl(h)                ((uint32_t)h)
    123 
    124 #define NTOHS(n)
    125 #define HTONS(h)
    126 #define NTOHL(n)
    127 #define HTONL(h)
    128 
    129 /*
    130  *  注意: IPヘッダ以降は、4 バイト境界にアラインされている事を
    131  *        前提としているが、4 バイト境界でアクセスする
    132  *        プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン
    133  *        されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。
    134  */
    135 
    136 #define ntoahl(h,n)             memcpy((uint8_t*)&(h),(n),4)
    137 #define ahtonl(n,h)             memcpy((n),(uint8_t*)&(h),4)
    138 
    139 #define nahcmpl(n,h)            memcmp((n),(uint8_t*)&(h),4)
    140 
    141 #elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
    142 
    143 #ifndef NET_REV_ENDIAN_HWORD
    144 
    145 #define NET_REV_ENDIAN_HWORD(d) ((uint16_t)((((uint16_t)(d)&0xff)<<8)|(((uint16_t)(d)>>8)&0xff)))
    146 
    147 #endif  /* of #ifndef NET_REV_ENDIAN_HWORD */
    148 
    149 #ifndef NET_REV_ENDIAN_WORD
    150 
    151 #define NET_REV_ENDIAN_WORD(d)  ((uint32_t)((((uint32_t)(d)&0xff)<<24)|(((uint32_t)(d)&0xff00)<<8)| \
    152                                             (((uint32_t)(d)>>8)&0xff00)|(((uint32_t)(d)>>24)&0xff)))
    153 
    154 #endif  /* of #ifndef NET_REV_ENDIAN_WORD */
    155 
    156 #define ntohs(n)                NET_REV_ENDIAN_HWORD(n)
    157 #define htons(h)                NET_REV_ENDIAN_HWORD(h)
    158 #define ntohl(n)                NET_REV_ENDIAN_WORD(n)
    159 #define htonl(h)                NET_REV_ENDIAN_WORD(h)
    160 
    161 #define NTOHS(n)                ((n)=NET_REV_ENDIAN_HWORD(n))
    162 #define HTONS(h)                ((h)=NET_REV_ENDIAN_HWORD(h))
    163 #define NTOHL(n)                ((n)=NET_REV_ENDIAN_WORD(n))
    164 #define HTONL(h)                ((h)=NET_REV_ENDIAN_WORD(h))
    165 
    166 /*
    167  *  注意: IPヘッダ以降は、4 バイト境界にアラインされている事を
    168  *        前提としているが、4 バイト境界でアクセスする
    169  *        プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン
    170  *        されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。
    171  */
    172 
    173 #ifndef _MACRO_ONLY
    174 
    175 extern void rev_memcpy_word (uint8_t *dst, uint8_t *src);
    176 extern int  rev_memcmp_word (uint8_t *data1, uint8_t *data2);
    177 
    178 #endif  /* of #ifndef _MACRO_ONLY */
    179 
    180 #define ntoahl(h,n)             rev_memcpy_word((uint8_t*)&(h),(n))
    181 #define ahtonl(n,h)             rev_memcpy_word((n),(uint8_t*)&(h))
    182 #define nahcmpl(n,h)            rev_memcmp_word((n),(uint8_t*)&(h))
    183 
    184 #else   /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
    185 
    186 #error "_NET_CFG_BYTE_ORDER expected."
    187 
    188 #endif  /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
    189 
    190 /*
    19171 *  プロトコルを識別するフラグに関する定義
    19272 *
     
    19979#define PROTO_FLG_PPP_LCP       ULONG_C(0x00000008)     /* ppp_lcp.c    */
    20080#define PROTO_FLG_PPP_IPCP      ULONG_C(0x00000010)     /* ppp_ipcp.c   */
    201 #define PROTO_FLG_PPP_CCP       ULONG_C(0x00000020)     /* ppp_ccp.c    */
    202 #define PROTO_FLG_PPP_PAP       ULONG_C(0x00000040)     /* ppp_upap.c   */
    203 #define PROTO_FLG_PPP_MODEM     ULONG_C(0x00000080)     /* ppp_modem.c  */
    204 #define PROTO_FLG_PPP           ULONG_C(0x00000100)     /* ppp.c        */
     81#define PROTO_FLG_PPP_IPV6CP    ULONG_C(0x00000020)     /* ppp_ipv6cp.c */
     82#define PROTO_FLG_PPP_CCP       ULONG_C(0x00000040)     /* ppp_ccp.c    */
     83#define PROTO_FLG_PPP_PAP       ULONG_C(0x00000080)     /* ppp_upap.c   */
     84#define PROTO_FLG_PPP_MODEM     ULONG_C(0x00000100)     /* ppp_modem.c  */
     85#define PROTO_FLG_PPP           ULONG_C(0x00000200)     /* ppp.c        */
    20586
    20687#define PROTO_FLG_ETHER_NIC     ULONG_C(0x00000001)     /* if_??.c      */
     
    21697#define PROTO_FLG_IP4           ULONG_C(0x00010000)     /* ip_*.c       */
    21798#define PROTO_FLG_ICMP4         ULONG_C(0x00040000)     /* ip_icmp.c    */
     99#define PROTO_FLG_IGMP          ULONG_C(0x00080000)     /* ip_igmp.c    */
    218100
    219101#define PROTO_FLG_IP6           ULONG_C(0x00100000)     /* ip6_*.c      */
     
    236118#define AT_INET6                UINT_C(0x20)            /* IPv6 アドレス    */
    237119
     120/*
     121 *  IPv4 UDPオプションの定義
     122 */
     123
     124#define IP_MULTICAST_IF    32
     125#define IP_MULTICAST_TTL   33
     126#define IP_MULTICAST_LOOP  34
     127#define IP_ADD_MEMBERSHIP  35
     128#define IP_DROP_MEMBERSHIP 36
     129#define IP_MSFILTER        41
     130
    238131#if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
    239132
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg

    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 *
     
    5050                TA_TFIFO,
    5151                NUM_MPF_NET_BUF_CSEG,
    52                 sizeof(T_NET_BUF_CSEG)
     52                sizeof(T_NET_BUF_CSEG),
     53                NULL,
     54                NULL
    5355                });
    5456#endif  /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
     
    5759CRE_MPF(MPF_NET_BUF_64, {
    5860                TA_TFIFO, NUM_MPF_NET_BUF_64,
    59                 sizeof(T_NET_BUF_64)
     61                sizeof(T_NET_BUF_64),
     62                NULL,
     63                NULL
    6064                });
    6165#endif  /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
     
    6569                TA_TFIFO,
    6670                NUM_MPF_NET_BUF_128,
    67                 sizeof(T_NET_BUF_128)
     71                sizeof(T_NET_BUF_128),
     72                NULL,
     73                NULL
    6874                });
    6975#endif  /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
     
    7379                TA_TFIFO,
    7480                NUM_MPF_NET_BUF_256,
    75                 sizeof(T_NET_BUF_256)
     81                sizeof(T_NET_BUF_256),
     82                NULL,
     83                NULL
    7684                });
    7785#endif  /* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */
     
    8189                TA_TFIFO,
    8290                NUM_MPF_NET_BUF_512,
    83                 sizeof(T_NET_BUF_512)
     91                sizeof(T_NET_BUF_512),
     92                NULL,
     93                NULL
    8494                });
    8595#endif  /* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */
     
    8999                TA_TFIFO,
    90100                NUM_MPF_NET_BUF_IP_MSS,
    91                 sizeof(T_NET_BUF_IP_MSS)
     101                sizeof(T_NET_BUF_IP_MSS),
     102                NULL,
     103                NULL
    92104                });
    93105#endif  /* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */
     
    97109                TA_TFIFO,
    98110                NUM_MPF_NET_BUF_1024,
    99                 sizeof(T_NET_BUF_1024)
     111                sizeof(T_NET_BUF_1024),
     112                NULL,
     113                NULL
    100114                });
    101115#endif  /* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */
     
    105119                TA_TFIFO,
    106120                NUM_MPF_NET_BUF_IPV6_MMTU,
    107                 sizeof(T_NET_BUF_IPV6_MMTU)
     121                sizeof(T_NET_BUF_IPV6_MMTU),
     122                NULL,
     123                NULL
    108124                });
    109125#endif  /* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */
     
    113129                TA_TFIFO,
    114130                NUM_MPF_NET_BUF_IF_PDU,
    115                 sizeof(T_NET_BUF_IF_PDU)
     131                sizeof(T_NET_BUF_IF_PDU),
     132                NULL,
     133                NULL
    116134                });
    117135#endif  /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
    118136
     137#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
     138
     139CRE_MPF(MPF_NET_BUF_REASSM, {
     140                TA_TFIFO,
     141                NUM_MPF_NET_BUF6_REASSM,
     142                sizeof(T_NET_BUF6_REASSM),
     143                NULL,
     144                NULL
     145                });
     146
     147#else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
     148
    119149#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
     150
    120151CRE_MPF(MPF_NET_BUF_REASSM, {
    121152                TA_TFIFO,
    122153                NUM_MPF_NET_BUF4_REASSM,
    123                 sizeof(T_NET_BUF4_REASSM)
     154                sizeof(T_NET_BUF4_REASSM),
     155                NULL,
     156                NULL
    124157                });
    125158#endif  /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
    126159
    127 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
    128 CRE_MPF(MPF_NET_BUF_REASSM, {
    129                 TA_TFIFO,
    130                 NUM_MPF_NET_BUF6_REASSM,
    131                 sizeof(T_NET_BUF6_REASSM)
    132                 });
    133160#endif  /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
    134161
     
    137164                TA_TFIFO,
    138165                NUM_MPF_NET_BUF6_65536,
    139                 sizeof(T_NET_BUF6_65536)
     166                sizeof(T_NET_BUF6_65536),
     167                NULL,
     168                NULL
    140169                });
    141170#endif  /* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.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 *
     
    5757#include <net/ethernet.h>
    5858#include <net/net.h>
     59#include <net/net_endian.h>
    5960#include <net/net_buf.h>
    6061#include <net/net_count.h>
     
    6263#include <netinet/in.h>
    6364#include <netinet/in_var.h>
    64 #include <netinet6/in6.h>
    6565#include <netinet/ip.h>
    6666#include <netinet/ip_var.h>
    67 #include <netinet/ip6.h>
    68 #include <netinet6/ip6_var.h>
    6967#include <netinet/tcp.h>
    70 #include <netinet/tcp_timer.h>
    7168#include <netinet/tcp_var.h>
    7269
     
    9895
    9996#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
     97
    10098        {
    10199                MPF_NET_BUF_REASSM,
     
    109107
    110108                },
    111 #endif  /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
     109
     110#else   /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
    112111
    113112#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
     113
    114114        {
    115115                MPF_NET_BUF_REASSM,
     
    123123
    124124                },
     125
    125126#endif  /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
     127
     128#endif  /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
    126129
    127130#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
     
    223226#endif  /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
    224227
    225 #if defined(SUPPORT_INET4)
     228#if defined(_IP4_CFG)
    226229
    227230#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
     
    239242#endif  /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
    240243
    241 #endif  /* of #if defined(SUPPORT_INET4) */
     244#endif  /* of #if defined(_IP4_CFG) */
    242245
    243246#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
     
    308311                        (*buf)->len   = (uint16_t)minlen;
    309312                        (*buf)->flags = 0;
     313
     314#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    310315                        NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
     316                        net_buf_table[ix].busies ++;
     317#endif
    311318                        return error;
    312319                        }
     
    316323                }
    317324
    318         syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, minlen);
     325        syslog(LOG_WARNING, "[BUF] busy, up   index:%d,%d[%4d], len:%4d.",
     326                            (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
    319327        *buf = NULL;
    320328        NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
     
    346354                        (*buf)->len   = net_buf_table[ix].size;
    347355                        (*buf)->flags = 0;
     356
     357#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    348358                        NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
     359                        net_buf_table[ix].busies ++;
     360#endif
    349361                        return error;
    350362                        }
     
    354366                }
    355367
    356         syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, maxlen);
     368        syslog(LOG_WARNING, "[BUF] busy, down index:%d,%d[%4d], len:%4d.",
     369                            (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
    357370        *buf = NULL;
    358371        NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
     
    380393                }
    381394
     395#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
     396
    382397        /* TCP で予約したネットワークバッファを取り出す。*/
    383398        if ((nbatr & NBA_RESERVE_TCP) != 0) {
     
    386401                        }
    387402                }
     403
     404#endif  /* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
    388405
    389406        if ((nbatr & NBA_SEARCH_DESCENT) != 0)
     
    423440        else {
    424441
     442#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
     443
    425444                /* TCP で、ネットワークバッファを予約する。*/
    426445                if (TCP_PUSH_RES_NBUF(buf) == NULL)
    427446                        return E_OK;
    428447
     448#endif  /* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
     449
    429450                /* 固定メモリプールに返す。*/
    430                 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK)
     451
     452#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     453                net_buf_table[buf->idix].busies --;
     454#endif
     455                if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
    431456                        syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
     457                        }
    432458                }
    433459        return error;
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h

    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 *
     
    6161        uint8_t         halign[4 - IF_HDR_ALIGN];
    6262#endif
    63         uint8_t         buf[4]; /* バッファ本体               */
     63        uint8_t         buf[IF_MIN_LEN];        /* バッファ本体 */
    6464        };
    6565
     
    7171
    7272#endif  /* of #ifndef T_NET_BUF_DEFINED */
     73
    7374/*
    7475 *  64 オクテット
     
    159160 *  ネットワークインタフェースの最大 PDU サイズ
    160161 */
     162
     163#if defined(IF_PDU_SIZE)
    161164
    162165typedef struct t_net_buf_if_pdu {
     
    177180        } T_NET_BUF_IF_PDU;
    178181
     182#endif  /* of #if defined(IF_PDU_SIZE) */
     183
    179184/*
    180185 *  ネットワークバッファ表
     
    189194
    190195        ulong_t         prepares;
     196        ulong_t         busies;
    191197        ulong_t         requests;
    192198        ulong_t         allocs;
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.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 *
     
    120120
    121121#include <net/net.h>
     122#include <net/net_endian.h>
    122123#include <net/net_count.h>
    123124
     
    142143#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
    143144
     145#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
     146
     147T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets;
     148T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets;
     149
     150#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
     151
    144152#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP
    145153
     
    190198#endif  /* of #ifdef SUPPORT_ETHER */
    191199
    192 #if defined(SUPPORT_INET4)
     200#if defined(_IP4_CFG)
    193201
    194202#if NET_COUNT_ENABLE & PROTO_FLG_ARP
     
    210218#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
    211219
    212 #endif  /* of #if defined(SUPPORT_INET4) */
    213 
    214 #if defined(SUPPORT_INET6)
     220#if NET_COUNT_ENABLE & PROTO_FLG_IGMP
     221
     222T_NET_COUNT     net_count_igmp;
     223
     224#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
     225
     226#endif  /* of #if defined(_IP4_CFG) */
     227
     228#if defined(_IP6_CFG)
    215229
    216230#if NET_COUNT_ENABLE & PROTO_FLG_IP6
     
    232246#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
    233247
    234 #endif  /* of #if defined(SUPPORT_INET6) */
     248#endif  /* of #if defined(_IP6_CFG) */
    235249
    236250#ifdef SUPPORT_TCP
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.h

    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 *
     
    155155#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
    156156
     157/* PPP IPV6CP */
     158
     159#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
     160
     161#define NET_COUNT_PPP_IPV6CP(v,c)       ((v)+=(c))
     162
     163#ifndef _MACRO_ONLY
     164
     165extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets;
     166extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets;
     167
     168#endif  /* of #ifndef _MACRO_ONLY */
     169
     170#else   /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
     171
     172#define NET_COUNT_PPP_IPV6CP(v,c)
     173
     174#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
     175
    157176/* PPP IPCP */
    158177
     
    302321#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
    303322
    304 #if defined(SUPPORT_INET4)
     323#if defined(_IP4_CFG)
    305324
    306325/* ARP */
     
    380399#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
    381400
    382 #endif  /* of #if defined(SUPPORT_INET4) */
    383 
    384 #if defined(SUPPORT_INET6)
     401/* IGMP */
     402
     403#if NET_COUNT_ENABLE & PROTO_FLG_IGMP
     404
     405#define NET_COUNT_IGMP(v,c)     ((v)+=(c))
     406
     407#ifndef _MACRO_ONLY
     408
     409extern T_NET_COUNT      net_count_igmp;
     410
     411#endif  /* of #ifndef _MACRO_ONLY */
     412
     413#else   /* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */
     414
     415#define NET_COUNT_IGMP(v,c)
     416
     417#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */
     418
     419#endif  /* of #if defined(_IP4_CFG) */
     420
     421#if defined(_IP6_CFG)
    385422
    386423/* IPv6 */
     
    472509#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
    473510
    474 #endif  /* of #if defined(SUPPORT_INET6) */
     511#endif  /* of #if defined(_IP6_CFG) */
    475512
    476513#ifdef SUPPORT_TCP
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_jsp.cfg

    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 *
     
    127127#endif  /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
    128128
     129#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
     130
     131CRE_MPF(MPF_NET_BUF_REASSM, {
     132                TA_TFIFO,
     133                NUM_MPF_NET_BUF6_REASSM,
     134                sizeof(T_NET_BUF6_REASSM),
     135                NULL
     136                });
     137
     138#else   /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
     139
    129140#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
     141
    130142CRE_MPF(MPF_NET_BUF_REASSM, {
    131143                TA_TFIFO,
     
    134146                NULL
    135147                });
     148
    136149#endif  /* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
    137150
    138 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
    139 CRE_MPF(MPF_NET_BUF_REASSM, {
    140                 TA_TFIFO,
    141                 NUM_MPF_NET_BUF6_REASSM,
    142                 sizeof(T_NET_BUF6_REASSM),
    143                 NULL
    144                 });
    145151#endif  /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
    146152
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h

    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 *
     
    4141/* net/ethernet.c */
    4242
     43#define ether_input_task        _tinet_ether_input_task
     44#define ether_get_ifnet         _tinet_ether_get_ifnet
     45#define ether_in6_resolve_multicast     \
     46                                _tinet_ether_in6_resolve_multicast
     47#define ether_srand             _tinet_ether_srand
     48#define ether_output            _tinet_ether_output
     49#define ether_raw_output        _tinet_ether_raw_output
     50#define ether_output_task       _tinet_ether_output_task
     51
    4352#define ether_broad_cast_addr   _tinet_ether_broad_cast_addr
    4453#define ether_ipv4_addr_local   _tinet_ether_ipv4_addr_local
     
    4655                                _tinet_ether_ipv4_addr_local_mask
    4756
    48 #define ether_raw_output        _tinet_ether_raw_output
    49 #define ether_output            _tinet_ether_output
    5057#define ether_in6_ifaddr        _tinet_ether_in6_ifaddr
    5158#define ether_in6_ifaddr_list   _tinet_ether_in6_ifaddr_list
    52 #define ether_in6_resolve_multicast     \
    53                                 _tinet_ether_in6_resolve_multicast
    54 #define ether_input_task        _tinet_ether_input_task
    55 #define ether_get_ifnet         _tinet_ether_get_ifnet
    56 #define ether_output_task       _tinet_ether_output_task
    5759
    5860/* net/if.c */
     
    9395/* route_cfg.c */
    9496
    95 #define routing_tbl             _tinet_routing_tbl
     97#define routing6_tbl            _tinet_routing6_tbl
     98#define routing4_tbl            _tinet_routing4_tbl
    9699
    97100#ifdef SUPPORT_PPP
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.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 *
     
    8888#include <tinet_config.h>
    8989
     90#include <net/if.h>
     91#include <net/if_loop.h>
     92#include <net/if_ppp.h>
     93#include <net/ethernet.h>
    9094#include <net/net.h>
     95#include <net/net_endian.h>
    9196
    9297/*
     
    103108net_rand (void)
    104109{
    105         next = (next * 1103515245 + 12345) % (ULONG_C(0x7fffffff) + 1);
     110        next = (next * 99991 + 12345) & ULONG_C(0x7fffffff);
    106111        return next;
    107112        }
     
    114119net_srand (uint32_t seed)
    115120{
    116         next += seed;
     121        SYSTIM now;
     122
     123        syscall(get_tim(&now));
     124        next += now + seed + IF_SRAND();
    117125        }
    118126
     
    186194
    187195/*
    188  *  rev_memcpy_word -- 反転メモリコピー(4 バイト)
     196 *  rev_memcpy_hword -- 反転メモリコピー(2 バイト)
    189197 *
    190198 *    バイト単位にアクセスする事により、
     
    193201
    194202void
    195 rev_memcpy_word (uint8_t *dst, uint8_t *src)
    196 {
    197         *(dst    ) = *(src + 3);
    198         *(dst + 1) = *(src + 2);
    199         *(dst + 2) = *(src + 1);
    200         *(dst + 3) = *(src    );
    201         }
    202 
    203 /*
    204  *  rev_memcmp_word -- 反転メモリ比較(4 バイト)
     203rev_memcpy_hword (void *dst, void *src)
     204{
     205        *((uint8_t*)dst    ) = *((uint8_t*)src + 1);
     206        *((uint8_t*)dst + 1) = *((uint8_t*)src    );
     207        }
     208
     209/*
     210 *  rev_memcpy_word -- 反転メモリコピー(4 バイト)
    205211 *
    206212 *    バイト単位にアクセスする事により、
     
    208214 */
    209215
     216void
     217rev_memcpy_word (void *dst, void *src)
     218{
     219        *((uint8_t*)dst    ) = *((uint8_t*)src + 3);
     220        *((uint8_t*)dst + 1) = *((uint8_t*)src + 2);
     221        *((uint8_t*)dst + 2) = *((uint8_t*)src + 1);
     222        *((uint8_t*)dst + 3) = *((uint8_t*)src    );
     223        }
     224
     225/*
     226 *  rev_memcmp_word -- 反転メモリ比較(4 バイト)
     227 *
     228 *    バイト単位にアクセスする事により、
     229 *    境界へのアラインの問題を解決する。
     230 */
     231
    210232int_t
    211 rev_memcmp_word (uint8_t *data1, uint8_t *data2)
     233rev_memcmp_word (void *data1, void *data2)
    212234{
    213235        int_t   ix, diff;
    214236
    215         for (ix = 4; ix -- > 0; ) {
    216                 diff = *(data1 + ix) -  *(data2 + (3 - ix));
     237        for (ix = sizeof(uint32_t); ix -- > 0; ) {
     238                diff = *((uint8_t*)data1 + ix) -  *((uint8_t*)data2 + (3 - ix));
    217239                if (diff != 0)
    218240                        return diff;
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.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 *
     
    9090#include <net/ethernet.h>
    9191#include <net/net.h>
     92#include <net/net_endian.h>
    9293#include <net/net_buf.h>
    9394#include <net/net_timer.h>
    9495
    9596#include <netinet/in.h>
     97#include <netinet/in_var.h>
    9698#include <netinet/ip.h>
    9799#include <netinet/ip_var.h>
    98 #include <netinet/ip6.h>
    99 #include <netinet6/ip6_var.h>
    100 #include <netinet/tcp_timer.h>
    101100
    102101/*
     
    162161"\n"
    163162"TINET %d.%d.%d (" __DATE__ ", " __TIME__ ")\n"
    164 "Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering\n"
     163"Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering\n"
    165164"                    Tomakomai National College of Technology, JAPAN\n";
    166165
     
    181180
    182181        /* IP を初期化する。*/
    183         IP_INIT();
     182
     183#if defined(_IP6_CFG)
     184        ip6_init();
     185#endif
     186
     187#if defined(_IP4_CFG)
     188        ip_init();
     189#endif
    184190
    185191#ifdef SUPPORT_TCP
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.h

    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 *
     
    7474 */
    7575
    76 #define SYSTIM_HZ               ULONG_C(1000*1000)      /* [ms]                                 */
     76#define SYSTIM_HZ               ULONG_C(1000000)        /* [us]                                 */
    7777
    7878/*
     
    8080 */
    8181
    82 #define NET_TIMER_CYCLE         ULONG_C(100)    /* [ms]、fast timeout 使用時の動作周期   */
     82#define NET_TIMER_CYCLE         ULONG_C(100000) /* [us]、fast timeout 使用時の動作周期   */
    8383                                                /* タイマの周波数                      */
    8484#define NET_TIMER_HZ            (SYSTIM_HZ/NET_TIMER_CYCLE)
    8585
    86 #ifdef SUPPORT_INET6
     86#ifdef _IP6_CFG
    8787#define NUM_NET_CALLOUT         12              /* タイムアウト呼出し数、10 以上     */
    8888#else
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_var.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.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 *
     
    8181#include <net/if_ppp.h>
    8282#include <net/net.h>
     83#include <net/net_endian.h>
     84#include <net/net_var.h>
    8385#include <net/net_buf.h>
    8486#include <net/net_timer.h>
     
    8991#include <net/ppp_fsm.h>
    9092#include <net/ppp_lcp.h>
     93#include <net/ppp_ipv6cp.h>
    9194#include <net/ppp_ipcp.h>
    9295#include <net/ppp_ccp.h>
     
    108111T_PPP_PROTENT *protocols[] = {
    109112        &lcp_protent,
     113
     114#ifdef _IP6_CFG
     115        &ipv6cp_protent,
     116#endif  /* of #ifdef _IP6_CFG */
     117
     118#ifdef _IP4_CFG
    110119        &ipcp_protent,
     120#endif  /* of #ifdef _IP4_CFG */
    111121
    112122#ifdef SUPPORT_CCP
    113123        &ccp_protent,
    114 #endif  /* #ifdef SUPPORT_CCP */
     124#endif  /* of #ifdef SUPPORT_CCP */
    115125
    116126#ifdef LCP_CFG_PAP
    117127        &pap_protent,
    118 #endif  /* #ifdef LCP_CFG_PAP */
     128#endif  /* of #ifdef LCP_CFG_PAP */
    119129
    120130#ifdef LCP_CFG_CHAP
    121131        &chap_protent,
    122 #endif  /* #ifdef LCP_CFG_CHAP */
     132#endif  /* of #ifdef LCP_CFG_CHAP */
    123133
    124134        NULL
     
    223233#endif  /* of #ifdef PPP_CFG_MODEM */
    224234
     235#ifdef _IP6_CFG
     236        /* IPV6CP の接続完了まで待つ。*/
     237        if ((error = wait_ipv6cp()) != E_OK)
     238                goto buf_ret;
     239#endif  /* of #ifdef _IP6_CFG */
     240
     241#ifdef _IP4_CFG
    225242        /* IPCP の接続完了まで待つ。*/
    226243        if ((error = wait_ipcp()) != E_OK)
    227244                goto buf_ret;
     245#endif  /* of #ifdef _IP4_CFG */
     246
     247#ifdef _IP4_CFG
     248        /* IPCP の接続完了まで待つ。*/
     249        if ((error = wait_ipcp()) != E_OK)
     250                goto buf_ret;
     251#endif  /* of #ifdef _IP4_CFG */
    228252
    229253#ifdef PPP_IDLE_TIMEOUT
     
    290314        ID              tskid;
    291315        int_t           ix;
     316        uint8_t         rcount = 0;
    292317
    293318        /* ポートを初期設定する */
     
    321346        /* PPP 出力タスクを起動する */
    322347        syscall(act_tsk(PPP_OUTPUT_TASK));
     348
     349        /* 乱数生成を初期化する。*/
     350        net_srand(0);
    323351
    324352        while (true) {
     
    328356                        if (input->len > 0) {
    329357
    330         #ifdef PPP_IDLE_TIMEOUT
     358                                /* 乱数生成を初期化する。*/
     359                                if (rcount == 0)
     360                                        net_srand(input->len);
     361                                rcount ++;
     362
     363#ifdef PPP_IDLE_TIMEOUT
    331364                                wai_sem(SEM_IDLE_TIMEOUT);
    332365                                if (idle && ntohs(*GET_PPP_HDR(input)) != PPP_LCP) {
     
    335368                                        }
    336369                                sig_sem(SEM_IDLE_TIMEOUT);
    337         #endif  /* of #ifdef PPP_IDLE_TIMEOUT */
     370#endif  /* of #ifdef PPP_IDLE_TIMEOUT */
    338371
    339372                                parse_input(input);
     
    342375                                syscall(rel_net_buf(input));
    343376
    344         #ifdef PPP_IDLE_TIMEOUT
     377#ifdef PPP_IDLE_TIMEOUT
    345378                        wai_sem(SEM_IDLE_TIMEOUT);
    346379                        if (!idle && ppp_phase == PPP_PHASE_NETWORK) {
     
    353386                                }
    354387                        sig_sem(SEM_IDLE_TIMEOUT);
    355         #endif  /* of #ifdef PPP_IDLE_TIMEOUT */
     388#endif  /* of #ifdef PPP_IDLE_TIMEOUT */
    356389
    357390                        }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.cfg

    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 *
     
    5656        });
    5757
    58 CRE_DTQ(DTQ_PPP_OUTPUT,  { TA_TFIFO, NUM_DTQ_PPP_OUTPUT,  NULL });
     58CRE_DTQ(DTQ_PPP_OUTPUT,   { TA_TFIFO, NUM_DTQ_PPP_OUTPUT,  NULL });
    5959
    60 CRE_SEM(SEM_MODEM_READY, { TA_TPRI, 0, 1 });
    61 CRE_SEM(SEM_IPCP_READY,  { TA_TPRI, 0, 1 });
     60CRE_SEM(SEM_MODEM_READY,  { TA_TPRI, 0, 1 });
     61
     62#if defined(_IP6_CFG)
     63CRE_SEM(SEM_IPV6CP_READY, { TA_TPRI, 0, 1 });
     64#endif
     65
     66#if defined(_IP4_CFG)
     67CRE_SEM(SEM_IPCP_READY,   { TA_TPRI, 0, 1 });
     68#endif
    6269
    6370#ifdef PPP_IDLE_TIMEOUT
    64 CRE_SEM(SEM_IDLE_TIMEOUT,{ TA_TPRI, 1, 1 });
     71CRE_SEM(SEM_IDLE_TIMEOUT, { TA_TPRI, 1, 1 });
    6572#endif  /* of #ifdef PPP_IDLE_TIMEOUT */
    6673
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.h

    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 *
     
    7474 */
    7575
    76 #define PPP_IP          UINT_C(0x0021)          /* IP   */
     76#define PPP_IP          UINT_C(0x0021)          /* IPv4         */
     77#define PPP_IPV6        UINT_C(0x0057)          /* IPv6         */
    7778
    78 #define PPP_IPCP        UINT_C(0x8021)          /* IPCP */
    79 #define PPP_CCP         UINT_C(0x80fd)          /* CCP */
     79#define PPP_IPCP        UINT_C(0x8021)          /* IPCP         */
     80#define PPP_IPV6CP      UINT_C(0x8057)          /* IPV6CP       */
     81#define PPP_CCP         UINT_C(0x80fd)          /* CCP          */
    8082
    81 #define PPP_LCP         UINT_C(0xc021)          /* LCP  */
    82 #define PPP_PAP         UINT_C(0xc023)          /* PAP  */
    83 #define PPP_LQR         UINT_C(0xc025)          /* LQR  */
    84 #define PPP_CHAP        UINT_C(0xc223)          /* CHAP */
     83#define PPP_LCP         UINT_C(0xc021)          /* LCP          */
     84#define PPP_PAP         UINT_C(0xc023)          /* PAP          */
     85#define PPP_LQR         UINT_C(0xc025)          /* LQR          */
     86#define PPP_CHAP        UINT_C(0xc223)          /* CHAP         */
    8587
    8688#define GET_PPP_HDR(nbuf)       ((T_PPP_HDR*)((nbuf)->buf))
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.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 *
     
    100100#include <net/if_ppp.h>
    101101#include <net/net.h>
     102#include <net/net_endian.h>
    102103#include <net/net_buf.h>
    103104#include <net/ppp.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.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 *
     
    9393#include <net/if_ppp.h>
    9494#include <net/net_buf.h>
    95 #include <net/net_debug.h>
    9695#include <net/net_count.h>
    9796#include <net/ppp.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.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 *
     
    8686#include <net/if_ppp.h>
    8787#include <net/net.h>
     88#include <net/net_endian.h>
    8889#include <net/net_timer.h>
    8990#include <net/net_buf.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.h

    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 *
     
    9696        int8_t          retrans;        /* Configure-Request または、               */
    9797                                        /* Terminate-Request の再送回数              */
    98         } __attribute__((packed, aligned(2)))T_PPP_FSM;
     98        } T_PPP_FSM;
    9999
    100100#define T_PPP_FSM_DEFINED
     
    124124                                        /* 不明な CP を受信したときの処理    */
    125125        bool_t  (*extcode)(T_PPP_FSM *, uint8_t, uint8_t, T_NET_BUF *);
    126         } __attribute__((packed, aligned(2)))T_PPP_FSM_CALLBACKS;
     126        } T_PPP_FSM_CALLBACKS;
    127127
    128128/*
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.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 *
     
    6565#include <net/if_ppp.h>
    6666#include <net/net.h>
     67#include <net/net_endian.h>
    6768#include <net/net_buf.h>
    6869#include <net/net_count.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.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 *
     
    8989#include <net/if_ppp.h>
    9090#include <net/net.h>
     91#include <net/net_endian.h>
    9192#include <net/net_buf.h>
    9293#include <net/net_count.h>
     
    102103#include <netinet/ip.h>
    103104#include <netinet/tcp.h>
     105#include <netinet/tcp_var.h>
    104106#include <netinet/tcp_timer.h>
    105 #include <netinet/tcp_var.h>
    106107#include <netinet/udp_var.h>
    107108
     
    149150        NULL,
    150151        {
    151                 IPV4_ADDR_LOCAL,                /* IP アドレス                      */
     152                IPV4_ADDR_LOCAL,                /* IPv4 アドレス                    */
    152153                UINT_C(0),                      /* サブネットマスク             */
    153154                },
     
    157158        NULL,
    158159        {
    159                 IPV4_ADDR_REMOTE,               /* IP アドレス                      */
     160                IPV4_ADDR_REMOTE,               /* IPv4 アドレス                    */
    160161                UINT_C(0),                      /* サブネットマスク             */
    161162                }
     
    200201        ipcp_open,                      /* オープンする                       */
    201202        ipcp_close,                     /* クローズする                       */
    202         ip_input,                       /* データ入力、IP 入力          */
     203        ip_input,                       /* データ入力、IPv4 入力        */
    203204        };
    204205
     
    307308        int_t cilen = 0;
    308309
    309         cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);       /* IP アドレス */
     310        cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);       /* IPv4 アドレス */
    310311
    311312        return cilen;
     
    323324        buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
    324325
    325         /* IP アドレスオプションを追加する。 */
     326        /* IPv4 アドレスオプションを追加する。 */
    326327        *buf ++ = IPCP_CIT_ADDR;
    327328        *buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    328         ahtonl(buf, ipcp_local_neg_cfg.in_ifaddr.addr);
     329        ahtonl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr);
    329330        buf += sizeof(uint32_t);
    330331        }
     
    355356            *buf ++ != IPCP_CIT_ADDR                    ||
    356357            *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
    357             nahcmpl(buf, ipcp_local_neg_cfg.in_ifaddr.addr))
     358            nahcmpl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr))
    358359                return false;
    359360        buf += sizeof(uint32_t);
     
    390391                buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    391392                len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    392                 new_cfg.in_ifaddr.addr = cilong;
     393                new_cfg.in4_ifaddr.addr = cilong;
    393394                }
    394395
     
    438439                buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    439440                len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    440                 new_cfg.in_ifaddr.addr = 0;
     441                new_cfg.in4_ifaddr.addr = 0;
    441442                }
    442443
     
    499500                switch (type) {
    500501
    501                 case IPCP_CIT_ADDR:     /* IP アドレス */
     502                case IPCP_CIT_ADDR:     /* IPv4 アドレス */
    502503
    503504                        /* CI 長が、ヘッダ + 4 オクテットでなければエラー */
     
    506507                        else {
    507508                                ntoahl(addr, ap);
    508                                 if (addr != ipcp_remote_neg_cfg.in_ifaddr.addr &&
    509                                     (addr == 0 || ipcp_remote_neg_cfg.in_ifaddr.addr != 0)) {
     509                                if (addr != ipcp_remote_neg_cfg.in4_ifaddr.addr &&
     510                                    (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr != 0)) {
    510511                                        *np ++ = IPCP_CIT_ADDR;
    511512                                        *np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
    512                                         ahtonl(np, ipcp_remote_neg_cfg.in_ifaddr.addr);
     513                                        ahtonl(np, ipcp_remote_neg_cfg.in4_ifaddr.addr);
    513514                                        np  += sizeof(uint32_t);
    514515                                        code = PPP_CONFNAK;
    515516                                        }
    516517#if 1   /* 要確認 */
    517                                 else if (addr == 0 && ipcp_remote_neg_cfg.in_ifaddr.addr == 0)
     518                                else if (addr == 0 && ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
    518519#else
    519                                 else if (addr == 0 || ipcp_remote_neg_cfg.in_ifaddr.addr == 0)
     520                                else if (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
    520521#endif
    521522                                        code = PPP_CONFREJ;
    522523                                else
    523                                         ipcp_remote_neg_cfg.in_ifaddr.addr = addr;
     524                                        ipcp_remote_neg_cfg.in4_ifaddr.addr = addr;
    524525                                }
    525526                        break;
     
    582583        /*
    583584         *  サブネットマスクと
    584          *  ローカル・ブロードキャスト IP アドレスを設定する。
     585         *  ローカル・ブロードキャスト IPv4 アドレスを設定する。
    585586         */
    586         ipcp_local_ack_cfg.in_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in_ifaddr.addr);
     587        ipcp_local_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in4_ifaddr.addr);
    587588
    588589        /* 相手の構成情報の初期設定 */
     
    591592        /*
    592593         *  サブネットマスクと
    593          *  ローカル・ブロードキャスト IP アドレスを設定する。
     594         *  ローカル・ブロードキャスト IPv4 アドレスを設定する。
    594595         */
    595         ipcp_remote_ack_cfg.in_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in_ifaddr.addr);
     596        ipcp_remote_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in4_ifaddr.addr);
    596597
    597598        sig_sem(SEM_IPCP_READY);
    598599
    599         syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IP Addr: %s, Remote IP Addr: %s.",
    600                            ip2str(NULL, &ipcp_local_neg_cfg.in_ifaddr.addr),
    601                            ip2str(NULL, &ipcp_remote_neg_cfg.in_ifaddr.addr));
     600        syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IPv4 Addr: %s, Remote IPv4 Addr: %s.",
     601                           ip2str(NULL, &ipcp_local_neg_cfg.in4_ifaddr.addr),
     602                           ip2str(NULL, &ipcp_remote_neg_cfg.in4_ifaddr.addr));
    602603        }
    603604
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.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 *
     
    8686#include <net/if_ppp.h>
    8787#include <net/net.h>
     88#include <net/net_endian.h>
    8889#include <net/net_var.h>
    8990#include <net/net_buf.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.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 *
     
    4747#include <net/if_ppp.h>
    4848#include <net/net.h>
     49#include <net/net_endian.h>
    4950#include <net/net_buf.h>
    5051#include <net/net_count.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.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 *
     
    8787#include <net/if_ppp.h>
    8888#include <net/net.h>
     89#include <net/net_endian.h>
    8990#include <net/net_buf.h>
    9091#include <net/net_timer.h>
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_var.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/net/route.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp

    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#
     
    5050
    5151TINET_ROOT = $(SRCDIR)/tinet
    52 NETAPP_DIR = $(TINET_ROOT)/netapp
     52NETAPP_DIRS = $(TINET_ROOT)/netapp
    5353NETAPP_COBJS := $(NETAPP_COBJS) netapp_subr.o
    5454
     55ifeq ($(USE_LCD),true)
     56
     57        NETAPP_COBJS := $(NETAPP_COBJS) lcd.o
     58
     59ifeq ($(TARGET_KERNEL),ASP)
     60        NETAPP_COBJS := $(NETAPP_COBJS) target_lcd.o sc1602.o
     61endif
     62
     63ifeq ($(TARGET_KERNEL),JSP)
     64        NETAPP_COBJS := $(NETAPP_COBJS) hw_lcd.o sc1602.o
     65endif
     66
     67endif
     68
    5569#  トランスポート層の選択
    5670
    57 SUPPORT_TCP = false
    58 SUPPORT_UDP = false
     71#SUPPORT_TCP = false
     72#SUPPORT_UDP = false
    5973
    6074#
     
    6276#
    6377
     78ifeq ($(USE_WWW4_SRV),true)
     79        USE_WWW_SRV = true
     80        CDEFS := $(CDEFS) -DUSE_WWW4_SRV
     81endif
     82
    6483ifeq ($(USE_WWW_SRV),true)
    65         SUPPORT_TCP = true
    66         TCP_CFG_PASSIVE_OPEN = true
     84
     85        SUPPORT_TCP = true
    6786        USE_NETAPP_SUBR = true
    6887        CDEFS := $(CDEFS) -DUSE_WWW_SRV
    6988        NETAPP_COBJS := $(NETAPP_COBJS) wwws.o
    70         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/wwws.cfg
     89        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/wwws.cfg
     90
     91endif
     92
     93ifeq ($(USE_TCP4_ECHO_SRV),true)
     94        TCP_ECHO_SRV = tcp_echo_srv1
     95        CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_SRV
    7196endif
    7297
    7398ifeq ($(TCP_ECHO_SRV),tcp_echo_srv1)            # 送受信タスク同一型
    74         SUPPORT_TCP = true
    75         TCP_CFG_PASSIVE_OPEN = true
     99
     100        SUPPORT_TCP = true
    76101        USE_NETAPP_SUBR = true
    77102        CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV1
    78103        NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1.o
    79         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv1.cfg
     104        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv1.cfg
     105
     106        ifeq ($(USE_TCP_NON_BLOCKING),true)
     107                NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_nblk.o
     108        endif
     109
     110        ifeq ($(USE_TCP_EXTENTIONS),true)
     111                NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_ext.o
     112        endif
     113
    80114endif
    81115
    82116ifeq ($(TCP_ECHO_SRV),tcp_echo_srv2)            # 送受信タスク分離型
    83117        SUPPORT_TCP = true
    84         TCP_CFG_PASSIVE_OPEN = true
    85118        USE_NETAPP_SUBR = true
    86119        CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV2
    87120        NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv2.o
    88         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv2.cfg
     121        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv2.cfg
     122endif
     123
     124ifeq ($(USE_UDP4_ECHO_SRV),true)
     125        USE_UDP_ECHO_SRV = true
    89126endif
    90127
    91128ifeq ($(USE_UDP_ECHO_SRV),true)
    92         SUPPORT_UDP = true
    93         USE_NETAPP_SUBR = true
     129
    94130        CDEFS := $(CDEFS) -DUSE_UDP_ECHO_SRV
    95         NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_srv.o
    96         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_srv.cfg
     131
     132        ifeq ($(SUPPORT_INET6),true)
     133                SUPPORT_UDP = true
     134                USE_NETAPP_SUBR = true
     135                CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_SRV_TSK
     136                NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_srv.o
     137                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_srv.cfg
     138
     139                ifeq ($(SUPPORT_INET4),true)
     140                        ifeq ($(USE_UDP4_ECHO_SRV),true)
     141                                CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
     142                                NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
     143                                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
     144                        endif
     145                endif
     146        else
     147                ifeq ($(SUPPORT_INET4),true)
     148                        SUPPORT_UDP = true
     149                        USE_NETAPP_SUBR = true
     150                        CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
     151                        NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
     152                        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
     153                endif
     154        endif
     155endif
     156
     157
     158ifeq ($(USE_TCP4_ECHO_CLI),true)
     159        USE_TCP_ECHO_CLI = true
     160        CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_CLI
    97161endif
    98162
     
    101165        USE_NETAPP_SUBR = true
    102166        CDEFS := $(CDEFS) -DUSE_TCP_ECHO_CLI
    103         NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o
    104         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_cli.cfg
     167        NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o tcp_echo_cli_snd.o tcp_echo_cli_rcv.o
     168        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_cli.cfg
     169endif
     170
     171ifeq ($(USE_UDP4_ECHO_CLI),true)
     172        USE_UDP_ECHO_CLI = true
    105173endif
    106174
    107175ifeq ($(USE_UDP_ECHO_CLI),true)
    108         SUPPORT_UDP = true
    109         USE_NETAPP_SUBR = true
     176
    110177        CDEFS := $(CDEFS) -DUSE_UDP_ECHO_CLI
    111         NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_cli.o
    112         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_cli.cfg
     178
     179        ifeq ($(SUPPORT_INET6),true)
     180                SUPPORT_UDP = true
     181                USE_NETAPP_SUBR = true
     182                CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_CLI_TSK
     183                NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o
     184                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg
     185       
     186                ifeq ($(SUPPORT_INET4),true)
     187                        ifeq ($(USE_UDP4_ECHO_CLI),true)
     188                                CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
     189                                NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
     190                                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
     191                        endif
     192                endif
     193        else
     194                ifeq ($(SUPPORT_INET4),true)
     195                        SUPPORT_UDP = true
     196                        USE_NETAPP_SUBR = true
     197                        CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
     198                        NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
     199                        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
     200                endif
     201
     202        endif
    113203endif
    114204
    115205ifeq ($(USE_TCP_DISCARD_SRV),true)
    116206        SUPPORT_TCP = true
    117         TCP_CFG_PASSIVE_OPEN = true
    118207        USE_NETAPP_SUBR = true
    119208        CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_SRV
    120209        NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_srv.o
    121         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_discard_srv.cfg
     210        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_srv.cfg
    122211endif
    123212
     
    127216        CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_CLI
    128217        NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_cli.o
    129         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_discard_cli.cfg
     218        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_cli.cfg
    130219endif
    131220
     
    135224        CDEFS := $(CDEFS) -DUSE_UDP_DISCARD_CLI
    136225        NETAPP_COBJS := $(NETAPP_COBJS) udp_discard_cli.o
    137         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_discard_cli.cfg
     226        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp_discard_cli.cfg
    138227endif
    139228
     
    141230        ifeq ($(TCP_CFG_NON_BLOCKING),true)
    142231                SUPPORT_TCP = true
    143                 TCP_CFG_PASSIVE_OPEN = true
    144232                USE_DBG_CONS = true
    145233                USE_NETAPP_SUBR = true
    146234                CDEFS := $(CDEFS) -DUSE_NET_CONS
    147235                NETAPP_COBJS := $(NETAPP_COBJS) net_cons.o
    148                 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/net_cons.cfg
     236                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/net_cons.cfg
    149237        endif
    150238endif
    151239
    152240ifeq ($(USE_DBG_CONS),true)
    153 
    154241        USE_NETAPP_SUBR = true
    155242        CDEFS := $(CDEFS) -DUSE_DBG_CONS
    156243        NETAPP_COBJS := $(NETAPP_COBJS) dbg_cons.o
    157         NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/dbg_cons.cfg
    158 
     244        NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/dbg_cons.cfg
     245        ifeq ($(USE_DBG_CONS_PARSER),true)
     246                CDEFS := $(CDEFS) -DUSE_DBG_CONS_PARSER
     247        endif
     248        ifeq ($(USE_DBG_CONS_EXTRA_PARSE),true)
     249                CDEFS := $(CDEFS) -DUSE_DBG_CONS_EXTRA_PARSE
     250        endif
    159251endif
    160252
    161253ifeq ($(USE_PING),true)
    162 
    163254        USE_NETAPP_SUBR = true
    164255        CDEFS := $(CDEFS) -DUSE_PING
    165 
    166256        ifeq ($(SUPPORT_INET4),true)
    167 
    168257                NETAPP_COBJS := $(NETAPP_COBJS) ping.o
    169258        endif
    170 
    171259        ifeq ($(SUPPORT_INET6),true)
    172 
    173260                NETAPP_COBJS := $(NETAPP_COBJS) ping6.o
    174261        endif
    175 
     262endif
     263
     264ifeq ($(USE_RESOLVER),true)
     265        SUPPORT_UDP = true
     266        CDEFS := $(CDEFS) -DUSE_RESOLVER
     267        NETAPP_COBJS := $(NETAPP_COBJS) resolver.o
     268
     269endif
     270
     271ifeq ($(USE_DHCP6_CLI),true)
     272        ifeq ($(SUPPORT_INET6),true)
     273                SUPPORT_UDP = true
     274                UDP_CFG_NON_BLOCKING = true
     275                USE_UDP_NON_BLOCKING = true
     276                CDEFS := $(CDEFS) -DDHCP6_CLI_CFG
     277                NETAPP_COBJS := $(NETAPP_COBJS) dhcp6_cli.o
     278        endif
     279endif
     280
     281ifeq ($(USE_DHCP4_CLI),true)
     282        ifeq ($(SUPPORT_INET4),true)
     283                SUPPORT_UDP = true
     284                UDP_CFG_NON_BLOCKING = true
     285                USE_UDP_NON_BLOCKING = true
     286                CDEFS := $(CDEFS) -DDHCP4_CLI_CFG
     287                NETAPP_COBJS := $(NETAPP_COBJS) dhcp4_cli.o
     288        endif
    176289endif
    177290
     
    180293endif
    181294
     295ifeq ($(API_CFG_IP4MAPPED_ADDR),true)
     296        CDEFS := $(CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
     297endif
     298
    182299ifeq ($(USE_COPYSAVE_API),true)
    183300        CDEFS := $(CDEFS) -DUSE_COPYSAVE_API
    184 endif
    185 
    186 ifndef TCP_CFG_PASSIVE_OPEN
    187         CDEFS := $(CDEFS) -DUNDEF_TCP_CFG_PASSIVE_OPEN
    188301endif
    189302
     
    241354endif
    242355
     356ifeq ($(USE_LCD),true)
     357        CDEFS := $(CDEFS) -DUSE_LCD
     358endif
     359
    243360#
    244361#  アプリケーションプログラムに関する定義への追加
     
    247364ifeq ($(TARGET_KERNEL),ASP)
    248365
    249         APPLDIR := $(APPLDIR) $(NETAPP_DIR)
     366        APPLDIR := $(APPLDIR) $(NETAPP_DIRS)
    250367        APPL_COBJS := $(APPL_COBJS) $(NETAPP_COBJS)
    251368        APPL_CFLAGS := $(APPL_CFLAGS) -fno-strict-aliasing
     
    255372ifeq ($(TARGET_KERNEL),JSP)
    256373
    257         UTASK_DIR := $(UTASK_DIR):$(NETAPP_DIR)
     374        UTASK_DIRS := $(UTASK_DIRS):$(NETAPP_DIRS)
    258375        UTASK_COBJS := $(UTASK_COBJS) $(NETAPP_COBJS)
    259376        UTASK_CFLAGS := $(UTASK_CFLAGS) -fno-strict-aliasing
     
    261378endif
    262379
     380ifeq ($(USE_LCD),true)
     381
     382ifeq ($(TARGET_KERNEL),ASP)
     383
     384        APPLDIR := $(APPLDIR) $(SRCDIR)/pdic/sc1602
     385
     386endif
     387
     388ifeq ($(TARGET_KERNEL),JSP)
     389
     390        UTASK_DIRS := $(UTASK_DIRS):$(SRCDIR)/pdic/sc1602
     391
     392endif
     393
     394endif
     395
    263396#
    264397#  TINET コンフィギュレーションファイルの定義への追加
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.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 *
     
    3737
    3838#include <stdlib.h>
     39#include <string.h>
    3940
    4041#ifdef TARGET_KERNEL_ASP
     
    4445#include <syssvc/serial.h>
    4546#include <syssvc/logtask.h>
    46 #include "kernel_cfg.h"
    4747#include "kernel/kernel_impl.h"
    4848#include "kernel/task.h"
     49#include "kernel_cfg.h"
     50#include "tinet_cfg.h"
    4951
    5052#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    5557#include <t_services.h>
    5658#include "kernel_id.h"
     59#include "tinet_id.h"
    5760
    5861#include "../kernel/jsp_kernel.h"
     
    6972#include <net/ethernet.h>
    7073#include <net/net.h>
     74#include <net/net_endian.h>
    7175#include <net/net_buf.h>
    7276#include <net/net_timer.h>
     
    8387#include <netinet/ip.h>
    8488#include <netinet/ip_var.h>
    85 #include <netinet/ip6.h>
    86 #include <netinet6/ip6_var.h>
    87 #include <netinet6/nd6.h>
    8889#include <netinet/if_ether.h>
    8990#include <netinet/tcp.h>
    90 #include <netinet/tcp_timer.h>
    9191#include <netinet/tcp_var.h>
    9292#include <netinet/tcp_fsm.h>
     93#include <netinet/tcp_timer.h>
    9394#include <netinet/udp.h>
    9495#include <netinet/udp_var.h>
    9596
     97#include <netinet6/nd6.h>
     98
    9699#include <net/if_var.h>
    97 #include <net/if6_var.h>
    98100
    99101#include <netapp/netapp.h>
    100102#include <netapp/netapp_var.h>
    101 #include <netapp/echo.h>
    102 #include <netapp/discard.h>
     103#include <netapp/wwws.h>
     104#include <netapp/tcp_echo_srv1.h>
     105#include <netapp/tcp_echo_srv2.h>
     106#include <netapp/tcp_echo_cli.h>
     107#include <netapp/tcp_discard_cli.h>
     108#include <netapp/udp6_echo_srv.h>
     109#include <netapp/udp4_echo_srv.h>
     110#include <netapp/udp6_echo_cli.h>
     111#include <netapp/udp4_echo_cli.h>
     112#include <netapp/udp_discard_cli.h>
     113#include <netapp/resolver.h>
    103114#include <netapp/dbg_cons.h>
    104 
    105 #ifdef USE_LCD
    106 
    107 #include "sc1602/lcd.h"
    108 
    109 #endif  /* of #ifdef USE_LCD */
     115#include <netapp/dhcp6_cli.h>
     116#include <netapp/dhcp4_cli.h>
     117#include "lcd.h"
    110118
    111119#ifdef USE_DBG_CONS
    112120
    113 #define DBG_LINE_SIZE   63
    114 
    115121/*
    116  *  task_status -- タスクの状態の出力
     122 *  dbg_cons_task_status -- タスクの状態の出力
    117123 */
    118124
     
    127133        };
    128134
    129 static void
    130 task_status (ID portid, char *line)
     135void
     136dbg_cons_task_status (ID portid, char *line)
    131137{
    132138        TCB     *tcb;
     
    149155                        st >>= 1;
    150156                        }
    151                 cons_printf(portid, "\n");
     157                cons_putchar(portid, '\n');
    152158                }
    153159
     
    176182        };
    177183
     184#if defined(SUPPORT_INET6)
     185
     186static void
     187tcp_cep_status (ID portid, char *line)
     188{
     189        T_TCP_CEP*      cep;
     190        int             len;
     191
     192#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
     193
     194        T_TCP_TWCEP*    twcep;
     195
     196#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
     197
     198        cons_printf(portid,
     199                    "TCP CEP Status\n"
     200                    "ID  Snd-Q Rcv-Q Foreign Address                               State\n");
     201
     202        for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
     203                if (!VALID_TCP_CEP(cep)) {
     204                        cons_printf(portid,
     205                                    "%2d%c%c     0     0"
     206                                    " -                                            "
     207                                    " INVALID\n",
     208                                    GET_TCP_CEPID(cep),
     209                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     210                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
     211                        }
     212                else if (cep->fsm_state == TCP_FSM_CLOSED) {
     213                        cons_printf(portid,
     214                                    "%2d%c%c     0     0"
     215                                    " -                                            "
     216                                    " CLOSED\n",
     217                                    GET_TCP_CEPID(cep),
     218                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     219                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
     220                        }
     221                else if (cep->fsm_state == TCP_FSM_LISTEN) {
     222                        cons_printf(portid,
     223                                    "%2d%c%c     0     0"
     224                                    " -                                            "
     225                                    " LISTEN\n",
     226                                    GET_TCP_CEPID(cep),
     227                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     228                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
     229                        }
     230                else {
     231                        cons_printf(portid,
     232                                    "%2d%c%c %5d %5d ",
     233                                    GET_TCP_CEPID(cep),
     234                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     235                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4',
     236                                    cep->swbuf_count, cep->rwbuf_count);
     237
    178238#if defined(SUPPORT_INET4)
    179239
     240                        if (TCP_IS_CEP_IPV4(cep)) {
     241                                T_IN4_ADDR      addr;
     242
     243                                addr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     244                                len  = put_ipv4addr(portid, &addr, 0);
     245                                }
     246                        else
     247                                len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
     248
     249#else   /* of #if defined(SUPPORT_INET4) */
     250
     251                        len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
     252
     253#endif  /* of #if defined(SUPPORT_INET4) */
     254
     255                        cons_putchar(portid, '.');
     256                        len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
     257                        for (len = 44 - len; len -- > 0; )
     258                                cons_putchar(portid, ' ');
     259                        if (cep->fsm_state == TCP_FSM_TIME_WAIT)
     260                                cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
     261                                                    cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
     262                        else
     263                                cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
     264                        }
     265
     266#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
     267
     268        for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
     269                if (twcep->fsm_state == TCP_FSM_CLOSED) {
     270                        cons_printf(portid,
     271                                    "%2dTW     0     0"
     272                                    " -                                            "
     273                                    " CLOSED\n",
     274                                    GET_TCP_TWCEPID(twcep));
     275                        }
     276                else {
     277                        cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
     278
     279#if defined(SUPPORT_INET4)
     280
     281                        if (TCP_IS_CEP_IPV4(twcep)) {
     282                                T_IN4_ADDR      addr;
     283
     284                                addr = ntohl(twcep->dstaddr.ipaddr.s6_addr32[3]);
     285                                len  = put_ipv4addr(portid, &addr, 0);
     286                                }
     287                        else
     288                                len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
     289
     290#else   /* of #if defined(SUPPORT_INET4) */
     291
     292                        len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
     293
     294#endif  /* of #if defined(SUPPORT_INET4) */
     295
     296                        cons_putchar(portid, '.');
     297                        len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
     298                        for (len = 44 - len; len -- > 0; )
     299                                cons_putchar(portid, ' ');
     300                        if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
     301                                cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
     302                                                    twcep->timer_2msl / TCP_SLOW_HZ);
     303                        else
     304                                cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
     305                        }
     306                }
     307
     308#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
     309
     310        }
     311
     312#else   /* of #if defined(SUPPORT_INET6) */
     313
     314#if defined(SUPPORT_INET4)
     315
    180316static void
    181 tcp_status (ID portid, char *line)
     317tcp_cep_status (ID portid, char *line)
    182318{
    183319        T_TCP_CEP*      cep;
     
    190326#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    191327
    192 #ifdef TCP_CFG_PASSIVE_OPEN
    193 
    194         T_TCP_REP*      rep;
    195         int_t           cnt;
    196 
    197 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
    198 
    199         WAI_NET_CONS_PRINTF();
    200328        cons_printf(portid,
    201329                    "TCP CEP Status\n"
     
    205333                if (!VALID_TCP_CEP(cep)) {
    206334                        cons_printf(portid,
    207                                     "%2d%c     0     0"
     335                                    "%2d%c%c     0     0"
    208336                                    " -                    "
    209337                                    " -                    "
    210338                                    " INVALID\n",
    211339                                    GET_TCP_CEPID(cep),
    212                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
     340                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     341                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
    213342                        }
    214343                else if (cep->fsm_state == TCP_FSM_CLOSED) {
    215344                        cons_printf(portid,
    216                                     "%2d%c     0     0"
     345                                    "%2d%c%c     0     0"
    217346                                    " -                    "
    218347                                    " -                    "
    219348                                    " CLOSED\n",
    220349                                    GET_TCP_CEPID(cep),
    221                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
     350                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     351                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
    222352                        }
    223353                else if (cep->fsm_state == TCP_FSM_LISTEN) {
    224354                        cons_printf(portid,
    225                                     "%2d%c     0     0 ",
     355                                    "%2d%c%c     0     0 ",
    226356                                    GET_TCP_CEPID(cep),
    227                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
     357                                    DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
     358                                    TCP_IS_CEP_IPV6(cep) ? '6' : '4');
    228359                        len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
    229360                        cons_putchar(portid, ':');
     
    263394                if (twcep->fsm_state == TCP_FSM_CLOSED) {
    264395                        cons_printf(portid,
    265                                     "%2dTW    0     0"
     396                                    "%2dTW     0     0"
    266397                                    " -                    "
    267398                                    " -                    "
     
    270401                        }
    271402                else {
    272                         cons_printf(portid, "%2dTW    0     0 ", GET_TCP_TWCEPID(twcep));
     403                        cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
    273404                        len  = PUT_IPADDR(portid, &twcep->myaddr.ipaddr, 0);
    274405                        cons_putchar(portid, ':');
     
    291422#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    292423
    293 #ifdef TCP_CFG_PASSIVE_OPEN
     424        }
     425
     426#endif  /* of #if defined(SUPPORT_INET4) */
     427
     428#endif  /* of #if defined(SUPPORT_INET6) */
     429
     430#if TNUM_TCP6_REPID > 0
     431
     432static void
     433tcp6_rep_status (ID portid, char *line)
     434{
     435        T_TCP_CEP*      cep;
     436        T_TCP6_REP*     rep;
     437        ID              repid;
     438        int_t           cnt;
     439        uint_t          len;
    294440
    295441        cons_printf(portid,
    296                     "TCP REP Status\n"
     442                    "TCP6 REP Status\n"
    297443                    "ID  Local Address         CEP\n");
    298         for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) {
    299                 cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
    300                 if (VALID_TCP_REP(rep)) {
    301                         len  = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0);
    302                         cons_putchar(portid, ':');
    303                         len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
    304                         for (len = 21 - len; len -- > 0; )
    305                                 cons_putchar(portid, ' ');
    306                         cnt = 0;
    307                         for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
    308                                 if (cep->rep == rep) {
    309                                         if (cnt > 0)
    310                                                 cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
    311                                         else
    312                                                 cons_printf(portid, "%d", GET_TCP_CEPID(cep));
    313                                         cnt ++;
    314                                         }
    315                                 }
    316                         }
    317                 else
    318                         cons_printf(portid, "INVALID");
    319                 cons_putchar(portid, '\n');
    320                 }
    321 
    322 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
    323 
    324         SIG_NET_CONS_PRINTF();
    325         FLUSH_SND_BUFF();
    326         }
    327 
    328 #endif  /* of #if defined(SUPPORT_INET4) */
    329 
    330 #if defined(SUPPORT_INET6)
    331 
    332 static void
    333 tcp_status (ID portid, char *line)
    334 {
    335         T_TCP_CEP*      cep;
    336         uint_t          len;
    337 
    338 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
    339 
    340         T_TCP_TWCEP*    twcep;
    341 
    342 #endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    343 
    344 #ifdef TCP_CFG_PASSIVE_OPEN
    345 
    346         T_TCP_REP*      rep;
    347         int_t           cnt;
    348 
    349 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
    350 
    351         WAI_NET_CONS_PRINTF();
    352         cons_printf(portid,
    353                     "TCP CEP Status\n"
    354                     "ID  Snd-Q Rcv-Q Foreign Address                             State\n");
    355 
    356         for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
    357                 if (!VALID_TCP_CEP(cep)) {
    358                         cons_printf(portid,
    359                                     "%2d%c     0     0"
    360                                     " -                                          "
    361                                     " INVALID\n",
    362                                     GET_TCP_CEPID(cep),
    363                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
    364                         }
    365                 else if (cep->fsm_state == TCP_FSM_CLOSED) {
    366                         cons_printf(portid,
    367                                     "%2d%c     0     0"
    368                                     " -                                          "
    369                                     " CLOSED\n",
    370                                     GET_TCP_CEPID(cep),
    371                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
    372                         }
    373                 else if (cep->fsm_state == TCP_FSM_LISTEN) {
    374                         cons_printf(portid,
    375                                     "%2d%c     0     0"
    376                                     " -                                          "
    377                                     " LISTEN\n",
    378                                     GET_TCP_CEPID(cep),
    379                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
    380                         }
    381                 else {
    382                         cons_printf(portid,
    383                                     "%2d%c %5d %5d ",
    384                                     GET_TCP_CEPID(cep),
    385                                     DYNAMIC_TCP_CEP(cep) ? 'D' : ' ',
    386                                     cep->swbuf_count, cep->rwbuf_count);
    387                         len  = PUT_IPADDR(portid, &cep->dstaddr.ipaddr, 0);
    388                         cons_putchar(portid, '.');
    389                         len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
    390                         for (len = 42 - len; len -- > 0; )
    391                                 cons_putchar(portid, ' ');
    392                         if (cep->fsm_state == TCP_FSM_TIME_WAIT)
    393                                 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
    394                                                     cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
    395                         else
    396                                 cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
    397                         }
    398 
    399 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
    400 
    401         for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
    402                 if (twcep->fsm_state == TCP_FSM_CLOSED) {
    403                         cons_printf(portid,
    404                                     "%2dTW    0     0"
    405                                     " -                                          "
    406                                     " CLOSED\n",
    407                                     GET_TCP_TWCEPID(twcep));
    408                         }
    409                 else {
    410                         cons_printf(portid, "%2dTW    0     0 ", GET_TCP_TWCEPID(twcep));
    411                         len  = PUT_IPADDR(portid, &twcep->dstaddr.ipaddr, 0);
    412                         cons_putchar(portid, '.');
    413                         len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
    414                         for (len = 42 - len; len -- > 0; )
    415                                 cons_putchar(portid, ' ');
    416                         if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
    417                                 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
    418                                                     twcep->timer_2msl / TCP_SLOW_HZ);
    419                         else
    420                                 cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
    421                         }
    422                 }
    423 
    424 #endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    425 
    426 #ifdef TCP_CFG_PASSIVE_OPEN
    427 
    428         cons_printf(portid,
    429                     "TCP REP Status\n"
    430                     "ID  Local Address         CEP\n");
    431         for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) {
    432                 cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
     444        for (repid = TMIN_TCP6_REPID; repid <= tmax_tcp6_repid; repid ++) {
     445                rep = GET_TCP6_REP(repid);
     446                cons_printf(portid, "%2d%c ", GET_TCP6_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
    433447                if (VALID_TCP_REP(rep)) {
    434448                        len  = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0);
     
    439453                        cnt = 0;
    440454                        for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
    441                                 if (cep->rep == rep) {
     455                                if (TCP_IS_CEP_IPV6(cep) && cep->rep == rep) {
    442456                                        if (cnt > 0)
    443457                                                cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
     
    452466                cons_putchar(portid, '\n');
    453467                }
    454 
    455 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
    456 
    457         SIG_NET_CONS_PRINTF();
    458         FLUSH_SND_BUFF();
    459         }
    460 
    461 #endif  /* of #if defined(SUPPORT_INET6) */
    462 
    463 #endif  /* of #ifdef SUPPORT_TCP */
    464 
    465 #ifdef SUPPORT_UDP
    466 
    467 /*
    468  *  udp_status -- UDP の状態の出力
    469  */
     468        }
     469
     470#endif  /* of #if TNUM_TCP6_REPID > 0 */
     471
     472#if TNUM_TCP4_REPID > 0
    470473
    471474static void
    472 udp_status (ID portid, char *line)
    473 {
    474         T_UDP_CEP*      cep;
     475tcp4_rep_status (ID portid, char *line)
     476{
     477        T_TCP_CEP*      cep;
     478        T_TCP4_REP*     rep;
     479        ID              repid;
     480        int_t           cnt;
    475481        uint_t          len;
    476482
    477         WAI_NET_CONS_PRINTF();
    478483        cons_printf(portid,
    479                     "UDP CEP Status\n"
    480                     "ID  Local Address\n");
    481 
    482         for (cep = udp_cep; cep < &udp_cep[tmax_udp_ccepid]; cep ++) {
    483                 cons_printf(portid, "%2d%c ", GET_UDP_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
    484                 if (VALID_UDP_CEP(cep)) {
    485                         len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
    486                         cons_putchar(portid, '.');
    487                         len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
     484                    "TCP4 REP Status\n"
     485                    "ID  Local Address         CEP\n");
     486        for (repid = TMIN_TCP4_REPID; repid <= tmax_tcp4_repid; repid ++) {
     487                rep = GET_TCP4_REP(repid);
     488                cons_printf(portid, "%2d%c ", GET_TCP4_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
     489                if (VALID_TCP_REP(rep)) {
     490                        len  = put_ipv4addr(portid, &rep->myaddr.ipaddr, 0);
     491                        cons_putchar(portid, ':');
     492                        len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
     493                        for (len = 21 - len; len -- > 0; )
     494                                cons_putchar(portid, ' ');
     495                        cnt = 0;
     496                        for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
     497
     498#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     499
     500                                if (TCP_IS_CEP_IPV4(cep) && cep->rep4 == rep) {
     501
     502#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     503
     504                                if (TCP_IS_CEP_IPV4(cep) && cep->rep == rep) {
     505
     506#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     507
     508                                        if (cnt > 0)
     509                                                cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
     510                                        else
     511                                                cons_printf(portid, "%d", GET_TCP_CEPID(cep));
     512                                        cnt ++;
     513                                        }
     514                                }
    488515                        }
    489516                else
     
    491518                cons_putchar(portid, '\n');
    492519                }
     520        }
     521
     522#endif  /* of #if TNUM_TCP4_REPID > 0 */
     523
     524static void
     525tcp_status (ID portid, char *line)
     526{
     527        WAI_NET_CONS_PRINTF();
     528
     529        tcp_cep_status(portid, line);
     530
     531#if TNUM_TCP6_REPID > 0
     532        tcp6_rep_status(portid, line);
     533#endif
     534
     535#if TNUM_TCP4_REPID > 0
     536        tcp4_rep_status(portid, line);
     537#endif
    493538
    494539        SIG_NET_CONS_PRINTF();
     
    496541        }
    497542
    498 #endif  /* of #ifdef SUPPORT_UDP */
    499 
    500 #ifdef SUPPORT_ETHER
    501 
    502 #if defined(SUPPORT_INET4)
     543#endif  /* of #ifdef SUPPORT_TCP */
     544
     545#ifdef SUPPORT_UDP
    503546
    504547/*
    505  *  ifa_status -- ARP キャッシュ出力
    506  */
     548 *  udp6_status -- UDP の状態の出力
     549 */
     550
     551#if TNUM_UDP6_CEPID > 0
     552
     553extern const ID tmax_tcp_cepid;
    507554
    508555static void
    509 ifa_status (ID portid, char *line)
    510 {
    511         const T_ARP_ENTRY       *cache;
    512         int_t                   ix;
    513 
     556udp6_status (ID portid, char *line)
     557{
     558        T_UDP6_CEP*     cep;
     559        ID              cepid;
     560        uint_t          len;
     561
     562        cons_printf(portid,
     563                    "UDP6 CEP Status\n"
     564                    "ID  Local Address\n");
     565
     566        for (cepid = TMIN_UDP6_CEPID; cepid <= tmax_udp6_cepid; cepid ++) {
     567                cep = GET_UDP6_CEP(cepid);
     568                cons_printf(portid, "%2d%c ", GET_UDP6_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
     569                if (VALID_UDP_CEP(cep)) {
     570                        len  = put_ipv6addr(portid, &cep->myaddr.ipaddr, 0);
     571                        cons_putchar(portid, '.');
     572                        len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
     573                        }
     574                else
     575                        cons_printf(portid, "INVALID");
     576                cons_putchar(portid, '\n');
     577                }
     578
     579        SIG_NET_CONS_PRINTF();
     580        }
     581
     582#endif  /* of #if TNUM_UDP6_CEPID > 0 */
     583
     584/*
     585 *  udp4_status -- UDP の状態の出力
     586 */
     587
     588#if TNUM_UDP4_CEPID > 0
     589
     590static void
     591udp4_status (ID portid, char *line)
     592{
     593        T_UDP4_CEP*     cep;
     594        ID              cepid;
     595        uint_t          len;
     596
     597        cons_printf(portid,
     598                    "UDP4 CEP Status\n"
     599                    "ID  Local Address\n");
     600
     601        for (cepid = TMIN_UDP4_CEPID; cepid <= tmax_udp4_cepid; cepid ++) {
     602                cep = GET_UDP4_CEP(cepid);
     603                cons_printf(portid, "%2d%c ", GET_UDP4_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
     604                if (VALID_UDP_CEP(cep)) {
     605                        len  = put_ipv4addr(portid, &cep->myaddr.ipaddr, 0);
     606                        cons_putchar(portid, '.');
     607                        len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
     608                        }
     609                else
     610                        cons_printf(portid, "INVALID");
     611                cons_putchar(portid, '\n');
     612                }
     613
     614        SIG_NET_CONS_PRINTF();
     615        }
     616
     617#endif  /* of #if TNUM_UDP4_CEPID > 0 */
     618
     619static void
     620udp_status (ID portid, char *line)
     621{
    514622        WAI_NET_CONS_PRINTF();
    515         cons_printf(portid,
    516                     "ARP Cache\n"
    517                     "IX Expire IP Address      MAC Address\n");
    518 
    519         /* expire の単位は [ms]。*/
    520         cache = arp_get_cache();
    521         for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
    522                 if (cache[ix].expire != 0)
    523                         cons_printf(portid, "%2d %6d %15I %M\n",
    524                                             ix, cache[ix].expire / NET_TIMER_HZ,
    525                                             &cache[ix].ip_addr, cache[ix].mac_addr);
    526                 }
     623
     624#if TNUM_UDP6_CEPID > 0
     625        udp6_status(portid, line);
     626#endif
     627
     628#if TNUM_UDP4_CEPID > 0
     629        udp4_status(portid, line);
     630#endif
    527631
    528632        SIG_NET_CONS_PRINTF();
     
    530634        }
    531635
    532 #endif  /* of #if defined(SUPPORT_INET4) */
     636#endif  /* of #ifdef SUPPORT_UDP */
     637
     638#ifdef SUPPORT_ETHER
    533639
    534640#if defined(SUPPORT_INET6)
    535641
    536642/*
    537  * ifa_status -- 近隣キャッシュ状態の出力
     643 * ifa6_status -- 近隣キャッシュ状態の出力
    538644 */
    539645
     
    549655
    550656static void
    551 ifa_status (ID portid, char *line)
     657ifa6_status (ID portid, char *line)
    552658{
    553659        const T_LLINFO_ND6      *cache;
     
    565671        for (ix = 0; ix < NUM_ND6_CACHE_ENTRY; ix ++) {
    566672                if (cache[ix].state != ND6_LLINFO_FREE) {
    567                         cons_printf(portid, "%2d %6d %10s %M %I\n",
     673                        cons_printf(portid, "%2d %6ld %10s %M %lI\n",
    568674                                    ix,
    569675                                    cache[ix].state == ND6_LLINFO_STALE ||
    570                                     (uint32_t)(cache[ix].expire - now) <= 0
    571                                         ? 0 : (cache[ix].expire - now) / SYSTIM_HZ,
     676                                    (uint32_t)((int32_t)(cache[ix].expire - now) <= 0
     677                                         ? 0 : (int32_t)(cache[ix].expire - now) / SYSTIM_HZ),
    572678                                    nd_state_str[cache[ix].state],
    573679                                    &cache[ix].ifaddr,
     
    581687
    582688#endif  /* of #if defined(SUPPORT_INET6) */
     689
     690#if defined(SUPPORT_INET4)
     691
     692/*
     693 *  ifa4_status -- ARP キャッシュ出力
     694 */
     695
     696static void
     697ifa4_status (ID portid, char *line)
     698{
     699        const T_ARP_ENTRY       *cache;
     700        int_t                   ix;
     701
     702        WAI_NET_CONS_PRINTF();
     703        cons_printf(portid,
     704                    "ARP Cache\n"
     705                    "IX Expire MAC Address       IP Address\n");
     706
     707        /* expire の単位は [ms]。*/
     708        cache = arp_get_cache();
     709        for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
     710                if (cache[ix].expire != 0)
     711                        cons_printf(portid, "%2d %6d %M %hI\n",
     712                                            ix, cache[ix].expire / NET_TIMER_HZ,
     713                                            cache[ix].mac_addr, &cache[ix].ip_addr);
     714                }
     715
     716        SIG_NET_CONS_PRINTF();
     717        FLUSH_SND_BUFF();
     718        }
     719
     720#endif  /* of #if defined(SUPPORT_INET4) */
    583721
    584722#endif  /* of #ifdef SUPPORT_ETHER */
     
    673811
    674812#endif  /* of #ifdef SUPPORT_ETHER */
     813
     814#if defined(SUPPORT_INET6)
     815
     816        cons_printf(portid, "\nIPv6\n");
     817        cons_printf(portid, "\t受信オクテット数\t%lu\n",                net_count_ip6[NC_IP6_IN_OCTETS]);
     818        cons_printf(portid, "\t受信データグラム数\t%lu\n",               net_count_ip6[NC_IP6_IN_PACKETS]);
     819        cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n",    net_count_ip6[NC_IP6_IN_ERR_PACKETS]);
     820        cons_printf(portid, "\t長さエラー数\t%lu\n",                  net_count_ip6[NC_IP6_IN_ERR_SHORT]);
     821        cons_printf(portid, "\tバージョンエラー数\t%lu\n",               net_count_ip6[NC_IP6_IN_ERR_VER]);
     822        cons_printf(portid, "\tアドレスエラー数\t%lu\n",                net_count_ip6[NC_IP6_IN_ERR_ADDR]);
     823        cons_printf(portid, "\tプロトコルエラー数\t%lu\n",               net_count_ip6[NC_IP6_IN_ERR_PROTO]);
     824        cons_printf(portid, "\t分割受信数\t%lu\n",                   net_count_ip6[NC_IP6_FRAG_IN]);
     825        cons_printf(portid, "\t分割受信フラグメント数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);
     826        cons_printf(portid, "\t分割受信再構成成功数\t%lu\n",              net_count_ip6[NC_IP6_FRAG_IN_OK]);
     827        cons_printf(portid, "\t分割受信破棄数\t%lu\n",                 net_count_ip6[NC_IP6_FRAG_IN_DROP]);
     828        cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n",  net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);
     829        cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);
     830        cons_printf(portid, "\t送信オクテット数\t%lu\n",                net_count_ip6[NC_IP6_OUT_OCTETS]);
     831        cons_printf(portid, "\t送信データグラム数\t%lu\n",               net_count_ip6[NC_IP6_OUT_PACKETS]);
     832        cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n",    net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);
     833        cons_printf(portid, "\t分割送信数\t%lu\n",                   net_count_ip6[NC_IP6_FRAG_OUT]);
     834        cons_printf(portid, "\t分割送信フラグメント数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);
     835
     836        cons_printf(portid, "\nICMPv6\n");
     837        cons_printf(portid, "\t受信オクテット数\t%lu\n",                net_count_icmp6[NC_ICMP6_IN_OCTETS]);
     838        cons_printf(portid, "\t受信パケット数\t%lu\n",                 net_count_icmp6[NC_ICMP6_IN_PACKETS]);
     839        cons_printf(portid, "\t受信エラーパケット数\t%lu\n",              net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);
     840        cons_printf(portid, "\t受信チックサムエラー数\t%lu\n",             net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);
     841        cons_printf(portid, "\t送信オクテット数\t%lu\n",                net_count_icmp6[NC_ICMP6_OUT_OCTETS]);
     842        cons_printf(portid, "\t送信パケット数\t%lu\n",                 net_count_icmp6[NC_ICMP6_OUT_PACKETS]);
     843        cons_printf(portid, "\t送信エラーパケット数\t%lu\n",              net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);
     844
     845        cons_printf(portid, "\n近隣探索\n");
     846        cons_printf(portid, "\tルータ通知受信数\t%lu\n",                net_count_nd6[NC_ND6_RA_IN_PACKETS]);
     847        cons_printf(portid, "\tルータ要請送信数\t%lu\n",                net_count_nd6[NC_ND6_RS_OUT_PACKETS]);
     848        cons_printf(portid, "\t近隣通知受信数\t%lu\n",                 net_count_nd6[NC_ND6_NA_IN_PACKETS]);
     849        cons_printf(portid, "\t近隣通知送信数\t%lu\n",                 net_count_nd6[NC_ND6_NA_OUT_PACKETS]);
     850        cons_printf(portid, "\t近隣要請受信数\t%lu\n",                 net_count_nd6[NC_ND6_NS_IN_PACKETS]);
     851        cons_printf(portid, "\t近隣要請送信数\t%lu\n",                 net_count_nd6[NC_ND6_NS_OUT_PACKETS]);
     852        cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n",             net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);
     853
     854#else   /* of #if defined(SUPPORT_INET6) */
    675855
    676856#if defined(SUPPORT_INET4)
     
    707887
    708888#endif  /* of #if defined(SUPPORT_INET4) */
    709 
    710 #if defined(SUPPORT_INET6)
    711 
    712         cons_printf(portid, "\nIPv6\n");
    713         cons_printf(portid, "\t受信オクテット数\t%lu\n",                net_count_ip6[NC_IP6_IN_OCTETS]);
    714         cons_printf(portid, "\t受信データグラム数\t%lu\n",               net_count_ip6[NC_IP6_IN_PACKETS]);
    715         cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n",    net_count_ip6[NC_IP6_IN_ERR_PACKETS]);
    716         cons_printf(portid, "\t長さエラー数\t%lu\n",                  net_count_ip6[NC_IP6_IN_ERR_SHORT]);
    717         cons_printf(portid, "\tバージョンエラー数\t%lu\n",               net_count_ip6[NC_IP6_IN_ERR_VER]);
    718         cons_printf(portid, "\tアドレスエラー数\t%lu\n",                net_count_ip6[NC_IP6_IN_ERR_ADDR]);
    719         cons_printf(portid, "\tプロトコルエラー数\t%lu\n",               net_count_ip6[NC_IP6_IN_ERR_PROTO]);
    720         cons_printf(portid, "\t分割受信数\t%lu\n",                   net_count_ip6[NC_IP6_FRAG_IN]);
    721         cons_printf(portid, "\t分割受信フラグメント数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);
    722         cons_printf(portid, "\t分割受信再構成成功数\t%lu\n",              net_count_ip6[NC_IP6_FRAG_IN_OK]);
    723         cons_printf(portid, "\t分割受信破棄数\t%lu\n",                 net_count_ip6[NC_IP6_FRAG_IN_DROP]);
    724         cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n",  net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);
    725         cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);
    726         cons_printf(portid, "\t送信オクテット数\t%lu\n",                net_count_ip6[NC_IP6_OUT_OCTETS]);
    727         cons_printf(portid, "\t送信データグラム数\t%lu\n",               net_count_ip6[NC_IP6_OUT_PACKETS]);
    728         cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n",    net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);
    729         cons_printf(portid, "\t分割送信数\t%lu\n",                   net_count_ip6[NC_IP6_FRAG_OUT]);
    730         cons_printf(portid, "\t分割送信フラグメント数\t%lu\n",             net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);
    731 
    732         cons_printf(portid, "\nICMPv6\n");
    733         cons_printf(portid, "\t受信オクテット数\t%lu\n",                net_count_icmp6[NC_ICMP6_IN_OCTETS]);
    734         cons_printf(portid, "\t受信パケット数\t%lu\n",                 net_count_icmp6[NC_ICMP6_IN_PACKETS]);
    735         cons_printf(portid, "\t受信エラーパケット数\t%lu\n",              net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);
    736         cons_printf(portid, "\t受信チックサムエラー数\t%lu\n",             net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);
    737         cons_printf(portid, "\t送信オクテット数\t%lu\n",                net_count_icmp6[NC_ICMP6_OUT_OCTETS]);
    738         cons_printf(portid, "\t送信パケット数\t%lu\n",                 net_count_icmp6[NC_ICMP6_OUT_PACKETS]);
    739         cons_printf(portid, "\t送信エラーパケット数\t%lu\n",              net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);
    740 
    741         cons_printf(portid, "\n近隣探索\n");
    742         cons_printf(portid, "\tルータ通知受信数\t%lu\n",                net_count_nd6[NC_ND6_RA_IN_PACKETS]);
    743         cons_printf(portid, "\tルータ要請送信数\t%lu\n",                net_count_nd6[NC_ND6_RS_OUT_PACKETS]);
    744         cons_printf(portid, "\t近隣通知受信数\t%lu\n",                 net_count_nd6[NC_ND6_NA_IN_PACKETS]);
    745         cons_printf(portid, "\t近隣通知送信数\t%lu\n",                 net_count_nd6[NC_ND6_NA_OUT_PACKETS]);
    746         cons_printf(portid, "\t近隣要請受信数\t%lu\n",                 net_count_nd6[NC_ND6_NS_IN_PACKETS]);
    747         cons_printf(portid, "\t近隣要請送信数\t%lu\n",                 net_count_nd6[NC_ND6_NS_OUT_PACKETS]);
    748         cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n",             net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);
    749889
    750890#endif  /* of #if defined(SUPPORT_INET6) */
     
    787927
    788928        tbl = nbuf_get_tbl();
    789         cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t割当要求数\t割当数\t割当てエラー数\n");
     929        cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n");
    790930        for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
    791                 cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\n",
     931                cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
    792932                                    tbl[ix].size,
    793933                                    tbl[ix].prepares,
     934                                    tbl[ix].busies,
    794935                                    tbl[ix].requests,
    795936                                    tbl[ix].allocs,
     
    833974        for (ix = nbuf_get_tbl_size(); ix -- > 0; )
    834975                cons_printf(portid, "\t%d", tbl[ix].size);
    835         cons_printf(portid, "\n");
     976        cons_putchar(portid, '\n');
    836977
    837978        queue = ip_get_frag_queue();
     
    846987                                cons_printf(portid, "\t%d", count);
    847988                                }
    848                         cons_printf(portid, "\n");
     989                        cons_putchar(portid, '\n');
    849990                        }
    850991                }
     
    8741015        for (ix = nbuf_get_tbl_size(); ix -- > 0; )
    8751016                cons_printf(portid, "\t%d", tbl[ix].size);
    876         cons_printf(portid, "\n");
     1017        cons_putchar(portid, '\n');
    8771018
    8781019        queue = ip6_get_frag_queue();
     
    8871028                                cons_printf(portid, "\t%d", count);
    8881029                                }
    889                         cons_printf(portid, "\n");
     1030                        cons_putchar(portid, '\n');
    8901031                        }
    8911032                }
     
    9181059
    9191060#ifdef TCP_CFG_SWBUF_CSAVE
    920         T_IP_HDR*               iph;
    9211061        T_TCP_HDR*              tcph;
    9221062#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
     
    9251065        WAI_NET_CONS_PRINTF();
    9261066        get_tim(&now);
    927         cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%lu\n", now);
     1067        cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%u\n", now);
    9281068
    9291069#if NET_COUNT_ENABLE
    9301070
    931         cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t割当要求数\t割当数\t割当てエラー数\n");
     1071        cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n");
    9321072        tbl = nbuf_get_tbl();
    9331073        for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
    934                 cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\n",
     1074                cons_printf(portid, "\t%u\t%u\t%u\t%u\t%u\t%u\n",
    9351075                                    tbl[ix].size,
    9361076                                    tbl[ix].prepares,
     1077                                    tbl[ix].busies,
    9371078                                    tbl[ix].requests,
    9381079                                    tbl[ix].allocs,
     
    9491090                cons_printf(portid, "%2d", GET_TCP_CEPID(cep));
    9501091                for (nbuf = cep->reassq; nbuf != NULL; nbuf = tqhdr->next) {
    951                         tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_IP_Q_HDR(nbuf)->thoff);
    952                         cons_printf(portid, "[a:%6d-%6d] ",
     1092                        tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
     1093                        cons_printf(portid, "[a:%6lu-%6lu] ",
    9531094                                    ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
    9541095                                    ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
     
    9571098#ifdef TCP_CFG_RWBUF_CSAVE
    9581099                for (nbuf = cep->rwbufq; nbuf != NULL; nbuf = tqhdr->next) {
    959                         tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_IP_Q_HDR(nbuf)->thoff);
    960                         cons_printf(portid, "[r:%6d-%6d] ",
     1100                        tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
     1101                        cons_printf(portid, "[r:%6lu-%6lu] ",
    9611102                                    ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
    9621103                                    ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
     
    9661107#ifdef TCP_CFG_SWBUF_CSAVE
    9671108                if (cep->swbufq != NULL) {
    968                         iph  = GET_IP_HDR(cep->swbufq);
    9691109                        tcph = GET_TCP_HDR(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq));
    970                         cons_printf(portid, "[s:%6d-%6d] ",
     1110#if 0
     1111                        cons_printf(portid, "[s:%6lu-%6lu] ",
    9711112                                    ntohl(tcph->seq) - cep->iss,
    972                                     ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(iph) -
    973                                                                    GET_TCP_HDR_SIZE2(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))));
     1113                                    ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) -
     1114                                                                   GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))));
     1115#else
     1116                        cons_printf(portid, "[s:%6lu-%6lu,%08x,%08x] ",
     1117                                    ntohl(tcph->seq) - cep->iss,
     1118                                    ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) -
     1119                                                                   GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))),
     1120                                    ntohl(tcph->seq), cep->iss);
     1121#endif
    9741122                        }
    9751123#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
    9761124
    977                 cons_printf(portid, "\n");
     1125                cons_putchar(portid, '\n');
    9781126                }
    9791127
     
    10081156        }
    10091157
     1158#ifdef USE_RESOLVER
     1159
     1160/*
     1161 *  show_dns_soa -- DNS の SOA RDATA を表示する。
     1162 */
     1163
     1164static ER_UINT
     1165show_dns_soa (ID portid, uint8_t *msg, ER_UINT length, uint_t offset)
     1166{
     1167        T_RSLV_SOA      soa;
     1168        ER_UINT         error;
     1169        uint_t          rn_offset;
     1170
     1171        if ((error = dns_analyze_soa(&soa, offset, msg, length)) < 0)
     1172                return error;
     1173
     1174        cons_printf(portid, "    mname:   ");
     1175        rn_offset = show_dns_domain_name(portid, msg, offset);
     1176        cons_putchar(portid, '\n');
     1177        cons_printf(portid, "    rname:   ");
     1178        show_dns_domain_name(portid, msg, rn_offset);
     1179        cons_putchar(portid, '\n');
     1180
     1181        cons_printf(portid, "    serial:  %d\n", soa.serial);
     1182        cons_printf(portid, "    refresh: %d\n", soa.refresh);
     1183        cons_printf(portid, "    retry:   %d\n", soa.retry);
     1184        cons_printf(portid, "    expirel: %d\n", soa.expire);
     1185        cons_printf(portid, "    minimum: %d\n", soa.minimum);
     1186
     1187        return E_OK;
     1188        }
     1189
     1190/*
     1191 *  show_dns_qdsection -- DNS の Question セクションを表示する。
     1192 */
     1193
     1194static ER_UINT
     1195show_dns_qdsection (ID portid, uint8_t *msg, ER_UINT length, T_RSLV_DNS_MSG *rslv)
     1196{
     1197        T_RSLV_QD       qd;
     1198        ER_UINT         offset, error;
     1199        int             scount;
     1200
     1201        cons_printf(portid, "question   section: %d\n", rslv->dns_hdr.qdcount);
     1202        offset = rslv->qd_offset;
     1203        for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount ++) {
     1204                if ((error = dns_analyze_qd(&qd, offset, msg, length)) < 0)
     1205                        return error;
     1206
     1207                cons_printf(portid, "%2d: ", scount);
     1208                show_dns_domain_name(portid, msg, offset);
     1209                cons_printf(portid, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
     1210                offset = error;
     1211                }
     1212
     1213        return E_OK;
     1214        }
     1215
     1216/*
     1217 *  show_dns_section -- DNS の各セクションを表示する。
     1218 */
     1219
     1220static ER_UINT
     1221show_dns_section (ID portid, uint8_t *msg, ER_UINT length, uint_t scount, uint_t offset, char *title)
     1222{
     1223        T_RSLV_RR       rr;
     1224        T_IN4_ADDR      in4_addr;
     1225        ER_UINT         error;
     1226        int             count, dcount, col;
     1227        T_IN6_ADDR      in6_addr;
     1228
     1229        cons_printf(portid, "%10s section: %d\n", title, scount);
     1230        for (count = 1; count <= scount; count ++) {
     1231                if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
     1232                        return error;
     1233
     1234                cons_printf(portid, "%2d: ", count);
     1235                show_dns_domain_name(portid, msg, offset);
     1236                cons_printf(portid, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
     1237                            dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
     1238
     1239                switch (rr.type) {
     1240                case DNS_TYPE_A:
     1241                        memcpy((void*)&in4_addr, (void*)(msg + rr.rdata_offset), sizeof(in4_addr));
     1242                        in4_addr = ntohl(in4_addr);
     1243                        cons_printf(portid, "    IPv4 addr: %hI\n", &in4_addr);
     1244                        break;
     1245                case DNS_TYPE_NS:
     1246                        cons_printf(portid, "    host: ");
     1247                        show_dns_domain_name(portid, msg, rr.rdata_offset);
     1248                        cons_putchar(portid, '\n');
     1249                        break;
     1250                case DNS_TYPE_CNAME:
     1251                        cons_printf(portid, "    host: ");
     1252                        show_dns_domain_name(portid, msg, rr.rdata_offset);
     1253                        cons_putchar(portid, '\n');
     1254                        break;
     1255                case DNS_TYPE_SOA:
     1256                        show_dns_soa(portid, msg, length, rr.rdata_offset);
     1257                        break;
     1258                case DNS_TYPE_PTR:
     1259                        cons_printf(portid, "     PTR: ");
     1260                        show_dns_domain_name(portid, msg, rr.rdata_offset);
     1261                        cons_putchar(portid, '\n');
     1262                        break;
     1263                case DNS_TYPE_AAAA:
     1264                        memcpy((void*)&in6_addr, (void*)(msg + rr.rdata_offset), sizeof(in6_addr));
     1265                        cons_printf(portid, "    IPv6 addr: %lI\n", &in6_addr);
     1266                        break;
     1267                default:
     1268                        cons_printf(portid, "    data: ");
     1269                        col = 32;
     1270                        for (dcount = 0; dcount < rr.rdlength; dcount ++) {
     1271                                cons_printf(portid, "%02x", *(msg + rr.rdata_offset + dcount));
     1272                                if (-- col == 0) {
     1273                                        cons_printf(portid, "\n          ");
     1274                                        col = 32;
     1275                                        }
     1276                                }
     1277                        cons_putchar(portid, '\n');
     1278                        break;
     1279                        }
     1280                }
     1281
     1282        return E_OK;
     1283        }
     1284/*
     1285 *  dns_info -- DNS 情報の表示
     1286 */
     1287
     1288static void
     1289dns_info (ID portid)
     1290{
     1291#if defined(SUPPORT_INET6)
     1292        T_IN6_ADDR      in6_addr;
     1293#endif
    10101294#if defined(SUPPORT_INET4)
    1011 
    1012 #if NUM_ROUTE_ENTRY > 0
     1295        T_IN4_ADDR      in4_addr;
     1296#endif
     1297
     1298#if defined(SUPPORT_INET6)
     1299
     1300        cons_printf(portid, "domain name:     %s\n", dns_in6_get_dname());
     1301
     1302#else   /* of #if defined(SUPPORT_INET6) */
     1303
     1304        cons_printf(portid, "domain name:     %s\n", dns_in4_get_dname());
     1305
     1306#endif  /* of #if defined(SUPPORT_INET6) */
     1307
     1308#if defined(SUPPORT_INET6)
     1309        dns_in6_get_addr(&in6_addr);
     1310        cons_printf(portid, "IPv6 DNS server: ");
     1311        if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
     1312                cons_printf(portid, "not available.\n");
     1313        else
     1314                cons_printf(portid, "%lI.\n", &in6_addr);
     1315#endif  /* of #if defined(SUPPORT_INET6) */
     1316
     1317#if defined(SUPPORT_INET4)
     1318        dns_in4_get_addr(&in4_addr);
     1319        cons_printf(portid, "IPv4 DNS server: ");
     1320        if (in4_addr == IPV4_ADDRANY)
     1321                cons_printf(portid, "not available.\n");
     1322        else
     1323                cons_printf(portid, "%hI.\n", &in4_addr);
     1324#endif  /* of #if defined(SUPPORT_INET4) */
     1325        }
    10131326
    10141327/*
    1015  *  routing_table_status -- 経路表の出力
    1016  */
     1328 *  name_lookup -- ホスト名-IP アドレス変換
     1329 */
     1330
     1331const char *rcode_str[] = {
     1332        "no error",
     1333        "format error",
     1334        "server error",
     1335        "name error",
     1336        "not implement",
     1337        "refused",
     1338        };
    10171339
    10181340static void
    1019 routing_table_status (ID portid, char *line)
    1020 {
    1021         int_t   ix;
    1022 
    1023         if ('0' <= *(line = skip_blanks(line)) && *line <= '9') {
    1024                 T_IN4_ADDR      target, mask, gateway;
    1025 
    1026                 ix = atoi(line);
    1027                 while ('0' <= *line && *line <= '9')
    1028                         line ++;
    1029                 line = GET_IPADDR(&target,  skip_blanks(line));
    1030                 line = GET_IPADDR(&mask,    skip_blanks(line));
    1031                        GET_IPADDR(&gateway, skip_blanks(line));
    1032                 in4_add_route(ix, target, mask, gateway);
    1033                 }
    1034 
     1341name_lookup (ID portid, char *line)
     1342{
     1343        static char hostname[DBG_LINE_SIZE + 1];
     1344
     1345        T_RSLV_DNS_MSG  rslv;
     1346        ER_UINT         length, offset;
     1347        ER              error;
     1348        uint_t          flags = 0;
     1349        uint8_t         *msg;
     1350
     1351        /* コマンドのオプションを設定する。*/
     1352        line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
     1353        if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
     1354                cons_printf(portid, "DNS server not available.\n");
     1355                return;
     1356                }
     1357
     1358        /* 照会するホスト名・IP アドレスを解析する。*/
     1359        resolv_hoststr(&flags, hostname, sizeof(hostname), line);
     1360
     1361        /* 正引きでも逆引きでもプロトコル上は正引きを指定する。*/
     1362        flags |= DNS_LUP_OPCODE_FORWARD;
     1363
     1364        /* IPv6 アドレス、または IPv4 アドレスが指定された時は、照会タイプは PTR に設定する。*/
     1365        if (((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV6) ||
     1366            ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV4))
     1367                flags = (flags & ~DNS_LUP_FLAGS_QTYPE_MASK) | DNS_LUP_FLAGS_QTYPE_PTR;
     1368
     1369        if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
     1370                cons_printf(portid, "get buffer error: %s.\n", itron_strerror(error));
     1371                return;
     1372                }
     1373
     1374        if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
     1375                //cons_printf(portid, "error: %s.\n", itron_strerror(length));
     1376                goto err_ret;
     1377                }
     1378
     1379        dly_tsk(1 * 1000);
     1380        cons_printf(portid, "DNS header: flags: ");
     1381        if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE     |
     1382                                 DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
     1383                cons_printf(portid, (rslv.dns_hdr.code & DNS_QR_RESPONSE)         ? "QR," : "");
     1384                cons_printf(portid, (rslv.dns_hdr.code & DNS_AUTHORITATIVE)       ? "AA," : "");
     1385                cons_printf(portid, (rslv.dns_hdr.code & DNS_TRUN_CATION)         ? "TC," : "");
     1386                cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED)   ? "RD," : "");
     1387                cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
     1388                cons_printf(portid, " ");
     1389                }
     1390        cons_printf(portid, "opcode: ");
     1391        cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE)      ? "RV"  : "FW");
     1392        cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_STATUS)       ? ",ST" : "");
     1393        cons_printf(portid, ", rcode: %s.\n",
     1394                    (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
     1395                        ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
     1396
     1397        if ((offset = show_dns_qdsection(portid, msg, length, &rslv)) < 0) {
     1398                cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
     1399                }
     1400        if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
     1401                cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
     1402                }
     1403        if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
     1404                cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
     1405                }
     1406        if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
     1407                cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
     1408                }
     1409
     1410err_ret:
     1411        if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
     1412                cons_printf(portid, "release buffer error: %s.\n", itron_strerror(error));
     1413        return;
     1414        }
     1415
     1416#endif   /* of #ifdef USE_RESOLVER */
     1417
     1418#if defined(DHCP6_CLI_CFG)
     1419
     1420/*
     1421 *  dhcp6c_info -- DHCPv6 クライアント情報の表示
     1422 */
     1423
     1424static void
     1425dhcp6c_info (ID portid)
     1426{
     1427        T_IN6_ADDR      svaddr;
     1428        SYSTIM          bind_start;
     1429        ER              error;
     1430        uint32_t        expire, renew, rebind, deprefer;
     1431
     1432        if ((error = dhcp6c_get_info(&svaddr, &expire, &renew, &rebind, &deprefer, &bind_start)) == E_OK) {
     1433                cons_printf(portid, "      DHCPv6 server: %lI.\n", &svaddr);
     1434
     1435#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
     1436       
     1437                cons_printf(portid, "      DHCPv6 mode:   stateless.\n");
     1438
     1439#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
     1440
     1441                cons_printf(portid, "      DHCPv6 mode:   statefull,\n");
     1442                cons_printf(portid, "        Renew:       %u:%02u:%02u, Deprefer: %u:%02u:%02u,\n",
     1443                                       renew / 3600, (   renew / 60) % 60,    renew % 60,
     1444                                    deprefer / 3600, (deprefer / 60) % 60, deprefer % 60);
     1445                cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     1446                                      rebind / 3600, (  rebind / 60) % 60,   rebind % 60,
     1447                                      expire / 3600, (  expire / 60) % 60,   expire % 60);
     1448
     1449#else   /* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
     1450
     1451#endif  /* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
     1452
     1453                }
     1454        else if (error == E_OBJ)
     1455                cons_printf(portid, "      DHCPv6 server: not available.\n");
     1456        }
     1457
     1458#endif  /* of #if defined(DHCP6_CLI_CFG) */
     1459
     1460#if defined(DHCP4_CLI_CFG)
     1461
     1462/*
     1463 *  dhcp4c_info -- DHCPv4 クライアント情報の表示
     1464 */
     1465
     1466static void
     1467dhcp4c_info (ID portid)
     1468{
     1469        T_IN4_ADDR      svaddr;
     1470        SYSTIM          bind_start;
     1471        ER              error;
     1472        uint32_t        expire, renew, rebind;
     1473
     1474        if ((error = dhcp4c_get_info(&svaddr, &expire, &renew, &rebind, &bind_start)) == E_OK) {
     1475                cons_printf(portid, "      DHCPv4 server: %hI,\n", &svaddr);
     1476                cons_printf(portid, "        Renew:       %u:%02u:%02u,\n",
     1477                                      renew  / 3600, (renew  / 60) % 60, renew % 60);
     1478                cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     1479                                      rebind / 3600, (rebind / 60) % 60, rebind % 60,
     1480                                      expire / 3600, (expire / 60) % 60, expire % 60);
     1481                }
     1482        else if (error == E_OBJ)
     1483                cons_printf(portid, "      DHCPv4 server: not available.\n");
     1484        }
     1485
     1486#endif  /* of #if defined(DHCP4_CLI_CFG) */
     1487
     1488#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
     1489
     1490/*
     1491 *  dhcpc -- DHCP クライアント情報の表示と制御
     1492 */
     1493
     1494static void
     1495dhcpc (ID portid, char *line)
     1496{
    10351497        WAI_NET_CONS_PRINTF();
    1036         cons_printf(portid,
    1037                     "Routing Table Status\n"
    1038                     "IX Target          Mask            Gateway         Expire\n");
    1039 
    1040         for (ix = 0; ix < NUM_ROUTE_ENTRY; ix ++) {
    1041                 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) == 0)
    1042                         ;
    1043                 else if ((routing_tbl[ix].flags & IN_RTF_REDIRECT) != 0)
    1044                         cons_printf(portid, "%2d %15I %15I %15I %4d\n",
    1045                                     ix,
    1046                                     &routing_tbl[ix].target,
    1047                                     &routing_tbl[ix].mask,
    1048                                     &routing_tbl[ix].gateway,
    1049                                     &routing_tbl[ix].expire);
    1050                 else
    1051                         cons_printf(portid, "%2d %15I %15I %I\n",
    1052                                     ix,
    1053                                     &routing_tbl[ix].target,
    1054                                     &routing_tbl[ix].mask,
    1055                                     &routing_tbl[ix].gateway);
    1056                            
     1498
     1499        switch (*line) {
     1500
     1501#if defined(DHCP6_CLI_CFG)
     1502        case '6':                       /* DHCPv6 の制御 */
     1503                switch (*(line + 1)) {
     1504                case 'r':               /* アドレス情報を解放する。*/
     1505                        dhcp6c_rel_info();
     1506                        break;
     1507
     1508                case 'n':               /* アドレス情報を再取得する。*/
     1509                        dhcp6c_renew_info();
     1510                        break;
     1511
     1512                default:
     1513                        dhcp6c_info(portid);
     1514                        break;
     1515                        }
     1516                break;
     1517#endif  /* of #if defined(DHCP6_CLI_CFG) */
     1518
     1519#if defined(DHCP4_CLI_CFG)
     1520        case '4':               /* DHCPv4 の制御 */
     1521                switch (*(line + 1)) {
     1522                case 'r':               /* アドレス情報を解放する。*/
     1523                        dhcp4c_rel_info();
     1524                        break;
     1525
     1526                case 'n':               /* アドレス情報を再取得する。*/
     1527                        dhcp4c_renew_info();
     1528                        break;
     1529
     1530                default:
     1531                        dhcp4c_info(portid);
     1532                        break;
     1533                        }
     1534                break;
     1535#endif  /* of #if defined(DHCP4_CLI_CFG) */
     1536
     1537        default:
     1538
     1539#if defined(DHCP6_CLI_CFG)
     1540                dhcp6c_info(portid);
     1541#endif
     1542
     1543#if defined(DHCP4_CLI_CFG)
     1544                dhcp4c_info(portid);
     1545#endif
     1546                break;
    10571547                }
    10581548
     
    10611551        }
    10621552
    1063 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
    1064 
    1065 #endif  /* of #if defined(SUPPORT_INET4) */
     1553#endif  /* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
    10661554
    10671555#if defined(SUPPORT_INET6)
     
    11241612                        while (ptitle -- > 0)
    11251613                                cons_printf(portid, " ");
    1126                         cons_printf(portid, " %I\n",  &dr[rix].addr);
     1614                        cons_printf(portid, " %lI\n",  &dr[rix].addr);
    11271615                        }
    11281616                }
     
    11881676                        while (rtitle -- > 0)
    11891677                                cons_printf(portid, " ");
    1190                         cons_printf(portid, "%4d %I\n",  pr[pix].prefix_len, &pr[pix].prefix);
     1678                        cons_printf(portid, "%4d %lI\n",  pr[pix].prefix_len, &pr[pix].prefix);
    11911679                        }
    11921680                }
     
    11981686#endif  /* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
    11991687
    1200 #if NUM_ROUTE_ENTRY > 0
     1688#if NUM_IN6_ROUTE_ENTRY > 0
    12011689
    12021690/*
    1203  *  routing_table_status -- 経路表の出力
     1691 *  routing6_table_status -- 経路表(IPv6)の出力
    12041692 */
    12051693
    12061694static void
    1207 routing_table_status (ID portid, char *line)
     1695routing6_table_status (ID portid, char *line)
    12081696{
    12091697        SYSTIM  now;
     
    12121700        WAI_NET_CONS_PRINTF();
    12131701        cons_printf(portid,
    1214                     "Routing Table Status\n"
     1702                    "\nRouting Table Status (IPv6)\n"
    12151703                    "IX Expire flags Prefix Target                         Gateway\n");
    12161704
    1217         for (ix = 0; ix < NUM_STATIC_ROUTE_ENTRY; ix ++) {
    1218                 cons_printf(portid, "%2d STATIC     - %6d %30I %I\n",
     1705        for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++) {
     1706                cons_printf(portid, "%2d STATIC     - %6d %30lI %lI\n",
    12191707                            ix,
    1220                              routing_tbl[ix].prefix_len,
    1221                             &routing_tbl[ix].target,
    1222                             &routing_tbl[ix].gateway);
     1708                             routing6_tbl[ix].prefix_len,
     1709                            &routing6_tbl[ix].target,
     1710                            &routing6_tbl[ix].gateway);
    12231711                           
    12241712                }
     
    12281716        now /= SYSTIM_HZ;
    12291717
    1230         for ( ; ix < NUM_ROUTE_ENTRY; ix ++)
    1231                 if (routing_tbl[ix].flags & IN_RTF_DEFINED)
    1232                         cons_printf(portid, "%2d %6d    %02x %6d %30I %I\n",
     1718        for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
     1719                if (routing6_tbl[ix].flags & IN_RTF_DEFINED)
     1720                        cons_printf(portid, "%2d %6d    %02x %6d %30lI %lI\n",
    12331721                                    ix,
    1234                                     (uint32_t)(routing_tbl[ix].expire - now) <= 0
    1235                                         ? 0 : routing_tbl[ix].expire - now,
    1236                                      routing_tbl[ix].flags,
    1237                                      routing_tbl[ix].prefix_len,
    1238                                     &routing_tbl[ix].target,
    1239                                     &routing_tbl[ix].gateway);
     1722                                    (uint32_t)(routing6_tbl[ix].expire - now) <= 0
     1723                                        ? 0 : routing6_tbl[ix].expire - now,
     1724                                     routing6_tbl[ix].flags,
     1725                                     routing6_tbl[ix].prefix_len,
     1726                                    &routing6_tbl[ix].target,
     1727                                    &routing6_tbl[ix].gateway);
    12401728
    12411729        SIG_NET_CONS_PRINTF();
     
    12431731        }
    12441732
    1245 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
     1733#endif  /* of #if NUM_IN6_ROUTE_ENTRY > 0 */
    12461734
    12471735#endif  /* of #if defined(SUPPORT_INET6) */
    12481736
    1249 #if NUM_ROUTE_ENTRY > 0
     1737#if defined(SUPPORT_INET4)
     1738
     1739#if NUM_IN4_ROUTE_ENTRY > 0
    12501740
    12511741/*
    1252  *  routing_status -- ルーティング情報
     1742 *  routing4_table_status -- 経路表(IPv4)の出力
     1743 */
     1744
     1745static void
     1746routing4_table_status (ID portid, char *line)
     1747{
     1748        int_t   ix;
     1749
     1750        if ('0' <= *(line = skip_blanks(line)) && *line <= '9') {
     1751                T_IN4_ADDR      target, mask, gateway;
     1752
     1753                ix = atoi(line);
     1754                while ('0' <= *line && *line <= '9')
     1755                        line ++;
     1756                line = get_ipv4addr(&target,  skip_blanks(line));
     1757                line = get_ipv4addr(&mask,    skip_blanks(line));
     1758                       get_ipv4addr(&gateway, skip_blanks(line));
     1759                in4_add_route(ix, target, mask, gateway);
     1760                }
     1761
     1762        WAI_NET_CONS_PRINTF();
     1763        cons_printf(portid,
     1764                    "\nRouting Table Status (IPv4)\n"
     1765                    "IX Target          Mask            Gateway         Expire\n");
     1766
     1767        for (ix = 0; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
     1768                if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0)
     1769                        ;
     1770                else if ((routing4_tbl[ix].flags & IN_RTF_REDIRECT) != 0)
     1771                        cons_printf(portid, "%2d %15hI %15hI %15hI %4d\n",
     1772                                    ix,
     1773                                    &routing4_tbl[ix].target,
     1774                                    &routing4_tbl[ix].mask,
     1775                                    &routing4_tbl[ix].gateway,
     1776                                    &routing4_tbl[ix].expire);
     1777                else
     1778                        cons_printf(portid, "%2d %15hI %15hI %hI\n",
     1779                                    ix,
     1780                                    &routing4_tbl[ix].target,
     1781                                    &routing4_tbl[ix].mask,
     1782                                    &routing4_tbl[ix].gateway);
     1783                           
     1784                }
     1785
     1786        SIG_NET_CONS_PRINTF();
     1787        FLUSH_SND_BUFF();
     1788        }
     1789
     1790#endif  /* of #if NUM_IN4_ROUTE_ENTRY > 0 */
     1791
     1792#endif  /* of #if defined(SUPPORT_INET4) */
     1793
     1794/*
     1795 *  routing_status -- 経路情報
    12531796 */
    12541797
     
    12581801        switch (*line) {
    12591802
    1260 #if defined(SUPPORT_INET6)
    1261 
    1262 #if NUM_ND6_DEF_RTR_ENTRY > 0
     1803#if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0
    12631804
    12641805        case 'l':               /* ディフォルトルータ・リスト情報 */
     
    12701811                break;
    12711812
    1272 #endif  /* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
    1273 
    1274 #endif  /* of #if defined(SUPPORT_INET6) */
    1275 
    1276         default:                /* ルーティング表情報 */
    1277                 routing_table_status(portid, line);
     1813#endif  /* #if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0 */
     1814
     1815        default:
     1816
     1817                /* 経路表情報 */
     1818
     1819#if defined(SUPPORT_INET6) && NUM_IN6_ROUTE_ENTRY > 0
     1820                routing6_table_status(portid, line);
     1821#endif
     1822
     1823#if defined(SUPPORT_INET4) && NUM_IN4_ROUTE_ENTRY > 0
     1824                routing4_table_status(portid, line);
     1825#endif
     1826
    12781827                break;
    1279 
    1280                 break;
    1281                 }
    1282         }
    1283 
    1284 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
     1828                }
     1829        }
    12851830
    12861831/*
    1287  *  network_status -- ネットワークの状態の出力
    1288  */
    1289 
    1290 static void
    1291 network_status (ID portid, char *line)
     1832 *  dbg_cons_network_status -- ネットワークの状態の出力
     1833 */
     1834
     1835void
     1836dbg_cons_network_status (ID portid, char *line)
    12921837{
    12931838        switch (*line) {
     
    12961841
    12971842        case 'a':               /* IF アドレス情報 */
    1298                 ifa_status(portid, line + 1);
     1843
     1844#if defined(SUPPORT_INET6)
     1845                ifa6_status(portid, line + 1);
     1846#endif
     1847#if defined(SUPPORT_INET4)
     1848                ifa4_status(portid, line + 1);
     1849#endif
     1850
    12991851                break;
    13001852
     
    13131865#endif  /* of #if NET_COUNT_ENABLE */
    13141866
    1315 #if NUM_ROUTE_ENTRY > 0
    1316 
    1317         case 'r':               /* ルーティング情報 */
     1867        case 'r':               /* 経路情報 */
    13181868                routing_status(portid, line + 1);
    13191869                break;
    13201870
    1321 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
     1871#ifdef USE_RESOLVER
     1872
     1873        case 's':               /* name lookup */
     1874                if (*(line = skip_blanks(line + 1)) == '\0')
     1875                        dns_info(portid);
     1876                else
     1877                        name_lookup(portid, line);
     1878                break;
     1879
     1880#endif   /* of #ifdef USE_RESOLVER */
    13221881
    13231882#ifdef SUPPORT_TCP
     
    13381897
    13391898        default:
    1340                 cons_printf(portid, "no such command: '%c%c'\n", *(line - 1), *line);
     1899                cons_printf(portid, "no such command: '%c%c'.\n", *(line - 1), *line);
    13411900                SIG_NET_CONS_PRINTF();
    13421901                FLUSH_SND_BUFF();
     
    13451904        }
    13461905
    1347 #if defined(SUPPORT_INET4)
    1348 
    13491906/*
    1350  *  ifconfig -- ネットワークインタフェースの構成情報
    1351  */
    1352 
    1353 static void
    1354 ifconfig (ID portid, char *line)
    1355 {
    1356         T_IFNET         *ifp = IF_GET_IFNET();
    1357         T_IN4_ADDR      bc;
    1358 
     1907 *  dbg_cons_ifconfig -- ネットワークインタフェースの構成情報
     1908 */
     1909
     1910void
     1911dbg_cons_ifconfig (ID portid, char *line)
     1912{
    13591913#ifdef SUPPORT_ETHER
    13601914
    1361         if (*(line = skip_blanks(line))) {
    1362                 T_IN4_ADDR      addr, mask;
    1363 
    1364                 GET_IPADDR(&mask, skip_blanks(GET_IPADDR(&addr, line)));
    1365                 in4_add_ifaddr(addr, mask);
    1366                 }
    1367 
    1368 #endif  /* of #ifdef SUPPORT_ETHER */
     1915        T_IF_SOFTC      *ic;
    13691916
    13701917        WAI_NET_CONS_PRINTF();
    1371         cons_printf(portid,
    1372                     "Network Interface Configurations\n");
    1373 
    1374 #ifdef SUPPORT_ETHER
    1375 
    1376         cons_printf(portid,
    1377                     "ether: %M\n",
    1378                     IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr);
    1379 
    1380 #endif  /* of #ifdef SUPPORT_ETHER */
    1381 
    1382         bc = (ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask;
    1383         cons_printf(portid,
    1384                     "inet:  %I, mask: %I, broadcast: %I\n",
    1385                     &ifp->in_ifaddr.addr,
    1386                     &ifp->in_ifaddr.mask,
    1387                     &bc);
    1388 
     1918        ic = IF_ETHER_NIC_GET_SOFTC();
     1919        cons_printf(portid, "ether: %M\n", ic->ifaddr.lladdr);
    13891920        SIG_NET_CONS_PRINTF();
    13901921        FLUSH_SND_BUFF();
    1391         }
    1392 
    1393 #endif  /* of #if defined(SUPPORT_INET4) */
    1394 
    1395 #if defined(SUPPORT_INET6)
     1922
     1923#endif  /* of #ifdef SUPPORT_ETHER */
     1924        }
     1925
     1926#if defined(NETAPP_IP6_CFG)
    13961927
    13971928/*
    1398  *  ifconfig -- ネットワークインタフェースの構成情報
    1399  */
    1400 
    1401 static void
    1402 ifconfig (ID portid, char *line)
     1929 *  dbg_cons_ifconfig6 -- ネットワークインタフェース(IPv6)の構成情報
     1930 */
     1931
     1932void
     1933dbg_cons_ifconfig6 (ID portid, char *line)
    14031934{
    14041935#ifdef SUPPORT_ETHER
    14051936
    1406         T_IF_SOFTC      *ic;
    14071937        T_IFNET         *ifp = IF_GET_IFNET();
    14081938        int_t           ix;
     
    14101940
    14111941        WAI_NET_CONS_PRINTF();
    1412         ic = IF_ETHER_NIC_GET_SOFTC();
    1413         cons_printf(portid, "ether: %M\ninet6:\nIX   Expire Preffered RTR PFX Flags IP Address\n",
    1414                             ic->ifaddr.lladdr);
    14151942
    14161943        /* expire と vltime の単位は [s]。*/
     
    14181945        now /= SYSTIM_HZ;
    14191946
     1947        cons_printf(portid, "IPv6:\nIX   Expire Preffered RTR PFX Flags IP Address\n");
    14201948        for (ix = 0; ix < NUM_IN6_IFADDR_ENTRY; ix ++) {
    1421                 if (ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) {
     1949                if (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) {
    14221950                        cons_printf(portid, " %d", ix);
    1423                         if (ifp->in_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)
     1951                        if (ifp->in6_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)
    14241952                                cons_printf(portid, "    INFIN     INFIN");
    14251953                        else
    14261954                                cons_printf(portid, " %8d %9d",
    1427                                                     (uint32_t)(ifp->in_ifaddrs[ix].lifetime.expire - now) <= 0
    1428                                                         ? 0 : ifp->in_ifaddrs[ix].lifetime.expire - now,
    1429                                                     (uint32_t)(ifp->in_ifaddrs[ix].lifetime.preferred - now) <= 0
    1430                                                         ? 0 : ifp->in_ifaddrs[ix].lifetime.preferred - now);
    1431                         if (ifp->in_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)
     1955                                                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.expire - now) <= 0
     1956                                                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.expire - now,
     1957                                                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.preferred - now) <= 0
     1958                                                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.preferred - now);
     1959                        if (ifp->in6_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)
    14321960                                cons_printf(portid, "   -");
    14331961                        else
    1434                                 cons_printf(portid, " %3d", ifp->in_ifaddrs[ix].router_index);
    1435                         if (ifp->in_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)
     1962                                cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].router_index);
     1963                        if (ifp->in6_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)
    14361964                                cons_printf(portid, "   -");
    14371965                        else
    1438                                 cons_printf(portid, " %3d", ifp->in_ifaddrs[ix].prefix_index);
    1439                         cons_printf(portid, "    %02x %I\n",
    1440                                             ifp->in_ifaddrs[ix].flags,
    1441                                             &ifp->in_ifaddrs[ix].addr);
    1442                         }
    1443                 }
     1966                                cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].prefix_index);
     1967                        cons_printf(portid, "    %02x %lI\n",
     1968                                             ifp->in6_ifaddrs[ix].flags,
     1969                                            &ifp->in6_ifaddrs[ix].addr);
     1970                        }
     1971                }
     1972
     1973#ifdef DHCP6_CLI_CFG
     1974        dhcp6c_info(portid);
     1975#endif
    14441976
    14451977        SIG_NET_CONS_PRINTF();
     
    14491981        }
    14501982
    1451 #endif  /* of #if defined(SUPPORT_INET6) */
     1983#endif  /* of #if defined(NETAPP_IP6_CFG) */
     1984
     1985#if defined(NETAPP_IP4_CFG)
    14521986
    14531987/*
    1454  *  show_config -- コンフィギュレーション設定の表示
    1455  */
    1456 
    1457 static void
    1458 show_config (ID portid, char *line)
     1988 *  dbg_cons_ifconfig4 -- ネットワークインタフェース(IPv4)の構成情報
     1989 */
     1990
     1991void
     1992dbg_cons_ifconfig4 (ID portid, char *line)
     1993{
     1994        T_IFNET         *ifp = IF_GET_IFNET();
     1995        T_IN4_ADDR      bc;
     1996
     1997#ifdef SUPPORT_ETHER
     1998
     1999        if (*(line = skip_blanks(line))) {
     2000                T_IN4_ADDR      addr, mask;
     2001
     2002                get_ipv4addr(&mask, skip_blanks(get_ipv4addr(&addr, line)));
     2003                in4_add_ifaddr(addr, mask);
     2004                }
     2005
     2006#endif  /* of #ifdef SUPPORT_ETHER */
     2007
     2008        WAI_NET_CONS_PRINTF();
     2009
     2010        bc = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
     2011        cons_printf(portid,
     2012                    "IPv4: %hI, mask: %hI, broadcast: %hI\n",
     2013                    &ifp->in4_ifaddr.addr,
     2014                    &ifp->in4_ifaddr.mask,
     2015                    &bc);
     2016
     2017#ifdef DHCP4_CLI_CFG
     2018        dhcp4c_info(portid);
     2019#endif
     2020
     2021        SIG_NET_CONS_PRINTF();
     2022        FLUSH_SND_BUFF();
     2023        }
     2024
     2025#endif  /* of #if defined(NETAPP_IP4_CFG) */
     2026
     2027/*
     2028 *  dbg_cons_show_config -- コンフィギュレーション設定の表示
     2029 */
     2030
     2031void
     2032dbg_cons_show_config (ID portid, char *line)
    14592033{
    14602034#if defined(SUPPORT_ETHER)
     
    14642038#endif  /* of #if defined(SUPPORT_ETHER) */
    14652039
    1466 #if defined(DHCP_CFG)
    1467 
    14682040        cons_printf(portid, "DHCP:\n");
    1469 
    1470         cons_printf(portid, "  DHCP_CFG: On\n");
    1471 
    1472 #endif  /* of #if define(DHCP_CFG) */
     2041        cons_printf(portid, "  DHCP6_CLI_CFG: ");
     2042
     2043#if defined(DHCP6_CLI_CFG)
     2044
     2045        cons_printf(portid, "On\n           Mode: ");
     2046
     2047#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
     2048        cons_printf(portid, "STATELESS\n");
     2049#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
     2050        cons_printf(portid, "STATEFULL\n");
     2051#endif
     2052
     2053#else   /* of #if define(DHCP6_CLI_CFG) */
     2054
     2055        cons_printf(portid, "Off\n");
     2056
     2057#endif  /* of #if define(DHCP6_CLI_CFG) */
     2058
     2059        cons_printf(portid, "  DHCP4_CLI_CFG: ");
     2060
     2061#if defined(DHCP4_CLI_CFG)
     2062        cons_printf(portid, "On\n");
     2063#else
     2064        cons_printf(portid, "Off\n");
     2065#endif
     2066
     2067        cons_printf(portid, "Resolver:\n");
     2068        cons_printf(portid, "  USE_RESOLVER: ");
     2069
     2070#if defined(USE_RESOLVER)
     2071        cons_printf(portid, "On\n");
     2072#else
     2073        cons_printf(portid, "Off\n");
     2074#endif
    14732075
    14742076#if defined(SUPPORT_TCP)
    14752077
    14762078        cons_printf(portid, "TCP:\n");
    1477 
    1478         cons_printf(portid, "  TCP_CFG_PASSIVE_OPEN: ");
    1479 #if defined(TCP_CFG_PASSIVE_OPEN)
    1480         cons_printf(portid, "On\n");
    1481 #else
    1482         cons_printf(portid, "Off\n");
    1483 #endif
    14842079
    14852080        cons_printf(portid, "  TCP_CFG_OPT_MSS:      ");
     
    15532148#endif
    15542149
     2150        cons_printf(portid, "  TCP_CFG_NON_BLOCKING_COMPAT14: ");
     2151#if defined(TCP_CFG_NON_BLOCKING_COMPAT14)
     2152        cons_printf(portid, "On\n");
     2153#else
     2154        cons_printf(portid, "Off\n");
     2155#endif
     2156
    15552157        cons_printf(portid, "  TCP_CFG_EXTENTIONS:   ");
    15562158#if defined(TCP_CFG_EXTENTIONS)
    15572159#if defined(USE_TCP_EXTENTIONS)
    15582160        cons_printf(portid, "Use\n");
    1559 #if defined(SUPPORT_INET4)
    1560         cons_printf(portid, "  NUM_VRID_TCP_REPS:    %3d\n", NUM_VRID_TCP_REPS);
    1561         cons_printf(portid, "  NUM_VRID_TCP_CEPS:    %3d\n", NUM_VRID_TCP_CEPS);
    1562 #endif 
    15632161#if defined(SUPPORT_INET6)
    15642162        cons_printf(portid, "  NUM_VRID_TCP6_REPS:   %3d\n", NUM_VRID_TCP6_REPS);
    15652163        cons_printf(portid, "  NUM_VRID_TCP6_CEPS:   %3d\n", NUM_VRID_TCP6_CEPS);
    1566 #endif 
     2164#endif
     2165#if defined(SUPPORT_INET4)
     2166        cons_printf(portid, "  NUM_VRID_TCP4_REPS:   %3d\n", NUM_VRID_TCP4_REPS);
     2167        cons_printf(portid, "  NUM_VRID_TCP4_CEPS:   %3d\n", NUM_VRID_TCP4_CEPS);
     2168#endif
    15672169#else
    15682170        cons_printf(portid, "On\n");
     
    15892191#if defined(SUPPORT_INET4)
    15902192        addr = TCP_CFG_TRACE_IPV4_RADDR;
    1591         cons_printf(portid, "                            TCP_CFG_TRACE_IPV4_RADDR: %I\n", &addr);
     2193        cons_printf(portid, "                            TCP_CFG_TRACE_IPV4_RADDR: %hI\n", &addr);
    15922194#endif
    15932195        cons_printf(portid, "                            TCP_CFG_TRACE_RPORTNO:    %d\n", TCP_CFG_TRACE_RPORTNO);
     
    16332235#endif
    16342236
     2237        cons_printf(portid, "  UDP_CFG_NON_BLOCKING_COMPAT14: ");
     2238#if defined(UDP_CFG_NON_BLOCKING_COMPAT14)
     2239        cons_printf(portid, "On\n");
     2240#else
     2241        cons_printf(portid, "Off\n");
     2242#endif
     2243
    16352244        cons_printf(portid, "  UDP_CFG_EXTENTIONS:   ");
    16362245#if defined(UDP_CFG_EXTENTIONS)
     
    16402249        cons_printf(portid, "On\n");
    16412250#endif
    1642         cons_printf(portid, "  NUM_VRID_UDP_CEPS:    %3d\n", NUM_VRID_UDP_CEPS);
     2251        cons_printf(portid, "  NUM_VRID_UDP4_CEPS:   %3d\n", NUM_VRID_UDP4_CEPS);
    16432252        cons_printf(portid, "  NUM_VRID_UDP6_CEPS:   %3d\n", NUM_VRID_UDP6_CEPS);
    16442253#else
     
    16672276#endif
    16682277
     2278#if defined(NUM_REDIRECT_ROUTE_ENTRY)
    16692279#if NUM_REDIRECT_ROUTE_ENTRY > 0
    16702280        cons_printf(portid, "  TMO_IN_REDIRECT: %4d[s]\n", TMO_IN_REDIRECT / NET_TIMER_HZ);
    16712281#endif
    1672 
    1673 #if defined(SUPPORT_INET4)
    1674 
    1675         cons_printf(portid, "IPv4:\n");
    1676 
    1677         cons_printf(portid, "  IP4_CFG_FRAGMENT: ");
    1678 
    1679 #if defined(IP4_CFG_FRAGMENT)
     2282#endif  /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
     2283
     2284#if defined(SUPPORT_INET6)
     2285
     2286        cons_printf(portid, "IPv6:\n");
     2287
     2288        cons_printf(portid, "  IP6_IPV4_MAPPED_ADDR:   ");
     2289#if defined(IP6_CFG_IPV4_MAPPED_ADDR)
    16802290        cons_printf(portid, "On\n");
    1681         cons_printf(portid, "    NUM_IP4_FRAG_QUEUE:       %4d\n", NUM_IP4_FRAG_QUEUE);
    1682         cons_printf(portid, "    IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);
    16832291#else
    16842292        cons_printf(portid, "Off\n");
    1685 #endif  /* of #if defined(IP4_CFG_FRAGMENT) */
    1686 
    1687 #if defined(SUPPORT_ETHER)
    1688         addr = IPV4_ADDR_LOCAL;
    1689         cons_printf(portid, "  IPV4_ADDR_LOCAL:      %I\n", &addr);
    1690         addr = IPV4_ADDR_LOCAL_MASK;
    1691         cons_printf(portid, "  IPV4_ADDR_LOCAL_MASK: %I\n", &addr);
    1692         addr = IPV4_ADDR_DEFAULT_GW;
    1693         cons_printf(portid, "  IPV4_ADDR_DEFAULT_GW: %I\n", &addr);
    1694 #endif  /* of #if defined(SUPPORT_ETHER) */
     2293#endif
    16952294
    16962295        cons_printf(portid, "  Routing Table:\n");
    1697         cons_printf(portid, "    NUM_STATIC_ROUTE_ENTRY:   %d\n", NUM_STATIC_ROUTE_ENTRY);
    1698         cons_printf(portid, "    NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY);
    1699 
    1700 #endif  /* of #if defined(SUPPORT_INET4) */
    1701 
    1702 #if defined(SUPPORT_INET6)
    1703 
    1704         cons_printf(portid, "IPv6:\n");
    1705 
    1706         cons_printf(portid, "  Routing Table:\n");
    1707         cons_printf(portid, "    NUM_STATIC_ROUTE_ENTRY:   %d\n", NUM_STATIC_ROUTE_ENTRY);
    1708         cons_printf(portid, "    NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY);
     2296        cons_printf(portid, "    NUM_IN6_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN6_STATIC_ROUTE_ENTRY);
     2297        cons_printf(portid, "    NUM_IN6_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN6_REDIRECT_ROUTE_ENTRY);
    17092298
    17102299        cons_printf(portid, "ND:\n");
     
    17302319#endif  /* of #if defined(SUPPORT_INET6) */
    17312320
     2321#if defined(SUPPORT_INET4)
     2322
     2323        cons_printf(portid, "IPv4:\n");
     2324
     2325        cons_printf(portid, "  IP4_CFG_FRAGMENT: ");
     2326
     2327#if defined(IP4_CFG_FRAGMENT)
     2328        cons_printf(portid, "On\n");
     2329        cons_printf(portid, "    NUM_IP4_FRAG_QUEUE:       %4d\n", NUM_IP4_FRAG_QUEUE);
     2330        cons_printf(portid, "    IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);
     2331#else
     2332        cons_printf(portid, "Off\n");
     2333#endif  /* of #if defined(IP4_CFG_FRAGMENT) */
     2334
     2335#if defined(SUPPORT_ETHER)
     2336        addr = IPV4_ADDR_LOCAL;
     2337        cons_printf(portid, "  IPV4_ADDR_LOCAL:      %hI\n", &addr);
     2338        addr = IPV4_ADDR_LOCAL_MASK;
     2339        cons_printf(portid, "  IPV4_ADDR_LOCAL_MASK: %hI\n", &addr);
     2340        addr = IPV4_ADDR_DEFAULT_GW;
     2341        cons_printf(portid, "  IPV4_ADDR_DEFAULT_GW: %hI\n", &addr);
     2342#endif  /* of #if defined(SUPPORT_ETHER) */
     2343
     2344        cons_printf(portid, "  Routing Table:\n");
     2345        cons_printf(portid, "    NUM_IN4_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN4_STATIC_ROUTE_ENTRY);
     2346        cons_printf(portid, "    NUM_IN4_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN4_REDIRECT_ROUTE_ENTRY);
     2347
     2348#endif  /* of #if defined(SUPPORT_INET4) */
     2349
    17322350#if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER)
    17332351
     
    17712389#endif
    17722390
     2391        cons_printf(portid, "  ETHER_COLLECT_ADDR:      ");
     2392#if defined(ETHER_COLLECT_ADDR)
     2393        cons_printf(portid, "On\n");
     2394#else
     2395        cons_printf(portid, "Off\n");
     2396#endif
     2397
    17732398#endif  /* of #if defined(SUPPORT_ETHER) */
    17742399
     
    18542479        }
    18552480
     2481#ifdef USE_PING
     2482
     2483/*
     2484 *  ping コマンド
     2485 */
     2486
     2487void
     2488dbg_cons_ping_comd (ID portid, char *line)
     2489{
     2490        int_t   tmo, size;
     2491        char    apip = DEFAULT_API_PROTO;
     2492
     2493#if defined(SUPPORT_INET6)
     2494        T_IN6_ADDR      addr;
     2495#if defined(SUPPORT_INET4)
     2496        T_IN4_ADDR      addr4;
     2497#endif
     2498#else
     2499        T_IN4_ADDR      addr;
     2500#endif
     2501
     2502#if defined(PING_CFG_I6RLP)
     2503
     2504        static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452";
     2505        static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352";
     2506        static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2";
     2507
     2508        if      (apip == '1')
     2509                strcpy(line, i6rlp_pmtu_str1);
     2510        else if (apip == '2')
     2511                strcpy(line, i6rlp_pmtu_str2);
     2512        else if (apip == '3')
     2513                strcpy(line, i6rlp_pmtu_str3);
     2514
     2515#endif  /* of #ifdef PING_CFG_I6RLP */
     2516
     2517#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     2518
     2519        if ('0' <= *line && *line <= '9') {
     2520                if (*line == '6')
     2521                        apip = API_PROTO_IPV6;
     2522                if (*line == '4')
     2523                        apip = API_PROTO_IPV4;
     2524                line ++;
     2525                }
     2526
     2527#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     2528
     2529        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
     2530                syslog(LOG_NOTICE, "[PING] unknown host.");
     2531                return;
     2532                }
     2533
     2534        line = skip_blanks(line);
     2535        if ('0' <= *line && *line <= '9')
     2536                line = get_int(&tmo, line);
     2537        else
     2538                tmo = 3;
     2539
     2540        line = skip_blanks(line);
     2541        if ('0' <= *line && *line <= '9')
     2542                line = get_int(&size, line);
     2543        else
     2544                size = 64;
     2545
     2546#if defined(SUPPORT_INET6)
     2547
     2548#if defined(SUPPORT_INET4)
     2549
     2550        if (apip == API_PROTO_IPV6) {
     2551                syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
     2552                ping6(&addr, (uint_t)tmo, (uint_t)size);
     2553                }
     2554        else {
     2555                addr4 = ntohl(addr.s6_addr32[3]);
     2556                syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr4));
     2557                ping4(&addr4, (uint_t)tmo, (uint_t)size);
     2558                }
     2559
     2560#else /* of #if defined(SUPPORT_INET4) */
     2561
     2562        syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
     2563        ping6(&addr, (uint_t)tmo, (uint_t)size);
     2564
     2565#endif  /* of #if defined(SUPPORT_INET4) */
     2566
     2567#else   /* of #if defined(SUPPORT_INET6) */
     2568
     2569
     2570        syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr));
     2571        ping4(&addr, (uint_t)tmo, (uint_t)size);
     2572
     2573#endif  /* of #if defined(SUPPORT_INET6) */
     2574
     2575        }
     2576
     2577#endif  /* of #ifdef USE_PING */
     2578
     2579#ifdef USE_DBG_CONS_PARSER
     2580
    18562581/*
    18572582 *  デバッグコマンド解析
    18582583 */
    18592584
    1860 static void
     2585void
    18612586dbg_parse (ID portid, char *line)
    18622587{
    18632588        int_t   cepid;
    1864         ER      error;
     2589        ER      error = E_OK;
     2590
     2591#if defined(SUPPORT_UDP) && defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     2592        int_t   udp_cep_ipproto;
     2593#endif
    18652594
    18662595        switch (*line) {
     
    18702599
    18712600                case 'f':       /* show configurations */
    1872                         show_config(portid, line + 1);
     2601                        dbg_cons_show_config(portid, line + 1);
    18732602                        break;
    18742603
     
    18802609                                line ++;
    18812610                        if ((error = tcp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
    1882                                 cons_printf(portid, "[TCP CAN CEP] error: %s\n", itron_strerror(error));
     2611                                cons_printf(portid, "[TCP CAN CEP] error: %s.\n", itron_strerror(error));
    18832612                                SIG_NET_CONS_PRINTF();
    18842613                                FLUSH_SND_BUFF();
     
    18912620
    18922621                case 'u':       /* cancel UDP */
     2622
     2623#if defined(SUPPORT_INET6)
     2624
     2625#if defined(SUPPORT_INET4)
     2626
     2627                        udp_cep_ipproto = (*(line + 2) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6);
     2628                        cepid = atoi(line = skip_blanks(line + 3));
     2629                        while ('0' <= *line && *line <= '9')
     2630                                line ++;
     2631
     2632#if TNUM_UDP6_CEPID > 0
     2633
     2634                        if (udp_cep_ipproto == API_PROTO_IPV6) {
     2635                                if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
     2636                                        cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
     2637                                        SIG_NET_CONS_PRINTF();
     2638                                        FLUSH_SND_BUFF();
     2639                                        }
     2640                                }
     2641
     2642#endif  /* of #if TNUM_UDP6_CEPID > 0 */
     2643
     2644#if TNUM_UDP4_CEPID > 0
     2645
     2646                        if (udp_cep_ipproto == API_PROTO_IPV4) {
     2647                                if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
     2648                                        cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
     2649                                        SIG_NET_CONS_PRINTF();
     2650                                        FLUSH_SND_BUFF();
     2651                                        }
     2652                                }
     2653
     2654#endif  /* of #if TNUM_UDP4_CEPID > 0 */
     2655
     2656#else   /* of #if defined(SUPPORT_INET4) */
     2657
     2658#if TNUM_UDP6_CEPID > 0
     2659
    18932660                        cepid = atoi(line = skip_blanks(line + 2));
    18942661                        while ('0' <= *line && *line <= '9')
    18952662                                line ++;
     2663
    18962664                        if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
    1897                                 cons_printf(portid, "[UDP CAN CEP] error: %s\n", itron_strerror(error));
     2665                                cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
    18982666                                SIG_NET_CONS_PRINTF();
    18992667                                FLUSH_SND_BUFF();
    19002668                                }
     2669
     2670#endif  /* of #if TNUM_UDP6_CEPID > 0 */
     2671
     2672#endif  /* of #if defined(SUPPORT_INET4) */
     2673
     2674#else   /* of #if defined(SUPPORT_INET6) */
     2675
     2676#if defined(SUPPORT_INET4)
     2677
     2678#if TNUM_UDP4_CEPID > 0
     2679
     2680                        cepid = atoi(line = skip_blanks(line + 2));
     2681                        while ('0' <= *line && *line <= '9')
     2682                                line ++;
     2683
     2684                        if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
     2685                                cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
     2686                                SIG_NET_CONS_PRINTF();
     2687                                FLUSH_SND_BUFF();
     2688                                }
     2689
     2690#endif  /* of #if TNUM_UDP4_CEPID > 0 */
     2691
     2692#endif  /* of #if defined(SUPPORT_INET4) */
     2693
     2694#endif  /* of #if defined(SUPPORT_INET6) */
     2695
    19012696                        break;
    19022697
     
    19062701
    19072702                break;
    1908 
    1909 #if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS)
    19102703
    19112704        case 'd':       /* discard client */
     
    19292722#endif  /* of #if defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */
    19302723
     2724#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
     2725
     2726                case 'h':               /* DHCP client */
     2727                        dhcpc(portid, line + 2);
     2728                        break;
     2729
     2730#endif  /* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
     2731
    19312732#ifdef USE_TCP_DISCARD_CLI
    19322733
     
    19412742                        default:
    19422743                                if ((error = psnd_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
    1943                                         cons_printf(portid, "[TCP DISCARD CLI] error: %s\n",
     2744                                        cons_printf(portid, "[TCP DISCARD CLI] error: %s.\n",
    19442745                                               itron_strerror(error));
    19452746                                        SIG_NET_CONS_PRINTF();
     
    19652766                        default:
    19662767                                if ((error = psnd_dtq(DTQ_UDP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
    1967                                         cons_printf(portid, "[UDP DISCARD CLI] error: %s\n",
     2768                                        cons_printf(portid, "[UDP DISCARD CLI] error: %s.\n",
    19682769                                               itron_strerror(error));
    19692770                                        SIG_NET_CONS_PRINTF();
     
    19812782                break;
    19822783
    1983 #endif  /* of #if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */
    1984 
    1985 #if defined(USE_UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI)
     2784#if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI)
    19862785
    19872786        case 'e':       /* echo client */
     
    20002799                        default:
    20012800                                if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t)line)) != E_OK) {
    2002                                         cons_printf(portid, "[TCP ECHO CLI] error: %s\n", itron_strerror(error));
     2801                                        cons_printf(portid, "[TCP ECHO CLI] error: %s.\n", itron_strerror(error));
    20032802                                        SIG_NET_CONS_PRINTF();
    20042803                                        FLUSH_SND_BUFF();
     
    20112810#endif  /* of #ifdef USE_TCP_ECHO_CLI */
    20122811
    2013 #ifdef USE_UDP_ECHO_CLI
     2812#if defined(USE_UDP_ECHO_CLI)
    20142813
    20152814                case 'u':       /* UDP echo client */
    2016                         line += 2;
    2017                         switch (*line) {
     2815                        switch (*(line + 2)) {
    20182816
    20192817                        case 's':       /* cancel UDP echo */
    2020                                 udp_echo_cli_valid = false;
     2818
     2819#if defined(USE_UDP6_ECHO_CLI_TSK)
     2820
     2821#if defined(USE_UDP4_ECHO_CLI_TSK)
     2822
     2823                                if (*(line + 3) == '4')
     2824                                        udp4_echo_cli_valid = false;
     2825                                else
     2826                                        udp6_echo_cli_valid = false;
     2827
     2828#else   /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
     2829
     2830                                udp6_echo_cli_valid = false;
     2831
     2832#endif  /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
     2833
     2834#else   /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
     2835
     2836#if defined(USE_UDP4_CLI_TSK)
     2837
     2838                                udp4_echo_cli_valid = false;
     2839
     2840#endif  /* of #if defined(USE_UDP4_CLI_TSK) */
     2841
     2842#endif  /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
     2843
     2844
    20212845                                break;
    20222846
    20232847                        default:
    2024                                 if ((error = psnd_dtq(DTQ_UDP_ECHO_CLI, (intptr_t)line)) != E_OK) {
    2025                                         cons_printf(portid, "[UDP ECHO CLI] error: %s\n", itron_strerror(error));
     2848
     2849                                line += 2;
     2850
     2851#if defined(USE_UDP6_ECHO_CLI_TSK)
     2852
     2853#if defined(USE_UDP4_ECHO_CLI_TSK)
     2854
     2855                                if (*line == '4') {
     2856                                        line ++;
     2857                                        error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
     2858                                        }
     2859                                else {
     2860                                        if (*line && *line != ' ')
     2861                                                line ++;
     2862                                        error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
     2863                                        }
     2864
     2865#else   /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
     2866
     2867                                if (*line && *line != ' ')
     2868                                        line ++;
     2869                                error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
     2870
     2871#endif  /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
     2872
     2873#else   /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
     2874
     2875                                if (*line && *line != ' ')
     2876                                        line ++;
     2877                                error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
     2878
     2879#endif  /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
     2880
     2881                                if (error != E_OK) {
     2882                                        cons_printf(portid, "[UDP ECHO CLI] error: %s.\n", itron_strerror(error));
    20262883                                        SIG_NET_CONS_PRINTF();
    20272884                                        FLUSH_SND_BUFF();
    20282885                                        }
     2886
    20292887                                break;
    20302888
     
    20322890                        break;
    20332891
    2034 #endif  /* of #ifdef USE_UDP_ECHO_CLI */
     2892#endif  /* of #if defined(USE_UDP_ECHO_CLI) */
    20352893
    20362894                        }
     
    20382896                break;
    20392897
    2040 #endif  /* of #if defined(USE_UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI) */
     2898#endif  /* of #if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI) */
    20412899
    20422900        case 'i':
    20432901
    2044                 if (*(line + 1) == 'f')
    2045                         ifconfig(portid, line + 2);
     2902                if (*(line + 1) == 'f') {
     2903
     2904                        dbg_cons_ifconfig (portid, line + 2);
     2905
     2906#if defined(NETAPP_IP6_CFG)
     2907                        dbg_cons_ifconfig6(portid, line + 2);
     2908#endif
     2909
     2910#if defined(NETAPP_IP4_CFG)
     2911                        dbg_cons_ifconfig4(portid, line + 2);
     2912#endif
     2913
     2914                        }
    20462915
    20472916#ifdef SUPPORT_PPP
     
    20642933
    20652934        case 'n':               /* network status */
    2066                 network_status(portid, line + 1);
     2935                dbg_cons_network_status(portid, line + 1);
    20672936                break;
    20682937
     
    20702939
    20712940                if (*(line + 1) == 's')
    2072                         task_status(portid, skip_blanks(line + 2));
     2941                        dbg_cons_task_status(portid, skip_blanks(line + 2));
    20732942
    20742943#ifdef USE_PING
    20752944
    2076                 else {
    2077                         int_t           tmo, size;
    2078                         T_IN_ADDR       addr;
    2079 
    2080 #ifdef PING_CFG_I6RLP
    2081                         static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452";
    2082                         static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352";
    2083                         static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2";
    2084 
    2085                         if      (*(line + 1) == '1')
    2086                                 strcpy(line + 1, i6rlp_pmtu_str1);
    2087                         else if (*(line + 1) == '2')
    2088                                 strcpy(line + 1, i6rlp_pmtu_str2);
    2089                         else if (*(line + 1) == '3')
    2090                                 strcpy(line + 1, i6rlp_pmtu_str3);
    2091 
    2092 #endif  /* of #ifdef PING_CFG_I6RLP */
    2093 
    2094                         line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line + 1)));
    2095                         if ('0' <= *line && *line <= '9')
    2096                                 line = get_int(&tmo, line);
    2097                         else
    2098                                 tmo = 3;
    2099 
    2100                         line = skip_blanks(line + 1);
    2101                         if ('0' <= *line && *line <= '9')
    2102                                 line = get_int(&size, line);
    2103                         else
    2104                                 size = 64;
    2105 
    2106                         PING(&addr, (uint_t)tmo, (uint_t)size);
    2107                         }
     2945                else
     2946                        dbg_cons_ping_comd(portid, line + 1);
    21082947
    21092948#endif  /* of #ifdef USE_PING */
     
    21132952        case 'r':               /* release wait task */
    21142953                if ((error = rel_wai(atoi(skip_blanks(line + 1)))) != E_OK) {
    2115                         cons_printf(portid, "[REL WAI TSK] error: %s\n", itron_strerror(error));
     2954                        cons_printf(portid, "[REL WAI TSK] error: %s.\n", itron_strerror(error));
    21162955                        SIG_NET_CONS_PRINTF();
    21172956                        FLUSH_SND_BUFF();
     
    21252964
    21262965                case 't':               /* TCP REP */
    2127                         if ((error = tcp_del_rep(atoi(skip_blanks(line + 2)))) != E_OK) {
    2128                                 cons_printf(portid, "[TCP DEL REP] error: %s\n", itron_strerror(error));
     2966       
     2967                        error = tcp_del_rep(atoi(skip_blanks(line + 2)));
     2968                        if (error != E_OK) {
     2969                                cons_printf(portid, "[TCP DEL REP] ID: %d, error: %s.\n",
     2970                                                    atoi(skip_blanks(line + 2)),
     2971                                                    itron_strerror(error));
    21292972                                SIG_NET_CONS_PRINTF();
    21302973                                FLUSH_SND_BUFF();
     
    21372980
    21382981                case 'u':               /* UDP CEP */
    2139                         if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
    2140                                 cons_printf(portid, "[UDP DEL CEP] error: %s\n", itron_strerror(error));
     2982
     2983#if defined(USE_UDP6_ECHO_SRV_TSK)
     2984
     2985#if defined(USE_UDP4_ECHO_SRV_TSK)
     2986
     2987                        if (*(line + 2) == '4') {
     2988                                if ((error = udp_del_cep(atoi(skip_blanks(line + 3)))) != E_OK) {
     2989                                        cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
     2990                                        SIG_NET_CONS_PRINTF();
     2991                                        FLUSH_SND_BUFF();
     2992                                        }
     2993                                }
     2994                        else {
     2995                                if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
     2996                                        cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
     2997                                        SIG_NET_CONS_PRINTF();
     2998                                        FLUSH_SND_BUFF();
     2999                                        }
     3000                                }
     3001
     3002#else   /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3003
     3004                        if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
     3005                                cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
    21413006                                SIG_NET_CONS_PRINTF();
    21423007                                FLUSH_SND_BUFF();
    21433008                                }
     3009
     3010#endif  /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3011
     3012#else   /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
     3013
     3014#if defined(USE_UDP4_ECHO_SRV_TSK)
     3015
     3016                        if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
     3017                                cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
     3018                                SIG_NET_CONS_PRINTF();
     3019                                FLUSH_SND_BUFF();
     3020                                }
     3021
     3022#endif  /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3023
     3024#endif  /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
     3025
    21443026                        break;
    21453027
     
    21633045                        case 'd':               /* tcp discard server */
    21643046                                if ((error = wup_tsk(TCP_DISCARD_SRV_TASK)) != E_OK) {
    2165                                         cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s\n", itron_strerror(error));
     3047                                        //cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s.\n", itron_strerror(error));
    21663048                                        SIG_NET_CONS_PRINTF();
    21673049                                        FLUSH_SND_BUFF();
     
    21703052#endif  /* of #ifdef USE_TCP_DISCARD_SRV */
    21713053
    2172 #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2)
     3054#if defined(USE_TCP_ECHO_SRV1)
    21733055                        case 'e':               /* tcp echo server */
    2174                                 if ((error = wup_tsk(TCP_ECHO_SRV_TASK)) != E_OK) {
    2175                                         cons_printf(portid, "[WUP UDP DISCARD SRV] error: %s\n", itron_strerror(error));
     3056                                if ((error = wakeup_tcp_echo_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
     3057                                        //cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
    21763058                                        SIG_NET_CONS_PRINTF();
    21773059                                        FLUSH_SND_BUFF();
    21783060                                        }
    21793061                                break;
    2180 #endif  /* of #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2) */
     3062#endif  /* of #if defined(USE_TCP_ECHO_SRV1) */
     3063
     3064#if defined(USE_TCP_ECHO_SRV2)
     3065                        case 'e':               /* tcp echo server */
     3066                                if ((error = wup_tsk(TCP_ECHO_SRV_TASK2)) != E_OK) {
     3067                                        //cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
     3068                                        SIG_NET_CONS_PRINTF();
     3069                                        FLUSH_SND_BUFF();
     3070                                        }
     3071                                break;
     3072#endif  /* of #if defined(USE_TCP_ECHO_SRV2) */
    21813073
    21823074#ifdef USE_WWW_SRV
    21833075                        case 'w':               /* WWW server */
    2184                                 if ((error = wup_tsk(WWW_SRV_TASK1)) != E_OK) {
    2185                                         cons_printf(portid, "[WUP WWW SRV] error: %s\n", itron_strerror(error));
     3076                                if ((error = wakeup_www_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
     3077                                        //cons_printf(portid, "[WUP WWW SRV] error: %s.\n", itron_strerror(error));
    21863078                                        SIG_NET_CONS_PRINTF();
    21873079                                        FLUSH_SND_BUFF();
     
    22003092                        switch (*(line + 2)) {
    22013093
    2202 #if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK)
     3094#if !defined(USE_UDP_CALL_BACK)
     3095
    22033096                        case 'e':               /* udp echo server */
    2204                                 if ((error = wup_tsk(UDP_ECHO_SRV_TASK)) != E_OK) {
    2205                                         cons_printf(portid, "[WUP UDP ECHO SRV] error: %s\n", itron_strerror(error));
     3097
     3098#if defined(USE_UDP6_ECHO_SRV_TSK)
     3099
     3100#if defined(USE_UDP4_ECHO_SRV_TSK)
     3101
     3102                                if (*(line + 3) == '4') {
     3103                                        if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
     3104                                                cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
     3105                                                SIG_NET_CONS_PRINTF();
     3106                                                FLUSH_SND_BUFF();
     3107                                                }
     3108                                        }
     3109                                else {
     3110                                        if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
     3111                                                cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
     3112                                                SIG_NET_CONS_PRINTF();
     3113                                                FLUSH_SND_BUFF();
     3114                                                }
     3115                                        }
     3116
     3117#else   /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3118
     3119                                if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
     3120                                        cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
    22063121                                        SIG_NET_CONS_PRINTF();
    22073122                                        FLUSH_SND_BUFF();
    22083123                                        }
     3124
     3125#endif  /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3126
     3127#else   /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
     3128
     3129#if defined(USE_UDP4_ECHO_SRV_TSK)
     3130
     3131                                if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
     3132                                        cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
     3133                                        SIG_NET_CONS_PRINTF();
     3134                                        FLUSH_SND_BUFF();
     3135                                        }
     3136
     3137#endif  /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
     3138
     3139#endif  /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
     3140
    22093141                                break;
    2210 #endif  /* of #if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK) */
     3142
     3143#endif  /* of #if !defined(USE_UDP_CALL_BACK) */
    22113144
    22123145                                }
     
    22173150                default:
    22183151                        if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
    2219                                 cons_printf(portid, "[WUP TSK] error: %s\n", itron_strerror(error));
     3152                                cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
    22203153                                SIG_NET_CONS_PRINTF();
    22213154                                FLUSH_SND_BUFF();
     
    22303163        case 'w':               /* wake up task */
    22313164                if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
    2232                         cons_printf(portid, "[WUP TSK] error: %s\n", itron_strerror(error));
     3165                        cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
    22333166                        SIG_NET_CONS_PRINTF();
    22343167                        FLUSH_SND_BUFF();
     
    22423175                if (*line) {
    22433176
    2244 #ifdef USE_EXTRA_PARSE
    2245 
    2246                         extra_parse(line);
    2247 
    2248 #else   /* of #ifdef USE_EXTRA_PARSE */
    2249 
    2250                         cons_printf(portid, "no such command: '%c'\n", *line);
     3177#ifdef USE_DBG_CONS_EXTRA_PARSE
     3178
     3179                        //cons_printf(portid, "extra command: '%c'.\n", *line);
     3180                        dbg_cons_extra_parse(portid, line);
     3181
     3182#else   /* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
     3183
     3184                        //cons_printf(portid, "command: '%c'.\n", *line);
     3185                        cons_printf(portid, "no such command: '%c'.\n", *line);
    22513186                        SIG_NET_CONS_PRINTF();
    22523187                        FLUSH_SND_BUFF();
    22533188
    2254 #endif  /* of #ifdef USE_EXTRA_PARSE */
     3189#endif  /* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
    22553190
    22563191                        }
     
    22583193                }
    22593194        }
     3195
     3196#endif  /* of #ifdef USE_DBG_CONS_PARSER */
    22603197
    22613198/*
     
    22683205        static char line[DBG_LINE_SIZE + 1];
    22693206
    2270         uint_t  len;
    22713207        ID      tskid;
    22723208
     
    22743210#ifdef SUPPORT_ETHER
    22753211
     3212#if 0
    22763213#if defined(SUPPORT_INET6)
    22773214
    2278         int_t           lllen;
     3215        uint32_t        lllen;
    22793216        const uint8_t   *lladdr;
    22803217
    22813218#endif  /* of #if defined(SUPPORT_INET6) */
    2282 
    2283         lcd_init();
     3219#endif
     3220
     3221        lcd_initialize(0);
     3222
     3223#if 0
     3224#if defined(SUPPORT_INET6)
     3225
     3226        dly_tsk(1 * 1000);
     3227        lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;
     3228        for (lllen = ETHER_ADDR_LEN; lllen --; )
     3229                lcd_printf(LCD_PORTID, "%02x", *lladdr ++);
     3230        lcd_putc(LCD_PORTID, '\n');
     3231
     3232#else   /* of #if defined(SUPPORT_INET6) */
    22843233
    22853234        if ((TINET_PRVER & UINT_C(0x0f)) > 0)
    2286                 lcd_printf("TINET-%d.%d.%d\n",
     3235                lcd_printf(LCD_PORTID, "TINET-%d.%d.%d\n",
    22873236                       (TINET_PRVER   >> 12) & UINT_C(0x0f),
    22883237                       (TINET_PRVER   >>  4) & UINT_C(0x0f),
    22893238                        TINET_PRVER          & UINT_C(0x0f));
    22903239        else
    2291                 lcd_printf("TINET-%d.%d\n",
     3240                lcd_printf(LCD_PORTID, "TINET-%d.%d\n",
    22923241                       (TINET_PRVER   >> 12) & UINT_C(0x0f),
    22933242                       (TINET_PRVER   >>  4) & UINT_C(0x0f));
    22943243
    2295 #if defined(SUPPORT_INET6)
    2296 
    2297         lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;
    2298         for (lllen = ETHER_ADDR_LEN; lllen --; )
    2299                 lcd_printf("%02x", *lladdr ++);
    2300         lcd_printf("\n");
    2301 
    2302 #else   /* of #if defined(SUPPORT_INET6) */
    2303 
    2304         lcd_puts(ip2str(NULL, in4_get_ifaddr(0)));
    2305 
    23063244#endif  /* of #if defined(SUPPORT_INET6) */
     3245#endif
     3246
     3247#if 0
     3248#if defined(SUPPORT_INET4)
     3249
     3250        dly_tsk(1 * 1000);
     3251        lcd_puts(LCD_PORTID, ip2str(NULL, in4_get_ifaddr(0)));
     3252        lcd_putc(LCD_PORTID, '\n');
     3253
     3254#endif  /* of #if defined(SUPPORT_INET4) */
     3255#endif
    23073256
    23083257#endif  /* of #ifdef SUPPORT_ETHER */
    2309 #else   /* of #ifdef USE_LCD */
     3258#endif  /* of #ifdef USE_LCD */
    23103259
    23113260        get_tid(&tskid);
    23123261        cons_printf(CONSOLE_PORTID, "[CONSOLE:%d] started.\n", tskid);
    2313 
    2314 #endif  /* of #ifdef USE_LCD */
    2315 
    23163262        serial_ctl_por(CONSOLE_PORTID,
    23173263                       IOCTL_ECHO  | IOCTL_CRLF  |
    23183264                       IOCTL_FCSND | IOCTL_FCANY | IOCTL_FCRCV);
     3265        netapp_srand (tskid);
    23193266        while (true) {
    2320                 len = cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);
     3267                cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);
    23213268                dbg_parse(CONSOLE_PORTID, line);
    23223269                }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.h

    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 *
     
    5353
    5454extern void act_tasks (void);
    55 extern void extra_parse (char *line);
     55extern void dbg_parse (ID portid, char *line);
     56extern void dbg_cons_extra_parse (ID portid, char *line);
     57extern void dbg_cons_task_status (ID portid, char *line);
     58extern void dbg_cons_network_status (ID portid, char *line);
     59extern void dbg_cons_ifconfig (ID portid, char *line);
     60extern void dbg_cons_ifconfig6 (ID portid, char *line);
     61extern void dbg_cons_ifconfig4 (ID portid, char *line);
     62extern void dbg_cons_show_config (ID portid, char *line);
     63extern void dbg_cons_ping_comd (ID portid, char *line);
    5664
    5765#endif  /* of #ifndef _DBG_CONS_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.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 *
     
    6060#endif  /* of #ifdef TARGET_KERNEL_JSP */
    6161
    62 #include <tinet_defs.h>
    63 
    64 #include <net/if.h>
    65 #include <net/if_ppp.h>
    66 #include <net/if_loop.h>
    67 #include <net/ethernet.h>
    68 #include <net/net.h>
    69 #include <net/net_timer.h>
    70 
    7162#include <netinet/in.h>
    7263#include <netinet/in_itron.h>
     
    109100#define TELNET_OPT_IAC          (255)
    110101
     102#if defined(SUPPORT_INET6)
     103#define API_PROTO               '6'
     104#else
     105#define API_PROTO               '4'
     106#endif
     107
    111108/*
    112109 *  変数
     
    121118bool_t  wait_accept     = false;        /* 接続要求待ち中      */
    122119
     120#if defined(SUPPORT_INET6)
     121
     122T_IPV6EP        dst;
     123
     124#else   /* of #if defined(SUPPORT_INET6) */
     125
    123126#if defined(SUPPORT_INET4)
    124127
     
    126129
    127130#endif  /* of #if defined(SUPPORT_INET4) */
    128 
    129 #if defined(SUPPORT_INET6)
    130 
    131 T_IPV6EP        dst;
    132131
    133132#endif  /* of #if defined(SUPPORT_INET6) */
     
    156155                get_tim(&now);
    157156                if (*(ER*)p_parblk == E_OK) {
    158                         syslog(LOG_NOTICE, "[NCS:%02u CBN] connected:  %6lu, from: %s.%u",
    159                                            cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
     157                        syslog(LOG_NOTICE, "[NCS%c:%02u CBN] conct: %7lu, from: %s.%u",
     158                                           API_PROTO, cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    160159                        connected = true;
    161160                        }
    162161                else
    163                         syslog(LOG_NOTICE, "[NCS:%02d CBN] error: %s", itron_strerror(*(ER*)p_parblk));
     162                        syslog(LOG_NOTICE, "[NCS%c:%02d CBN] error: %s",
     163                                           API_PROTO, itron_strerror(*(ER*)p_parblk));
    164164                snd_len = snd_off = rcv_len = rcv_off = 0;
    165165                wait_accept = false;
     
    193193                if (snd_off > 0) {
    194194                        if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
    195                                 syslog(LOG_NOTICE, "[NCS:%02d SND] flush send error: %s",
    196                                                    NET_CONS_CEPID, itron_strerror(error));
     195                                syslog(LOG_NOTICE, "[NCS%c:%02d SND] flush send error: %s",
     196                                                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    197197                        snd_len = snd_off = 0;
    198198                        }
     
    218218                        if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK) {
    219219                                if (error != E_CLS)
    220                                         syslog(LOG_NOTICE, "[NCS:%02d SND] send buff error: %s",
    221                                                            NET_CONS_CEPID, itron_strerror(error));
     220                                        syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
     221                                                           API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    222222                                syscall(sig_sem(SEM_NET_CONS_SEND));
    223223                                return;
     
    226226                        if ((snd_len = tcp_get_buf(NET_CONS_CEPID, (void*)&snd_buff, TMO_FEVR)) <= 0) {
    227227                                if (snd_len != E_CLS)
    228                                         syslog(LOG_NOTICE, "[NCS:%02d SND] get buff error: %s",
    229                                                            NET_CONS_CEPID, itron_strerror(snd_len));
     228                                        syslog(LOG_NOTICE, "[NCS%c:%02d SND] get buff error: %s",
     229                                                           API_PROTO, NET_CONS_CEPID, itron_strerror(snd_len));
    230230                                syscall(sig_sem(SEM_NET_CONS_SEND));
    231231                                return;
     
    253253                        if ((error = tcp_rel_buf(NET_CONS_CEPID, rcv_len)) != E_OK) {
    254254                                if (error != E_CLS)
    255                                         syslog(LOG_NOTICE, "[NCS:%02d RCV] release buff error: %s",
    256                                                            NET_CONS_CEPID, itron_strerror(error));
     255                                        syslog(LOG_NOTICE, "[NCS%c:%02d RCV] release buff error: %s",
     256                                                           API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    257257                                discon_net_cons();
    258258                                return EOF;
     
    264264                        else if (rcv_len < 0) {
    265265                                if (rcv_len != E_CLS)
    266                                         syslog(LOG_NOTICE, "[NCS:%02d RCV] recieve buff error: %s",
    267                                                            NET_CONS_CEPID, itron_strerror(rcv_len));
     266                                        syslog(LOG_NOTICE, "[NCS%c:%02d RCV] recieve buff error: %s",
     267                                                           API_PROTO, NET_CONS_CEPID, itron_strerror(rcv_len));
    268268                                discon_net_cons();
    269269                                return EOF;
     
    284284{
    285285        T_SERIAL_RPOR   rpor;
    286         int_t           ch, req;
     286        int_t           ch;
    287287        char            uch;
    288288        ER              error;
     
    292292                error = TCP_ACP_CEP(NET_CONS_CEPID, NET_CONS_REPID, &dst, TMO_NBLK);
    293293#if 0
    294                 syslog(LOG_NOTICE, "[NCS:%02d ACP] status: %s",NET_CONS_CEPID, itron_strerror(error));
     294                syslog(LOG_NOTICE, "[NCS%c:%02d ACP] status: %s",
     295                                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    295296#endif
    296297                if (error != E_WBLK)
     
    307308                                        case TELNET_OPT_DO:
    308309                                        case TELNET_OPT_DONT:
    309                                                 req = cons_getchar_raw();
     310                                                cons_getchar_raw();
    310311                                                break;
    311312                                        case TELNET_OPT_SB:
     
    354355                if (snd_off > 0) {
    355356                        if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
    356                                 syslog(LOG_NOTICE, "[NCS:%02d SND] send buff error: %s",
    357                                                    NET_CONS_CEPID, itron_strerror(error));
     357                                syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
     358                                                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    358359                        }
    359360                if ((error = tcp_sht_cep(NET_CONS_CEPID)) != E_OK)
    360                         syslog(LOG_NOTICE, "[NCS:%02d SHT] shutdown error: %s",
    361                                            NET_CONS_CEPID, itron_strerror(error));
     361                        syslog(LOG_NOTICE, "[NCS%c:%02d SHT] shutdown error: %s",
     362                                           API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    362363                if ((error = tcp_cls_cep(NET_CONS_CEPID, TMO_FEVR)) != E_OK)
    363                         syslog(LOG_NOTICE, "[NCS:%02d CLS] close error: %s",
    364                                            NET_CONS_CEPID, itron_strerror(error));
     364                        syslog(LOG_NOTICE, "[NCS%c:%02d CLS] close error: %s",
     365                                           API_PROTO, NET_CONS_CEPID, itron_strerror(error));
    365366                connected = false;
    366367                syscall(sig_sem(SEM_NET_CONS_SEND));
    367368                get_tim(&now);
    368                 syslog(LOG_NOTICE, "[NCS:%02u SND] disconnected:%5lu, from: %s.%u",
    369                                    NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
     369                syslog(LOG_NOTICE, "[NCS%c:%02u SND] discn: %7lu, from: %s.%u",
     370                                   API_PROTO, NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    370371                }
    371372        return error;
     
    499500                        case 'M':
    500501                                str = va_arg(ap, char*);
    501                                 put_macaddr(CONSOLE_PORTID, str, width);
     502                                put_macaddr(CONSOLE_PORTID, (uint8_t *)str, width);
    502503                                break;
    503504
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp.h

    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 *
     
    3939 */
    4040
     41#if defined(SUPPORT_INET6)
     42
     43#define PUT_IPADDR(p,a,w)       put_ipv6addr(p,a,w)
     44
     45#else   /* of #if defined(SUPPORT_INET6) */
     46
    4147#if defined(SUPPORT_INET4)
     48
    4249#define PUT_IPADDR(p,a,w)       put_ipv4addr(p,a,w)
    43 #endif
    4450
    45 #if defined(SUPPORT_INET6)
    46 #define PUT_IPADDR(p,a,w)       put_ipv6addr(p,a,w)
    47 #endif
     51#endif  /* of #if defined(SUPPORT_INET4) */
     52
     53#endif  /* of #if defined(SUPPORT_INET6) */
    4854
    4955/*
     
    5258
    5359#ifndef CONSOLE_PORTID
     60#define CONSOLE_PORTID          LOGTASK_PORTID
     61#endif
    5462
    55 #define CONSOLE_PORTID          LOGTASK_PORTID
     63/*
     64 *  コンソールに用いる LCD ポート番号
     65 */
    5666
    57 #endif  /* of #ifndef CONSOLE_PORTID */
     67#define LCD_PORTID              0
    5868
    5969/*
     
    8090extern int_t put_macaddr (ID portid, uint8_t *mac, int_t width);
    8191
    82 #if defined(SUPPORT_INET4)
     92#ifdef T_IN4_ADDR_DEFINED
    8393extern int_t put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width);
    8494#endif
    85 
    86 #if defined(SUPPORT_INET6)
     95#ifdef T_IN6_ADDR_DEFINED
    8796extern int_t put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width);
    8897#endif
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.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 *
     
    4444#include <sil.h>
    4545#include <syssvc/serial.h>
     46#include <syssvc/logtask.h>
     47#include <t_syslog.h>
    4648#include "kernel_cfg.h"
    4749#include "tinet_cfg.h"
     
    6264
    6365#include <net/net.h>
     66#include <net/net_endian.h>
    6467
    6568#include <netinet/in.h>
     
    6871#include <netapp/netapp.h>
    6972#include <netapp/netapp_var.h>
     73#include <netapp/resolver.h>
    7074
    7175#ifdef USE_NETAPP_SUBR
     76
     77/*
     78 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
     79 */
     80
     81#if defined(SUPPORT_INET6)
     82
     83#ifdef USE_TCP_EXTENTIONS
     84
     85const ID vrid_tcp6_cep[] =
     86{
     87#if NUM_VRID_TCP6_CEPS >= 1
     88        TCP6_RSV_CEPID1,
     89#endif
     90#if NUM_VRID_TCP6_CEPS >= 2
     91        TCP6_RSV_CEPID2,
     92#endif
     93#if NUM_VRID_TCP6_CEPS >= 3
     94        TCP6_RSV_CEPID3,
     95#endif
     96#if NUM_VRID_TCP6_CEPS >= 4
     97        TCP6_RSV_CEPID4,
     98#endif
     99        };
     100
     101const ID vrid_tcp6_rep[] =
     102{
     103#if NUM_VRID_TCP6_REPS >= 1
     104        TCP6_RSV_REPID1,
     105#endif
     106#if NUM_VRID_TCP6_REPS >= 2
     107        TCP6_RSV_REPID2,
     108#endif
     109        };
     110
     111ID tskid_tcp6_cep[NUM_VRID_TCP6_CEPS];
     112ID tskid_tcp6_rep[NUM_VRID_TCP6_REPS];
     113
     114#endif  /* #ifdef USE_TCP_EXTENTIONS */
     115
     116#ifdef USE_UDP_EXTENTIONS
     117
     118const ID vrid_udp6_cep[] =
     119{
     120#if NUM_VRID_UDP6_CEPS >= 1
     121        UDP6_RSV_CEPID1,
     122#endif
     123#if NUM_VRID_UDP6_CEPS >= 2
     124        UDP6_RSV_CEPID2,
     125#endif
     126        };
     127
     128ID tskid_udp6_cep[NUM_VRID_UDP6_CEPS];
     129
     130#endif  /* #ifdef USE_UDP_EXTENTIONS */
     131
     132#undef  TCP_CRE_REP
     133#undef  UDP_CRE_CEP
     134#undef  UDP_DEL_CEP
     135#undef  TCP_IS_CEPID
     136#undef  ALLOC_TCP_REP
     137#undef  ALLOC_TCP_CEP
     138#undef  ALLOC_UDP_CEP
     139#undef  FREE_TCP_REP
     140#undef  FREE_TCP_CEP
     141#undef  FREE_UDP_CEP
     142#undef  T_TCPN_CREP
     143#undef  T_UDPN_CCEP
     144#undef  NUM_VRID_TCP_CEPS
     145#undef  NUM_VRID_TCP_REPS
     146#undef  NUM_VRID_UDP_CEPS
     147#undef  VRID_TCP_CEP
     148#undef  VRID_UDP_CEP
     149#undef  VRID_TCP_REP
     150#undef  TSKID_TCP_CEP
     151#undef  TSKID_TCP_REP
     152#undef  TSKID_UDP_CEP
     153#undef  API_IPPROTO
     154
     155#define TCP_CRE_REP             tcp6_cre_rep
     156#define UDP_CRE_CEP             udp6_cre_cep
     157#define UDP_DEL_CEP             udp6_del_cep
     158
     159#define TCP_IS_CEPID            tcp6_is_cepid
     160#define ALLOC_TCP_REP           alloc_tcp6_rep
     161#define ALLOC_TCP_CEP           alloc_tcp6_cep
     162#define ALLOC_UDP_CEP           alloc_udp6_cep
     163#define FREE_TCP_REP            free_tcp6_rep
     164#define FREE_TCP_CEP            free_tcp6_cep
     165#define FREE_UDP_CEP            free_udp6_cep
     166#define T_TCPN_CREP             T_TCP6_CREP
     167#define T_UDPN_CCEP             T_UDP6_CCEP
     168#define NUM_VRID_TCP_CEPS       NUM_VRID_TCP6_CEPS
     169#define NUM_VRID_TCP_REPS       NUM_VRID_TCP6_REPS
     170#define NUM_VRID_UDP_CEPS       NUM_VRID_UDP6_CEPS
     171#define VRID_TCP_CEP            vrid_tcp6_cep
     172#define VRID_TCP_REP            vrid_tcp6_rep
     173#define VRID_UDP_CEP            vrid_udp6_cep
     174#define TSKID_TCP_CEP           tskid_tcp6_cep
     175#define TSKID_TCP_REP           tskid_tcp6_rep
     176#define TSKID_UDP_CEP           tskid_udp6_cep
     177#define API_IPPROTO             API_PROTO_IPV6
     178
     179#include <netapp/netappn_subr.c>
     180
     181#endif  /* of #if defined(SUPPORT_INET6) */
     182
     183#if defined(SUPPORT_INET4)
     184
     185#ifdef USE_TCP_EXTENTIONS
     186
     187const ID vrid_tcp4_cep[] =
     188{
     189#if NUM_VRID_TCP4_CEPS >= 1
     190        TCP4_RSV_CEPID1,
     191#endif
     192#if NUM_VRID_TCP4_CEPS >= 2
     193        TCP4_RSV_CEPID2,
     194#endif
     195#if NUM_VRID_TCP4_CEPS >= 3
     196        TCP4_RSV_CEPID3,
     197#endif
     198#if NUM_VRID_TCP4_CEPS >= 4
     199        TCP4_RSV_CEPID4,
     200#endif
     201        };
     202
     203const ID vrid_tcp4_rep[] =
     204{
     205#if NUM_VRID_TCP4_REPS >= 1
     206        TCP4_RSV_REPID1,
     207#endif
     208#if NUM_VRID_TCP4_REPS >= 2
     209        TCP4_RSV_REPID2,
     210#endif
     211        };
     212
     213ID tskid_tcp4_cep[NUM_VRID_TCP4_CEPS];
     214ID tskid_tcp4_rep[NUM_VRID_TCP4_REPS];
     215
     216#endif  /* #ifdef USE_TCP_EXTENTIONS */
     217
     218#ifdef USE_UDP_EXTENTIONS
     219
     220const ID vrid_udp4_cep[] =
     221{
     222#if NUM_VRID_UDP4_CEPS >= 1
     223        UDP4_RSV_CEPID1,
     224#endif
     225#if NUM_VRID_UDP4_CEPS >= 2
     226        UDP4_RSV_CEPID2,
     227#endif
     228        };
     229
     230ID tskid_udp4_cep[NUM_VRID_UDP4_CEPS];
     231
     232#endif  /* #ifdef USE_UDP_EXTENTIONS */
     233
     234#undef  TCP_CRE_REP
     235#undef  UDP_CRE_CEP
     236#undef  UDP_DEL_CEP
     237#undef  TCP_IS_CEPID
     238#undef  ALLOC_TCP_REP
     239#undef  ALLOC_TCP_CEP
     240#undef  ALLOC_UDP_CEP
     241#undef  FREE_TCP_REP
     242#undef  FREE_TCP_CEP
     243#undef  FREE_UDP_CEP
     244#undef  T_TCPN_CREP
     245#undef  T_UDPN_CCEP
     246#undef  NUM_VRID_TCP_CEPS
     247#undef  NUM_VRID_TCP_REPS
     248#undef  NUM_VRID_UDP_CEPS
     249#undef  VRID_TCP_CEP
     250#undef  VRID_TCP_REP
     251#undef  VRID_UDP_CEP
     252#undef  TSKID_TCP_CEP
     253#undef  TSKID_TCP_REP
     254#undef  TSKID_UDP_CEP
     255#undef  API_IPPROTO
     256
     257#define TCP_CRE_REP             tcp_cre_rep
     258#define UDP_CRE_CEP             udp_cre_cep
     259#define UDP_DEL_CEP             udp_del_cep
     260#define TCP_IS_CEPID            tcp4_is_cepid
     261#define ALLOC_TCP_REP           alloc_tcp4_rep
     262#define ALLOC_TCP_CEP           alloc_tcp4_cep
     263#define ALLOC_UDP_CEP           alloc_udp4_cep
     264#define FREE_TCP_REP            free_tcp4_rep
     265#define FREE_TCP_CEP            free_tcp4_cep
     266#define FREE_UDP_CEP            free_udp4_cep
     267#define T_TCPN_CREP             T_TCP_CREP
     268#define T_UDPN_CCEP             T_UDP_CCEP
     269#define NUM_VRID_TCP_CEPS       NUM_VRID_TCP4_CEPS
     270#define NUM_VRID_TCP_REPS       NUM_VRID_TCP4_REPS
     271#define NUM_VRID_UDP_CEPS       NUM_VRID_UDP4_CEPS
     272#define VRID_TCP_CEP            vrid_tcp4_cep
     273#define VRID_TCP_REP            vrid_tcp4_rep
     274#define VRID_UDP_CEP            vrid_udp4_cep
     275#define TSKID_TCP_CEP           tskid_tcp4_cep
     276#define TSKID_TCP_REP           tskid_tcp4_rep
     277#define TSKID_UDP_CEP           tskid_udp4_cep
     278#define API_IPPROTO             API_PROTO_IPV4
     279
     280#include <netapp/netappn_subr.c>
     281
     282#endif  /* of #if defined(SUPPORT_INET4) */
     283
     284#undef  TCP_CRE_REP
     285#undef  ALLOC_TCPN_REP
     286#undef  ALLOC_TCPN_CEP
     287#undef  ALLOC_UDPN_CEP
     288#undef  FREE_TCPN_REP
     289#undef  FREE_TCPN_CEP
     290#undef  FREE_UDPN_CEP
     291#undef  T_TCPN_CREP
     292#undef  NUM_VRID_TCP_REPS
     293#undef  NUM_VRID_UDP_CEPS
     294#undef  VRID_TCP_CEP
     295#undef  VRID_TCP_REP
     296#undef  VRID_UDP_CEP
     297#undef  TSKID_TCP_CEP
     298#undef  TSKID_TCP_REP
     299#undef  TSKID_UDP_CEP
     300
     301/*
     302 *  変数
     303 */
     304
     305static uint32_t rand_next = ULONG_C(1);
     306
     307#if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     308
     309const T_IN6_ADDR in6_addr_unspecified =
     310        IPV6_ADDR_UNSPECIFIED_INIT;
     311
     312#endif  /* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
    72313
    73314/*
     
    83324const char radhex[] = "0123456789abcdef";
    84325const char radHEX[] = "0123456789ABCDEF";
     326
     327/*
     328 *  netapp_rand -- 乱数を返す。
     329 */
     330
     331uint32_t
     332netapp_rand (void)
     333{
     334        rand_next = (rand_next * 99991 + 12345) & ULONG_C(0x7fffffff);
     335        return rand_next;
     336        }
     337
     338/*
     339 *  srand -- 乱数を初期化する。
     340 */
     341
     342void
     343netapp_srand (uint32_t seed)
     344{
     345        SYSTIM now;
     346
     347        syscall(get_tim(&now));
     348        rand_next += now + seed;
     349        }
    85350
    86351#ifndef USE_NET_CONS
     
    160425        return pchars;
    161426        }
    162 
    163 #if defined(SUPPORT_INET4)
    164427
    165428/*
     
    186449        }
    187450
    188 #define PUT_IPADDR(p,a,w)       put_ipv4addr(p,a,w)
    189 
    190 #endif  /* of #if defined(SUPPORT_INET4) */
    191 
    192 #if defined(SUPPORT_INET6)
    193 
    194451/*
    195452 *  ipv6addr -- IPv6 アドレス出力
     
    199456put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width)
    200457{
    201         int_t   len = 0, ix;
     458        int_t   len = 0, ix, len6;
    202459        bool_t  omit = false, zero = false;
    203460
    204         if (addr == NULL) {
     461        if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) {
    205462                cons_putchar(portid, '0');
    206463                cons_putchar(portid, ':');
     
    210467                }
    211468        else {
    212                 for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
     469                if (in6_is_addr_ipv4mapped(addr))
     470                        len6 = sizeof(T_IN6_ADDR) / 2 - 2;
     471                else
     472                        len6 = sizeof(T_IN6_ADDR) / 2;
     473                for (ix = 0; ix < len6; ix ++) {
    213474                        if (omit) {
    214475                                len += cons_putnumber(portid, ntohs(addr->s6_addr16[ix]), 16, radhex, 0, false, ' ');
     
    234495                        }
    235496
     497                if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
     498                        T_IN4_ADDR ip4addr;
     499
     500                        ip4addr = ntohl(addr->s6_addr32[3]);
     501                        len += put_ipv4addr(portid, &ip4addr, 0);
     502                        }
     503
    236504                for ( ; len < width; len ++)
    237505                        cons_putchar(portid, ' ');
     
    239507        return len;
    240508        }
    241 
    242 #define PUT_IPADDR(p,a,w)       put_ipv6addr(p,a,w)
    243 
    244 #endif  /* of #if defined(SUPPORT_INET6) */
    245509
    246510/*
     
    275539        long_t  val;
    276540        char    padchar, *str;
    277         int_t   ch, width, longflag, left;
    278 
    279 #if defined(SUPPORT_INET4)
     541        int_t   ch, width, longflag, shortflag, left;
    280542        T_IN4_ADDR      *addr;
    281 #endif  /* of #if defined(SUPPORT_INET4) */
    282543
    283544        va_start(ap, fmt);
     
    288549                        }
    289550
    290                 width = longflag = 0;
     551                width = longflag = shortflag = 0;
    291552                padchar = ' ';
    292553
    293                 if (ch == '-') {                /* 左詰め */
     554                if (*fmt == '-') {              /* 左詰め */
    294555                        fmt ++;
    295556                        left = -1;
     
    310571                while (ch == 'l') {             /* long (long) の指定 */
    311572                        longflag ++;
     573                        ch = *fmt ++;
     574                        }
     575
     576                while (ch == 'h') {             /* short の指定 */
     577                        shortflag ++;
    312578                        ch = *fmt ++;
    313579                        }
     
    358624                case 'I':
    359625
     626                        if (longflag) {
     627                                str = va_arg(ap, char*);
     628                                put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
     629                                }
     630                        else if (shortflag) {
     631                                addr = va_arg(ap, T_IN4_ADDR *);
     632                                put_ipv4addr(portid, addr, width);
     633                                }
     634                        else {
     635
     636#if defined(SUPPORT_INET6)
     637
     638                                str = va_arg(ap, char*);
     639                                put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
     640
     641#else   /* of #if defined(SUPPORT_INET6) */
     642
    360643#if defined(SUPPORT_INET4)
    361644
    362                         addr = va_arg(ap, T_IN4_ADDR *);
    363                         put_ipv4addr(portid, addr, width);
     645                                addr = va_arg(ap, T_IN4_ADDR *);
     646                                put_ipv4addr(portid, addr, width);
    364647
    365648#endif  /* of #if defined(SUPPORT_INET4) */
    366649
    367 #if defined(SUPPORT_INET6)
    368 
    369                         str = va_arg(ap, char*);
    370                         put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
    371 
    372650#endif  /* of #if defined(SUPPORT_INET6) */
    373651
     652                                }
    374653                        break;
    375654
    376655                case 'M':
    377656                        str = va_arg(ap, char*);
    378                         put_macaddr(portid, str, width);
     657                        put_macaddr(portid, (uint8_t *)str, width);
    379658                        break;
    380659
     
    396675
    397676/*
     677 *  host2msg16 -- 16ビットの値を、バイトオーダーを調整してメッセージに書き込む。
     678 */
     679
     680void
     681host2msg16 (void *msg, uint16_t host_data)
     682{
     683        uint16_t        msg_data;
     684
     685        msg_data = htons(host_data);
     686        memcpy(msg, &msg_data, sizeof(msg_data));
     687        }
     688
     689/*
     690 *  host2msg32 -- 32ビットの値を、バイトオーダーを調整してメッセージに書き込む。
     691 */
     692
     693void
     694host2msg32 (void *msg, uint32_t host_data)
     695{
     696        uint32_t        msg_data;
     697
     698        msg_data = htonl(host_data);
     699        memcpy(msg, &msg_data, sizeof(msg_data));
     700        }
     701
     702/*
     703 *  msg2host16 -- 16ビットの値を、バイトオーダーを調整してメッセージから読み出す。
     704 */
     705
     706uint16_t
     707msg2host16 (void *msg)
     708{
     709        uint16_t        host_data;
     710
     711        memcpy(&host_data, msg, sizeof(host_data));
     712        return htons(host_data);
     713        }
     714
     715/*
     716 *  msg2host32 -- 32ビットの値を、バイトオーダーを調整してメッセージから読み出す。
     717 */
     718
     719uint32_t
     720msg2host32 (void *msg)
     721{
     722        uint32_t        host_data;
     723
     724        memcpy(&host_data, msg, sizeof(host_data));
     725        return htonl(host_data);
     726        }
     727
     728/*
    398729 *  skip_blanks -- 空白と TAB をスキップする。
    399730 */
     
    416747        int_t oct;
    417748
    418         *addr = 0;
     749        *addr = IPV4_ADDRANY;
    419750        while ('0' <= *line && *line <= '9') {
    420751                oct = 0;
     
    425756                        line ++;
    426757                }
     758#if 1
     759        return *addr == IPV4_ADDRANY ? NULL : line;
     760#else
    427761        return line;
    428         }
    429 
    430 #if defined(SUPPORT_INET6)
     762#endif
     763        }
     764
     765#if defined(SUPPORT_INET6) || defined(USE_RESOLVER)
    431766
    432767/*
     
    438773{
    439774        int_t word, ix = 0, omit = 0, six;
     775        char *ipv4line;
    440776
    441777        memset(addr, 0, sizeof(T_IN6_ADDR));
    442         while (ix < 8 &&
    443                (('0' <= *line && *line <= '9') ||
    444                 ('a' <= *line && *line <= 'f') ||
    445                 ('A' <= *line && *line <= 'F'))) {
    446                 word = 0;
    447                 while (('0' <= *line && *line <= '9') ||
    448                        ('a' <= *line && *line <= 'f') ||
    449                        ('A' <= *line && *line <= 'F')) {
    450                         if      ('0' <= *line && *line <= '9')
    451                                 word = (word << 4) + (*line ++) - '0';
    452                         else if ('a' <= *line && *line <= 'f')
    453                                 word = (word << 4) + (*line ++) - 'a' + 10;
    454                         else if ('A' <= *line && *line <= 'F')
    455                                 word = (word << 4) + (*line ++) - 'A' + 10;
    456                         }
    457                 addr->s6_addr16[ix ++] = htons(word);
    458                 if (*line == ':') {
    459                         line ++;
     778
     779        /*
     780         * IPv4 アドレス(数字.)を検出したら IPv4 アドレスとして入力し、
     781         * IPv4 射影アドレスに変換する。
     782         */
     783        for (ipv4line = line; '0' <= *ipv4line && *ipv4line <= '9'; ipv4line ++)
     784                ;
     785        if (*ipv4line == '.') {
     786                T_IN4_ADDR ipv4addr;
     787
     788                line = get_ipv4addr(&ipv4addr, line);
     789                in6_make_ipv4mapped (addr, ipv4addr);
     790                }
     791        else {
     792                while (ix < 8 &&
     793                       (('0' <= *line && *line <= '9') ||
     794                        ('a' <= *line && *line <= 'f') ||
     795                        ('A' <= *line && *line <= 'F'))) {
     796                        word = 0;
     797                        while (('0' <= *line && *line <= '9') ||
     798                               ('a' <= *line && *line <= 'f') ||
     799                               ('A' <= *line && *line <= 'F')) {
     800                                if      ('0' <= *line && *line <= '9')
     801                                        word = (word << 4) + (*line ++) - '0';
     802                                else if ('a' <= *line && *line <= 'f')
     803                                        word = (word << 4) + (*line ++) - 'a' + 10;
     804                                else if ('A' <= *line && *line <= 'F')
     805                                        word = (word << 4) + (*line ++) - 'A' + 10;
     806                                }
     807                        addr->s6_addr16[ix ++] = htons(word);
    460808                        if (*line == ':') {
    461                                 omit = ix;
    462809                                line ++;
    463                                 }
    464                         }
    465                 }
    466         if (omit > 0) {
    467                 six = 7;
    468                 while (ix > omit) {
    469                         addr->s6_addr16[six --] = addr->s6_addr16[-- ix];
    470                         addr->s6_addr16[ ix   ] = 0;
     810                                if (*line == ':') {
     811                                        omit = ix;
     812                                        line ++;
     813                                        }
     814                                }
     815                        }
     816                if (omit > 0) {
     817                        six = 7;
     818                        while (ix > omit) {
     819                                addr->s6_addr16[six --] = addr->s6_addr16[-- ix];
     820                                addr->s6_addr16[ ix   ] = 0;
     821                                }
    471822                        }
    472823                }
     
    474825        }
    475826
    476 #endif  /* of #if defined(SUPPORT_INET6) */
     827#endif  /* of #if defined(SUPPORT_INET6) || defined(USE_RESOLVER) */
    477828
    478829/*
     
    559910        }
    560911
    561 #ifdef USE_TCP_EXTENTIONS
    562 
    563 const ID vrid_tcp_rep[] =
    564 {
    565 #if NUM_VRID_TCP_REPS >= 1
    566         TCP_RSV_REPID1,
    567 #endif
    568 #if NUM_VRID_TCP_REPS >= 2
    569         TCP_RSV_REPID2,
    570 #endif
    571         };
    572 
    573 const ID vrid_tcp_cep[] =
    574 {
    575 #if NUM_VRID_TCP_CEPS >= 1
    576         TCP_RSV_CEPID1,
    577 #endif
    578 #if NUM_VRID_TCP_CEPS >= 2
    579         TCP_RSV_CEPID2,
    580 #endif
    581 #if NUM_VRID_TCP_CEPS >= 3
    582         TCP_RSV_CEPID3,
    583 #endif
    584 #if NUM_VRID_TCP_CEPS >= 4
    585         TCP_RSV_CEPID4,
    586 #endif
    587         };
    588 
    589 ID tskid_tcp_rep[NUM_VRID_TCP_REPS];
    590 ID tskid_tcp_cep[NUM_VRID_TCP_CEPS];
    591 
    592 /*
    593  *  alloc_tcp_rep -- TCP 受付口を獲得する。
    594  */
    595 
    596 ER
    597 alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep)
    598 {
    599         int_t   ix;
    600 
    601         *repid = TCP_REP_NONE;
    602         syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
    603         for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
    604                 if (tskid_tcp_rep[ix] == TSK_NONE) {
    605                         *repid = vrid_tcp_rep[ix];
    606                         tskid_tcp_rep[ix] = tskid;
     912#ifdef USE_RESOLVER
     913
     914/*
     915 *  dns_strtype -- DNS の type の文字列を返す。
     916 */
     917
     918const char *
     919dns_strtype (uint_t type)
     920{
     921        switch (type) {
     922        case DNS_TYPE_A:
     923                return "A";
     924                break;
     925        case DNS_TYPE_NS:
     926                return "NS";
     927                break;
     928        case DNS_TYPE_CNAME:
     929                return "CNAME";
     930                break;
     931        case DNS_TYPE_SOA:
     932                return "SOA";
     933                break;
     934        case DNS_TYPE_PTR:
     935                return "PTR";
     936                break;
     937        case DNS_TYPE_AAAA:
     938                return "AAAA";
     939                break;
     940        default:
     941                return "unknown type";
     942                break;
     943                }
     944        }
     945
     946/*
     947 *  dns_strclass -- DNS の class を表示する。
     948 */
     949
     950const char *
     951dns_strclass (uint_t class)
     952{
     953        switch (class) {
     954        case DNS_CLASS_IN:
     955                return "IN";
     956                break;
     957        default:
     958                return "unknown class";
     959                break;
     960                }
     961        }
     962
     963/*
     964 *  resolv_hoststr -- 文字列のFQDN・ホスト名・IPv6/IPv4 アドレスを解析する。
     965 */
     966
     967#define IS_HOSTCH_DIGIT(c)      (('0'<=(c)&&(c)<='9'))
     968#define IS_HOSTCH_XDIGIT(c)     (IS_HOSTCH_DIGIT(c)||('a'<=(c)&&(c)<='f')||('A'<=(c)&&(c)<='F'))
     969#define IS_HOSTCH_ALPHA(c)      (('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='z'))
     970#define IS_HOSTCH_ALNUM(c)      (IS_HOSTCH_ALPHA(c)||IS_HOSTCH_DIGIT(c))
     971#define IS_HOSTCH_IPV6ADDR(c)   (IS_HOSTCH_XDIGIT(c)||(c)==':')
     972#define IS_HOSTCH_IPV4ADDR(c)   (IS_HOSTCH_DIGIT(c)||(c)=='.')
     973#define IS_HOSTCH_IPADDR(c)     (IS_HOSTCH_XDIGIT(c)||(c)==':'||(c)=='.')
     974#define IS_HOSTCH_NAME_FIRST(c) (IS_HOSTCH_ALPHA(c))
     975#define IS_HOSTCH_NAME(c)       (IS_HOSTCH_ALNUM(c)||(c)=='-'||(c)=='.')
     976#define IS_HOSTCH_BLANK(c)      ((c)=='\0'||(c)==' '||(c)=='\t')
     977
     978char *
     979resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line)
     980{
     981        char *h, *p;
     982
     983        h = hostname;
     984        p = line = skip_blanks(line);
     985
     986        if (IS_HOSTCH_IPADDR(*p)) {
     987                while (IS_HOSTCH_DIGIT(*p)) {
     988                        if (h - hostname > name_size)
     989                                return NULL;
     990                        *h ++ = *p ++;
     991                        }
     992                if (p > line && *p == '.') {
     993                        while (IS_HOSTCH_IPV4ADDR(*p)) {
     994                                if (h - hostname > name_size)
     995                                        return NULL;
     996                                *h ++ = *p ++;
     997                                }
     998                        if (IS_HOSTCH_BLANK(*p)) {
     999                                *flags |= HOSTSTR_IPV4;
     1000                                *h = '\0';
     1001                                return p;
     1002                                }
     1003                        }
     1004                else if (IS_HOSTCH_IPADDR(*p)) {
     1005                        while (IS_HOSTCH_IPADDR(*p)) {
     1006                                if (h - hostname > name_size)
     1007                                        return NULL;
     1008                                *h ++ = *p ++;
     1009                                }
     1010                        if (IS_HOSTCH_BLANK(*p)) {
     1011                                *flags |= HOSTSTR_IPV6;
     1012                                *h = '\0';
     1013                                return p;
     1014                                }
     1015                        }
     1016                h = hostname;
     1017                p = line;
     1018                }
     1019
     1020        if (IS_HOSTCH_NAME_FIRST(*p)) {
     1021                *flags |= HOSTSTR_HOSTNAME;
     1022                while (IS_HOSTCH_NAME(*p)) {
     1023                        if (h - hostname > name_size)
     1024                                return NULL;
     1025                        if (*p == '.')
     1026                                *flags |= HOSTSTR_FQDN;
     1027                        *h ++ = *p ++;
     1028                        }
     1029                }
     1030        else
     1031                *flags |= HOSTSTR_OTHER;
     1032
     1033        *h = '\0';
     1034        return p;
     1035        }
     1036
     1037/*
     1038 *  show_dns_domain_name -- DNS のドメイン名を表示する。
     1039 */
     1040
     1041uint_t
     1042show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset)
     1043{
     1044        uint8_t *ptr;
     1045        uint_t  c;
     1046
     1047        ptr = hdr + offset;
     1048        while (*ptr) {
     1049                if ((*ptr & DNS_MSG_COMP_MARK) == DNS_MSG_COMP_MARK) {
     1050                        show_dns_domain_name(portid, hdr, (*ptr & ~DNS_MSG_COMP_MARK) << 8 | *(ptr + 1));
     1051                        ptr += 2;
    6071052                        break;
    6081053                        }
    609                 }
    610         syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
    611 
    612         if (*repid == TCP_REP_NONE)
    613                 return E_NOEXS;
     1054                else {
     1055                        for (c = 1; c <= *ptr; c++)
     1056                                cons_printf(portid, "%c", *(ptr + c));
     1057                        ptr += *ptr + 1;
     1058                        if (*ptr)
     1059                                cons_printf(portid, ".");
     1060                        }
     1061                }
     1062        return ptr - hdr;
     1063        }
     1064
     1065/*
     1066 *  resolv_options -- アドレス解決のオプション解析
     1067 */
     1068
     1069char *
     1070resolv_options (uint_t *flags, char *line, char apip)
     1071{
     1072#if defined(SUPPORT_INET6)
     1073        T_IN6_ADDR      in6_addr;
     1074#endif
     1075
     1076#if defined(SUPPORT_INET4)
     1077        T_IN4_ADDR      in4_addr;
     1078#endif
     1079
     1080        line = skip_blanks(line);
     1081
     1082#if defined(SUPPORT_INET6)
     1083
     1084#if defined(SUPPORT_INET4)
     1085
     1086        *flags |= DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4;
     1087        if (apip == API_PROTO_IPV4)
     1088                *flags |= DNS_LUP_FLAGS_QTYPE_A;
    6141089        else
    615                 return TCP_CRE_REP(*repid, crep);
    616         }
    617 
    618 /*
    619  *  free_tcp_rep -- TCP 受付口を解放する。
    620  */
    621 
    622 ER
    623 free_tcp_rep (ID repid, bool_t call_tcp_del_rep)
    624 {
    625         int_t   ix;
    626 
    627         syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
    628         for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
    629                 if (repid == vrid_tcp_rep[ix]) {
    630                         tskid_tcp_rep[ix] = TSK_NONE;
    631                         break;
    632                         }
    633                 }
    634         syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
    635 
    636         if (call_tcp_del_rep)
    637                 return tcp_del_rep(repid);
    638         else
    639                 return E_OK;
    640         }
    641 
    642 /*
    643  *  alloc_tcp_cep -- TCP 通信端点を獲得する。
    644  */
    645 
    646 ER
    647 alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep)
    648 {
    649         int_t   ix;
    650 
    651         *cepid = TCP_CEP_NONE;
    652         syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
    653         for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
    654                 if (tskid_tcp_cep[ix] == TSK_NONE) {
    655                         *cepid = vrid_tcp_cep[ix];
    656                         tskid_tcp_cep[ix] = tskid;
    657                         break;
    658                         }
    659                 }
    660         syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
    661 
    662         if (*cepid == TCP_CEP_NONE)
    663                 return E_NOEXS;
    664         else
    665                 return tcp_cre_cep(*cepid, ccep);
    666         }
    667 
    668 /*
    669  *  free_tcp_cep -- TCP 通信端点を解放する。
    670  */
    671 
    672 ER
    673 free_tcp_cep (ID cepid)
    674 {
    675         int_t   ix;
    676 
    677         syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
    678         for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
    679                 if (cepid == vrid_tcp_cep[ix]) {
    680                         tskid_tcp_cep[ix] = TSK_NONE;
    681                         break;
    682                         }
    683                 }
    684         syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
    685 
    686         return tcp_del_cep(cepid);
    687         }
    688 
    689 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    690 
    691 #ifdef USE_UDP_EXTENTIONS
    692 
    693 const ID vrid_udp_cep[] =
    694 {
    695 #if NUM_VRID_UDP_CEPS >= 1
    696         UDP_RSV_CEPID1,
    697 #endif
    698 #if NUM_VRID_UDP_CEPS >= 2
    699         UDP_RSV_CEPID2,
    700 #endif
    701         };
    702 
    703 ID tskid_udp_cep[NUM_VRID_UDP_CEPS];
    704 
    705 /*
    706  *  alloc_udp_cep -- UDP 通信端点を獲得する。
    707  */
    708 
    709 ER
    710 alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep)
    711 {
    712         int_t   ix;
    713 
    714         *cepid = UDP_CEP_NONE;
    715         syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
    716         for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
    717                 if (tskid_udp_cep[ix] == TSK_NONE) {
    718                         *cepid = vrid_udp_cep[ix];
    719                         tskid_udp_cep[ix] = tskid;
    720                         break;
    721                         }
    722                 }
    723         syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
    724 
    725         if (*cepid == UDP_CEP_NONE)
    726                 return E_NOEXS;
    727         else
    728                 return UDP_CRE_CEP(*cepid, ccep);
    729         }
    730 
    731 /*
    732  *  free_udp_cep -- UDP 通信端点を解放する。
    733  */
    734 
    735 ER
    736 free_udp_cep (ID cepid, bool_t call_udp_del_cep)
    737 {
    738         int_t   ix;
    739 
    740         syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
    741         for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
    742                 if (cepid == vrid_udp_cep[ix]) {
    743                         tskid_udp_cep[ix] = TSK_NONE;
    744                         break;
    745                         }
    746                 }
    747         syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
    748 
    749         if (call_udp_del_cep)
    750                 return udp_del_cep(cepid);
    751         else
    752                 return E_OK;
    753         }
    754 
    755 #endif  /* of #ifdef USE_UDP_EXTENTIONS */
     1090                *flags |= DNS_LUP_FLAGS_QTYPE_AAAA;
     1091
     1092        if (*line == '-') {
     1093                line ++;
     1094                if (*line == '6') {
     1095                        line ++;
     1096                        *flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
     1097                        }
     1098                else if (*line == '4') {
     1099                        line ++;
     1100                        *flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
     1101                        }
     1102                if (*line == 'Q' || *line == 'q') {
     1103                        *flags &= ~DNS_LUP_FLAGS_QTYPE_A;
     1104                        line ++;                   
     1105                        }
     1106                else if (*line == 'A' || *line == 'a') {
     1107                        *flags &= ~DNS_LUP_FLAGS_QTYPE_AAAA;
     1108                        line ++;                   
     1109                        }
     1110                while (*line && !(*line == ' ' || *line == '\t'))
     1111                        line ++;
     1112                }
     1113
     1114#else   /* of #if defined(SUPPORT_INET4) */
     1115
     1116        *flags = DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_QTYPE_AAAA;
     1117        if (*line == '-') {
     1118                line ++;
     1119                while (*line && !(*line == ' ' || *line == '\t'))
     1120                        line ++;
     1121                }
     1122
     1123#endif  /* of #if defined(SUPPORT_INET4) */
     1124
     1125#else   /* of #if defined(SUPPORT_INET6) */
     1126
     1127#if defined(SUPPORT_INET4)
     1128
     1129        *flags = DNS_LUP_FLAGS_PROTO_IPV4 | DNS_LUP_FLAGS_QTYPE_A;
     1130        if (*line == '-') {
     1131                line ++;
     1132                while (*line && !(*line == ' ' || *line == '\t'))
     1133                        line ++;
     1134                }
     1135
     1136#endif  /* of #if defined(SUPPORT_INET4) */
     1137
     1138#endif  /* of #if defined(SUPPORT_INET6) */
     1139
     1140#if defined(SUPPORT_INET6)
     1141
     1142        if (*flags | DNS_LUP_FLAGS_PROTO_IPV6) {
     1143                /*
     1144                 *  IPv6 で DNS サーバに照会することが指定されても、
     1145                 *  サーバの IPv6 アドレスが未定義の時は、指定を外す。
     1146                 */
     1147                dns_in6_get_addr(&in6_addr);
     1148                if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
     1149                        *flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
     1150                }
     1151
     1152#endif  /* of #if defined(SUPPORT_INET6) */
     1153
     1154#if defined(SUPPORT_INET4)
     1155
     1156        if (*flags | DNS_LUP_FLAGS_PROTO_IPV4) {
     1157                /*
     1158                 *  IPv4 で DNS サーバに照会することが指定されても、
     1159                 *  サーバの IPv4 アドレスが未定義の時は、指定を外す。
     1160                 */
     1161                dns_in4_get_addr(&in4_addr);
     1162                if (in4_addr == IPV4_ADDRANY)
     1163                        *flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
     1164                }
     1165
     1166#endif  /* of #if defined(SUPPORT_INET4) */
     1167
     1168        return line;
     1169        }
     1170
     1171#endif  /* of #ifdef USE_RESOLVER */
     1172
     1173/*
     1174 *  lookup_ipaddr -- ホスト名・リテラルのIPアドレスをIP アドレスに変換する。
     1175 */
     1176
     1177char *
     1178lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip)
     1179{
     1180
     1181#ifdef USE_RESOLVER
     1182
     1183        static char hostname[DBG_LINE_SIZE + 1];
     1184
     1185        ER_UINT error;
     1186        uint_t  flags = 0;
     1187        char    *last;
     1188
     1189        line = skip_blanks(resolv_options(&flags, line, apip));
     1190        if ((last = resolv_hoststr(&flags, hostname, sizeof(hostname), line)) == NULL) {
     1191                cons_printf(CONSOLE_PORTID, "unknown host: %s.\n", hostname);
     1192                return NULL;
     1193                }
     1194
     1195        switch (flags & DNS_LUP_FLAGS_NAME_MASK) {
     1196        case DNS_LUP_FLAGS_NAME_IPV4:
     1197        case DNS_LUP_FLAGS_NAME_IPV6:
     1198                line = GET_IPADDR(addr, line);          /* IP Address by Literal */
     1199                break;
     1200
     1201        case DNS_LUP_FLAGS_NAME_HOST:
     1202        case DNS_LUP_FLAGS_NAME_FQDN:
     1203                line = last;
     1204                if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
     1205                        cons_printf(CONSOLE_PORTID, "DNS server not available.\n");
     1206                        return NULL;
     1207                        }
     1208
     1209                flags |= DNS_LUP_OPCODE_FORWARD;
     1210                if ((error = dns_host_addr(flags, hostname, addr)) != E_OK) {
     1211                        cons_printf(CONSOLE_PORTID, "error: %s.\n", itron_strerror(error));
     1212                        return NULL;
     1213                        }
     1214                break;
     1215
     1216                }
     1217
     1218        return line;
     1219
     1220#else   /* of #ifdef USE_RESOLVER */
     1221
     1222        return GET_IPADDR(addr, skip_blanks(line));             /* IP Address by Literal */
     1223
     1224#endif   /* of #ifdef USE_RESOLVER */
     1225
     1226        }
    7561227
    7571228#endif  /* of #ifdef USE_NETAPP_SUBR */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_var.h

    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 *
     
    3636
    3737/*
    38  *  マクロ定義
    39  */
    40 
    41 #if defined(SUPPORT_INET4)
    42 #define T_IPEP          T_IPV4EP
     38 *  TOPPERS/JSP カーネル、システム時刻 (SYSTIM) の周波数
     39 */
     40
     41#define SYSTIM_HZ               ULONG_C(1000000)        /* [us]                                 */
     42
     43/*
     44 *  IPv6/IPv4 に関する定義
     45 */
     46
     47/*
     48 *  指定されたマクロに対するサンプルアプリケーション内部のマクロの定義
     49 *
     50 *    SUPPORT_INET6              .   .  ON  ON  ON  ON
     51 *    SUPPORT_INET4             ON  ON   .   .  ON  ON
     52 *    API_CFG_IP4MAPPED_ADDR     .  ON   .  ON   .  ON
     53 *    ----------------------    ----------------------
     54 *    NETAPP_IP6_CFG             .   .  ON  ON  ON  ON
     55 *    NETAPP_IP4_CFG            ON  ON   .  ON  ON  ON
     56 *   
     57 */
     58
     59#if defined(SUPPORT_INET6)
     60
     61#define NETAPP_IP6_CFG
     62
     63#endif  /* #if defined(SUPPORT_INET6) */
     64
     65#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
     66#define NETAPP_IP4_CFG
    4367#endif
    4468
    45 #if defined(SUPPORT_INET6)
    46 #define T_IPEP          T_IPV6EP
     69/*
     70 *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
     71 */
     72
     73#define DBG_LINE_SIZE           63
     74
     75#if defined(SUPPORT_INET6)
     76
     77#define T_IN_ADDR               T_IN6_ADDR
     78#define T_IPEP                  T_IPV6EP
     79#define IP_ADDRANY              IPV6_ADDRANY
     80#define T_TCPN_CREP             T_TCP6_CREP
     81
     82#else   /* of #if defined(SUPPORT_INET6) */
     83
     84#define T_IN_ADDR               T_IN4_ADDR
     85#define T_IPEP                  T_IPV4EP
     86#define IP_ADDRANY              IPV4_ADDRANY
     87#define T_TCPN_CREP             T_TCP_CREP
     88
     89#endif  /* of #if defined(SUPPORT_INET6) */
     90
     91/*
     92 *  API IPプロトコルの指定
     93 */
     94
     95#if defined(SUPPORT_INET6)
     96#define DEFAULT_API_PROTO       API_PROTO_IPV6
     97#else
     98#define DEFAULT_API_PROTO       API_PROTO_IPV4
    4799#endif
     100
     101/*
     102 *  resolv_hoststr が返す flags の値の定義
     103 *
     104 *    注意:
     105 *
     106 *      dns.h で定義されている DNS_OPCODE、
     107 *      resolver.h で定義されている DNS_LUP_FLAGS と重ならない事。
     108 */
     109
     110#define HOSTSTR_OTHER           0x0000U
     111#define HOSTSTR_IPV4            DNS_LUP_FLAGS_NAME_IPV4
     112#define HOSTSTR_IPV6            DNS_LUP_FLAGS_NAME_IPV6
     113#define HOSTSTR_HOSTNAME        DNS_LUP_FLAGS_NAME_HOST
     114#define HOSTSTR_FQDN            DNS_LUP_FLAGS_NAME_FQDN
     115
     116/*
     117 *  定数の定義
     118 */
     119
     120#define DBG_LINE_SIZE           63
     121
     122#if defined(SUPPORT_INET6)
     123
     124#define NUM_VRID_TCP_CEPS       NUM_VRID_TCP6_CEPS
     125
     126#else   /* of #if defined(SUPPORT_INET6) */
     127
     128#define NUM_VRID_TCP_CEPS       NUM_VRID_TCP4_CEPS
     129
     130#endif  /* of #if defined(SUPPORT_INET6) */
     131
     132/*
     133 *  関数シミュレーションマクロ
     134 */
     135
     136/* メッセージからの読出し */
     137
     138#define MSG2HOST16(p)           (msg2host16((void*)&(p)))
     139#define MSG2HOST32(p)           (msg2host32((void*)&(p)))
     140
     141/* メッセージへの書込み */
     142
     143#define HOST2MSG16(p,v)         (host2msg16((void*)&(p),(v)))
     144#define HOST2MSG32(p,v)         (host2msg32((void*)&(p),(v)))
    48145
    49146/*
     
    80177extern const char *in_strtfn (FN fncd);
    81178extern const char *itron_strerror (ER ercd);
     179extern const char *dns_strtype (uint_t type);
     180extern const char *dns_strclass (uint_t class);
    82181extern ER       net_syslog(uint_t prio, const char *format, ...) throw();
    83182extern ER       net_serial_ctl_por(ID portid, uint_t ioctl) throw();
     
    85184extern ER       discon_net_cons (void);
    86185extern void     wup_net_cons (void);
    87 extern ER       alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
    88 extern ER       free_tcp_rep (ID repid, bool_t call_tcp_del_rep);
    89 extern ER       alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
    90 extern ER       free_tcp_cep (ID cepid);
    91 extern ER       alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
    92 extern ER       free_udp_cep (ID cepid, bool_t call_udp_del_cep);
     186extern bool_t   tcp6_is_cepid (ID cepid);
     187extern ER       alloc_tcp6_rep (ID *repid, ID tskid, T_TCP6_CREP *crep);
     188extern ER       alloc_tcp6_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
     189extern ER       alloc_udp6_cep (ID *cepid, ID tskid, T_UDP6_CCEP *ccep);
     190extern ER       free_tcp6_rep (ID repid, bool_t call_tcp_del_rep);
     191extern ER       free_tcp6_cep (ID cepid);
     192extern ER       free_udp6_cep (ID cepid, bool_t call_udp_del_cep);
     193extern bool_t   tcp4_is_cepid (ID cepid);
     194extern ER       alloc_tcp4_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
     195extern ER       alloc_tcp4_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
     196extern ER       alloc_udp4_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
     197extern ER       free_tcp4_rep (ID repid, bool_t call_tcp_del_rep);
     198extern ER       free_tcp4_cep (ID cepid);
     199extern ER       free_udp4_cep (ID cepid, bool_t call_udp_del_cep);
     200extern void     ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
     201extern void     ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
     202extern char     *get_ipv6addr (T_IN6_ADDR *addr, char *line);
     203extern char     *get_ipv4addr (T_IN4_ADDR *addr, char *line);
     204extern char     *resolv_options (uint_t *flags, char *line, char apip);
     205extern char     *resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line);
     206extern char     *lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip);
     207extern uint_t   show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset);
     208extern void     host2msg16 (void *msg, uint16_t host_data);
     209extern void     host2msg32 (void *msg, uint32_t host_data);
     210extern uint16_t msg2host16 (void *msg);
     211extern uint32_t msg2host32 (void *msg);
     212extern uint32_t netapp_rand (void);
     213extern void     netapp_srand (uint32_t seed);
     214
     215#if defined(SUPPORT_INET6)
     216
     217#define TCP_CRE_REP(i,r)        tcp6_cre_rep(i,r)
     218#define TCP_CRE_CEP(i,c)        tcp6_cre_cep(i,c)
     219#define UDP_CRE_CEP(i,c)        udp6_cre_cep(i,c)
     220#define TCP_ACP_CEP(c,r,d,t)    tcp6_acp_cep(c,r,d,t)
     221#define TCP_CON_CEP(c,m,d,t)    tcp6_con_cep(c,m,d,t)
     222
     223#define UDP_SND_DAT(c,d,b,l,t)  udp6_snd_dat(c,d,b,l,t)
     224#define UDP_RCV_DAT(c,d,b,l,t)  udp6_rcv_dat(c,d,b,l,t)
     225
     226#define TCP_IS_CEPID(i)         tcp6_is_cepid(i)
     227#define ALLOC_TCP_REP(i,t,r)    alloc_tcp6_rep(i,t,r)
     228#define ALLOC_TCP_CEP(i,t,c)    alloc_tcp6_cep(i,t,c)
     229#define ALLOC_UDP_CEP(i,t,c)    alloc_udp6_cep(i,t,c)
     230#define FREE_TCP_REP(i,r)       free_tcp6_rep(i,r)
     231#define FREE_TCP_CEP(i)         free_tcp6_cep(i)
     232#define FREE_UDP_CEP(i,c)       free_udp6_cep(i,c)
     233
     234#define IP2STR(s,a)             ipv62str(s,a)
     235#define GET_IPADDR(a,l)         get_ipv6addr(a,l)
     236#define PING(a,t,l)             ping6(a,t,l)
     237
     238#else   /* of #if defined(SUPPORT_INET6) */
    93239
    94240#if defined(SUPPORT_INET4)
     
    103249#define UDP_RCV_DAT(c,d,b,l,t)  udp_rcv_dat(c,d,b,l,t)
    104250
     251#define TCP_IS_CEPID(i)         tcp4_is_cepid(i)
     252#define ALLOC_TCP_REP(i,t,r)    alloc_tcp4_rep(i,t,r)
     253#define ALLOC_TCP_CEP(i,t,c)    alloc_tcp4_cep(i,t,c)
     254#define ALLOC_UDP_CEP(i,t,c)    alloc_udp4_cep(i,t,c)
     255#define FREE_TCP_REP(i,r)       free_tcp4_rep(i,r)
     256#define FREE_TCP_CEP(i)         free_tcp4_cep(i)
     257#define FREE_UDP_CEP(i,c)       free_udp4_cep(i,c)
     258
    105259#define IP2STR(s,a)             ip2str(s,a)
    106 
    107260#define GET_IPADDR(a,l)         get_ipv4addr(a,l)
    108261#define PING(a,t,l)             ping4(a,t,l)
    109262
    110 extern void ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
    111 extern char *get_ipv4addr (T_IN4_ADDR *addr, char *line);
    112 
    113263#endif  /* of #if defined(SUPPORT_INET4) */
    114264
    115 #if defined(SUPPORT_INET6)
    116 
    117 #define TCP_CRE_REP(i,r)        tcp6_cre_rep(i,r)
    118 #define TCP_CRE_CEP(i,c)        tcp6_cre_cep(i,c)
    119 #define UDP_CRE_CEP(i,c)        udp6_cre_cep(i,c)
    120 #define TCP_ACP_CEP(c,r,d,t)    tcp6_acp_cep(c,r,d,t)
    121 #define TCP_CON_CEP(c,m,d,t)    tcp6_con_cep(c,m,d,t)
    122 
    123 #define UDP_SND_DAT(c,d,b,l,t)  udp6_snd_dat(c,d,b,l,t)
    124 #define UDP_RCV_DAT(c,d,b,l,t)  udp6_rcv_dat(c,d,b,l,t)
    125 
    126 #define IP2STR(s,a)             ipv62str(s,a)
    127 
    128 #define GET_IPADDR(a,l)         get_ipv6addr(a,l)
    129 #define PING(a,t,l)             ping6(a,t,l)
    130 
    131 extern void ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
    132 extern char *get_ipv6addr (T_IN6_ADDR *addr, char *line);
    133 
    134265#endif  /* of #if defined(SUPPORT_INET6) */
    135266
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping.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 *
     
    6161#include <net/ppp_ipcp.h>
    6262#include <net/net.h>
     63#include <net/net_endian.h>
    6364#include <net/net_buf.h>
    6465#include <net/net_timer.h>
     
    7475#ifdef USE_PING
    7576
     77#if defined(SUPPORT_INET4)
     78
    7679/*
    7780 *  変数
    7881 */
    7982
    80 static uint16_t icmp_id = 0;
     83#if 0
    8184static uint16_t curr_icmp_id;
    8285static uint16_t curr_icmp_len;
     86#endif
     87
     88static uint16_t icmp_id = 0;
    8389static SYSTIM   icmp_start_time;
    8490
     
    9096icmp_reply_timeout (void *arg)
    9197{
    92         syslog(LOG_NOTICE, "[PING] request timeout.");
     98        syslog(LOG_NOTICE, "[PING4] request timeout.");
    9399        }
    94100
     
    100106icmp_echo_reply (T_NET_BUF *input, uint_t ihoff)
    101107{
    102         SYSTIM time;
     108        SYSTIM          time;
     109        T_IN4_ADDR      addr;
    103110
    104111        syscall(get_tim(&time));
     112        addr = ntohl(GET_IP4_HDR(input)->src);
    105113        untimeout(icmp_reply_timeout, NULL);
    106         syslog(LOG_NOTICE, "[PING] reply, %d [ms].",
    107                            (time - icmp_start_time) * 1000 / SYSTIM_HZ);
     114        syslog(LOG_NOTICE, "[PING4] reply: %5ld [ms] from: %s",
     115                           (time - icmp_start_time) * 1000 / SYSTIM_HZ,
     116                           ip2str(NULL, &addr));
    108117        }
    109118
     
    143152
    144153        /* 応答チェック用の変数を設定する。*/
     154#if 0
    145155        curr_icmp_id  = icmp_id ++;
    146156        curr_icmp_len = len;
     157#endif
    147158
    148159        NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
     
    157168        }
    158169
     170#endif  /* of #if defined(SUPPORT_INET4) */
     171
    159172#endif  /* of #ifdef USE_PING */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping6.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 *
     
    6161#include <net/ppp_ipcp.h>
    6262#include <net/net.h>
     63#include <net/net_endian.h>
    6364#include <net/net_buf.h>
    6465#include <net/net_timer.h>
     
    6768#include <netinet/in.h>
    6869#include <netinet/in_var.h>
     70#include <netinet/ip.h>
     71#include <netinet/ip_var.h>
     72#include <netinet/ip_icmp.h>
    6973
    70 #include <netinet6/in6.h>
    71 #include <netinet6/in6_var.h>
    7274#include <netinet6/nd6.h>
    7375
    74 #include <netinet/ip6.h>
    75 #include <netinet6/ip6_var.h>
    76 #include <netinet/icmp6.h>
    77 
    78 #include <net/if6_var.h>
     76#include <net/if_var.h>
    7977
    8078#ifdef USE_PING
     79
     80#if defined(SUPPORT_INET6)
    8181
    8282/*
     
    8484 */
    8585
    86 static uint16_t send_icmp6_id = 0;
     86#if 0
    8787static uint16_t curr_icmp6_id;
    8888static uint16_t curr_icmp6_size;
     89#endif
     90
     91static uint16_t send_icmp6_id = 0;
    8992static uint16_t reply_count;
    9093static SYSTIM   icmp6_start_time;
     
    108111icmp6_echo_reply (T_NET_BUF *input, uint_t ihoff)
    109112{
    110         T_IP6_HDR       *ip6h;
    111         SYSTIM          time;
     113        SYSTIM  time;
    112114
    113115        syscall(get_tim(&time));
    114         ip6h  = GET_IP6_HDR(input);
    115 
    116         syslog(LOG_NOTICE, "[PING6] reply: %5d [ms] from: %s",
     116        untimeout(icmp6_reply_timeout, NULL);
     117        syslog(LOG_NOTICE, "[PING6] reply: %5ld [ms] from: %s",
    117118                           (time - icmp6_start_time) * 1000 / SYSTIM_HZ,
    118                            ipv62str(NULL, &ip6h->src));
     119                           ipv62str(NULL, &GET_IP6_HDR(input)->src));
    119120        reply_count ++;
    120121        }
     
    169170
    170171        /* 応答チェック用の変数を設定する。*/
     172        reply_count = 0;
     173
     174#if 0
    171175        curr_icmp6_id   = send_icmp6_id ++;
    172176        curr_icmp6_size = size;
     177#endif
    173178
    174         reply_count = 0;
    175 
     179#if 0
    176180        syslog(LOG_NOTICE, "[PING6] send: TMO:%d, SIZE:%d, to: %s, from %s",
    177181                           tmo, size,
    178182                           ipv62str(NULL, addr), ipv62str(NULL, &ia->addr));
     183#endif
    179184
    180185        /* 送信後、現在の時間を記憶し、タイムアウトを設定する。*/
     
    188193        }
    189194
     195#endif  /* of #if defined(SUPPORT_INET6) */
     196
    190197#endif  /* of #ifdef USE_PING */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.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 *
     
    5858#endif  /* of #ifdef TARGET_KERNEL_JSP */
    5959
    60 #include <tinet_defs.h>
    61 #include <tinet_config.h>
    62 
    63 #include <net/if.h>
    64 #include <net/if_ppp.h>
    65 #include <net/if_loop.h>
    66 #include <net/ethernet.h>
    67 #include <net/net.h>
    68 #include <net/net_var.h>
    69 #include <net/net_timer.h>
    70 
    7160#include <netinet/in.h>
    7261#include <netinet/in_itron.h>
    73 #include <netinet/ip.h>
    74 #include <netinet/ip6.h>
    75 #include <netinet/tcp.h>
    7662
    7763#include <netapp/netapp.h>
    7864#include <netapp/netapp_var.h>
    79 #include <netapp/discard.h>
     65#include <netapp/tcp_discard_cli.h>
    8066
    8167#ifdef USE_TCP_DISCARD_CLI
     
    8874
    8975/*#define SHOW_RCV_RANGE*/
     76
     77/* 送信間隔 */
     78
     79#ifdef TOPPERS_S810_CLG3_85
     80
     81#define START_DLY       (10*SYSTIM_HZ)
     82#define SND_ITV         (5*SYSTIM_HZ)
     83#define SLP_ITV         (30*SYSTIM_HZ)
     84
     85#else   /* of #ifdef TOPPERS_S810_CLG3_85 */
     86
     87#define START_DLY       (10*SYSTIM_HZ)
     88#define SND_ITV         (5*SYSTIM_HZ)
     89#define SLP_ITV         (60*SYSTIM_HZ)
     90
     91#endif  /* of #ifdef TOPPERS_S810_CLG3_85 */
     92
     93/* 自動実行 */
     94
     95#if defined(TCP_DISCARD_CLI_AUTO_RUN_STR)
     96#else
     97#if 0
     98#if defined(SUPPORT_INET6)
     99#define TCP_DISCARD_CLI_AUTO_RUN_STR    "fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
     100#else
     101#define TCP_DISCARD_CLI_AUTO_RUN_STR    "172.25.129.142 - 0"
     102#endif
     103#endif
     104#endif
    90105
    91106/*
     
    143158        case TFN_TCP_CLS_CEP:
    144159                if (nblk_error < 0)
    145                         syslog(LOG_NOTICE, "[TDC:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
     160                        syslog(LOG_NOTICE, "[TDCn:%02u CBN] close error: %s", cepid, itron_strerror(nblk_error));
    146161                syscall(sig_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
    147162                break;
     
    162177 */
    163178
    164 static void
     179static ER
    165180send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
    166181{
     
    183198
    184199        if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
    185                 syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(error));
    186                 return;
     200                syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
     201                return error;
    187202                }
    188203
     
    191206
    192207        if (nblk_error != E_OK)
    193                 syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(nblk_error));
     208                syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(nblk_error));
    194209        else {
    195210                get_tim(&time);
    196                 syslog(LOG_NOTICE, "[TDC:%02d SND] connecting: %6ld, to:   %s.%d",
     211                syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
    197212                                   cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);
    198213
     
    202217                        while (soff < SND_BUF_SIZE) {
    203218                                if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
    204                                         syslog(LOG_NOTICE, "[TDC:%02d SND] send error: %s",
     219                                        syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s",
    205220                                                           cepid, itron_strerror(slen));
    206221                                        goto cls_ret;
     
    211226
    212227#ifdef SHOW_RCV_RANGE
    213                                 syslog(LOG_NOTICE, "[TDC:%02d SND] snd: %2d, len: %4d, off: %4d",
     228                                syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
    214229                                                   cepid, scount, (uint16_t)slen, soff);
    215230#endif  /* of #ifdef SHOW_RCV_RANGE */
    216231
    217                                 syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
     232                                syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
    218233                                }
    219234                        }
     
    221236        cls_ret:
    222237                get_tim(&time);
    223                 syslog(LOG_NOTICE, "[TDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
     238                syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
    224239                                   cepid, time / SYSTIM_HZ, scount, total);
    225240
    226241                if ((error = tcp_sht_cep(cepid)) < 0)
    227                         syslog(LOG_NOTICE, "[TDC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
     242                        syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
    228243
    229244                if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
    230                         syslog(LOG_NOTICE, "[TDC:%02d SND] close error: %s", cepid, itron_strerror(error));
     245                        syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
    231246
    232247                /* 開放が完了するまで待つ。*/
    233248                syscall(wai_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
    234249                }
     250
     251        return E_OK;
    235252        }
    236253
     
    241258 */
    242259
    243 static void
     260static ER
    244261send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
    245262{
     
    266283
    267284        if ((error = TCP_CON_CEP(cepid, &src, &dst, 60 * 1000)) != E_OK) {
    268                 syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(error));
    269                 return;
     285                syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
     286                return error;
    270287                }
    271288
    272289        get_tim(&time);
    273         syslog(LOG_NOTICE, "[TDC:%02d SND] connecting: %6ld, to:   %s.%d",
     290        syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
    274291                           cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    275292
     
    279296                while (soff < SND_BUF_SIZE) {
    280297                        if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
    281                                 syslog(LOG_NOTICE, "[TDC:%02d SND] send error: %s", cepid, itron_strerror(slen));
     298                                syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s", cepid, itron_strerror(slen));
    282299                                goto cls_ret;
    283300                                }
     
    287304
    288305#ifdef SHOW_RCV_RANGE
    289                         syslog(LOG_NOTICE, "[TDC:%02d SND] snd: %3d, len: %4d, off: %4d",
     306                        syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
    290307                                           cepid, scount, (uint16_t)slen, soff);
    291308#endif  /* of #ifdef SHOW_RCV_RANGE */
    292309
    293                         syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
     310                        syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
    294311                        }
    295312                }
     
    297314cls_ret:
    298315        get_tim(&time);
    299         syslog(LOG_NOTICE, "[TDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
     316        syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
    300317                           cepid, time / SYSTIM_HZ, scount, total);
    301318
    302319        if ((error = tcp_sht_cep(cepid)) < 0)
    303                 syslog(LOG_NOTICE, "[TDC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
     320                syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
    304321
    305322        if ((error = tcp_cls_cep(cepid, TMO_FEVR)) < 0)
    306                 syslog(LOG_NOTICE, "[TDC:%02d SND] close error: %s", cepid, itron_strerror(error));
     323                syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
     324
     325        return E_OK;
    307326        }
    308327
    309328#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
     329
     330/*
     331 *  getcomd -- コマンドを得る。
     332 */
     333
     334#ifdef TCP_DISCARD_CLI_AUTO_RUN_STR
     335
     336static char *
     337getcomd (ID cepid, bool_t retry)
     338{
     339        ER              error;
     340        char            *line = NULL;
     341        static char     auto_run_str[] = TCP_DISCARD_CLI_AUTO_RUN_STR;
     342        static int_t    count = 0;
     343
     344        if (retry || (count == 0)) {
     345                line = auto_run_str;
     346                dly_tsk(3 * 1000);
     347                }
     348        else {
     349                while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
     350                        syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
     351                        dly_tsk(SLP_ITV);
     352                        }
     353                }
     354
     355        count ++;
     356        return line;
     357        }
     358
     359#else   /* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
     360
     361static char *
     362getcomd (ID cepid, bool_t retry)
     363{
     364        ER      error;
     365        char    *line = NULL;
     366
     367        while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
     368                syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
     369                dly_tsk(SLP_ITV);
     370                }
     371        return line;
     372        }
     373
     374#endif  /* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
    310375
    311376void
    312377tcp_discard_cli_task (intptr_t exinf)
    313378{
     379        ID              tskid, cepid;
    314380        T_IN_ADDR       addr;
    315         ID              tskid, cepid;
    316         int_t           rep;
    317         uint32_t        count;
     381        ER              error;
     382        uint8_t         *line;
     383        int_t           rep, count;
     384        bool_t          retry = false;
    318385        uint16_t        portno;
    319         uint8_t         *line;
     386        char            apip;
    320387
    321388#ifdef USE_TCP_EXTENTIONS
    322389
    323         ER              error;
    324390        T_TCP_CCEP      ccep;
    325391
    326392#endif  /* of #ifdef USE_TCP_EXTENTIONS */
    327393
     394#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
     395        dly_tsk(START_DLY);
     396#endif
    328397        get_tid(&tskid);
    329         syslog(LOG_NOTICE, "[TCP DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
     398
     399#if defined(SUPPORT_INET6)
     400        apip = API_PROTO_IPV6;
     401#if defined(SUPPORT_INET4)
     402        syslog(LOG_NOTICE, "[TCPn DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
     403#else
     404        syslog(LOG_NOTICE, "[TCP6 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
     405#endif
     406#else
     407        apip = API_PROTO_IPV4;
     408        syslog(LOG_NOTICE, "[TCP4 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
     409#endif
     410
    330411        while (true) {
    331                 if (rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line) == E_OK) {
    332                         line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));       /* IP Address */
    333 
    334                         if ('0' <= *line && *line <= '9') {                             /* Port No */
    335                                 line = get_int(&rep, line);
    336                                 portno = (uint16_t)rep;
     412                line = skip_blanks(getcomd((ID)exinf, retry));
     413
     414                if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
     415                        syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], unknown host.",
     416                               (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
     417                        dly_tsk(SLP_ITV);
     418                        syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", (ID)exinf);
     419                        retry = true;
     420                        continue;
     421                        }
     422                else
     423                        retry = false;
     424
     425                line = skip_blanks(line);
     426                if ('0' <= *line && *line <= '9') {     /* Port No */
     427                        line = get_int(&rep, line);
     428                        portno = (uint16_t)rep;
     429                        }
     430                else {
     431                        line ++;
     432                        portno = DISCARD_SRV_PORTNO;
     433                        }
     434
     435                line = skip_blanks(line);
     436                if ('0' <= *line && *line <= '9')       /* Repeat */
     437                        line = get_int(&rep, line);
     438                else
     439                        rep = 1;
     440
     441#ifdef USE_TCP_EXTENTIONS
     442
     443                ccep.cepatr = 0;
     444                ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE;
     445                ccep.rbufsz = 0;
     446                ccep.rbuf = NADR;
     447
     448#ifdef TCP_CFG_SWBUF_CSAVE
     449                ccep.sbuf = NADR;
     450#else
     451                ccep.sbuf = tcp_discard_cli_swbuf;
     452#endif
     453#ifdef USE_TCP_NON_BLOCKING
     454                ccep.callback = (FP)callback_nblk_tcp_discard_cli;
     455#else
     456                ccep.callback = NULL;
     457#endif
     458
     459                if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
     460                        syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP create error: %s", cepid, itron_strerror(error));
     461                        continue;
     462                        }
     463
     464#else   /* of #ifdef USE_TCP_EXTENTIONS */
     465
     466                cepid = (ID)exinf;
     467
     468#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     469
     470                tcp_discard_cli_valid = true;
     471                count = 0;
     472                while (rep == 0 || count < rep) {
     473                        if (!tcp_discard_cli_valid) {
     474                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] canceled.", cepid);
     475                                break;
     476                                }
     477
     478                        count ++;
     479                        if (rep == 0) {
     480                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d", cepid, count);
     481                                error = send_tcp_discard(cepid, &addr, portno);
     482                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d", cepid, count);
    337483                                }
    338484                        else {
    339                                 line ++;
    340                                 portno = DISCARD_SRV_PORTNO;
    341                                 }
    342 
    343                         line = skip_blanks(line);
    344                         if ('0' <= *line && *line <= '9')                               /* Repeat */
    345                                 line = get_int(&rep, line);
    346                         else
    347                                 rep = 1;
     485                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d/%d", cepid, count, rep);
     486                                error = send_tcp_discard(cepid, &addr, portno);
     487                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d/%d", cepid, count, rep);
     488                                }
     489
     490                        if (error != E_OK) {
     491                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], error: %s",
     492                                                   cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
     493                                tslp_tsk(SLP_ITV);
     494                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", cepid);
     495                                }
     496
     497#if defined(SND_ITV)
     498#if SND_ITV > 0
     499                        if (count < rep) {
     500                                uint_t itv;
     501                               
     502                                itv = SND_ITV;
     503                                syslog(LOG_NOTICE, "[TDCn:%02u TSK] interval: %d[s].", cepid, itv / SYSTIM_HZ);
     504                                syscall(dly_tsk(SND_ITV));
     505                                }
     506#endif
     507#endif
     508                        }
    348509
    349510#ifdef USE_TCP_EXTENTIONS
    350511
    351                         ccep.cepatr = 0;
    352                         ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE;
    353                         ccep.rbufsz = 0;
    354                         ccep.rbuf = NADR;
    355 
    356 #ifdef TCP_CFG_SWBUF_CSAVE
    357                         ccep.sbuf = NADR;
    358 #else
    359                         ccep.sbuf = tcp_discard_cli_swbuf;
    360 #endif
    361 #ifdef USE_TCP_NON_BLOCKING
    362                         ccep.callback = (FP)callback_nblk_tcp_discard_cli;
    363 #else
    364                         ccep.callback = NULL;
    365 #endif
    366 
    367                         if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) {
    368                                 syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
    369                                 continue;
    370                                 }
    371 
    372 #else   /* of #ifdef USE_TCP_EXTENTIONS */
    373 
    374                         cepid = (ID)exinf;
     512                if ((error = FREE_TCP_CEP(cepid)) != E_OK)
     513                        syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP delete error: %s", cepid, itron_strerror(error));
    375514
    376515#endif  /* of #ifdef USE_TCP_EXTENTIONS */
    377516
    378                         tcp_discard_cli_valid = true;
    379                         for (count = rep; count -- > 0; ) {
    380                                 if (!tcp_discard_cli_valid) {
    381                                         syslog(LOG_NOTICE, "[TDC:%02d TSK] canceled.", (ID)exinf);
    382                                         break;
    383                                         }
    384                                 syslog(LOG_NOTICE, "[TDC:%02d TSK] start:              repeat: %d/%d",
    385                                                    (ID)exinf, rep - count, rep);
    386                                 send_tcp_discard(cepid, &addr, portno);
    387                                 syslog(LOG_NOTICE, "[TDC:%02d TSK] finished:           repeat: %d/%d",
    388                                                    (ID)exinf, rep - count, rep);
    389                                 syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
    390                                 }
    391 
    392 #ifdef USE_TCP_EXTENTIONS
    393 
    394                         if ((error = free_tcp_cep(cepid)) != E_OK)
    395                                 syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
    396 
    397 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    398 
    399                         }
    400517                }
    401518        }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.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 *
     
    5858#endif  /* of #ifdef TARGET_KERNEL_JSP */
    5959
    60 #include <tinet_defs.h>
    61 #include <tinet_config.h>
    62 
    63 #include <net/if.h>
    64 #include <net/if_ppp.h>
    65 #include <net/if_loop.h>
    66 #include <net/ethernet.h>
    67 #include <net/net.h>
    68 #include <net/net_timer.h>
    69 
    7060#include <netinet/in.h>
    7161#include <netinet/in_itron.h>
    72 #include <netinet/ip.h>
    73 #include <netinet/ip6.h>
    74 #include <netinet/tcp.h>
    7562
    7663#include <netapp/netapp.h>
    7764#include <netapp/netapp_var.h>
    78 #include <netapp/discard.h>
     65#include <netapp/tcp_discard_srv.h>
    7966
    8067#ifdef USE_TCP_DISCARD_SRV
     
    121108
    122109        if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    123                 syslog(LOG_NOTICE, "[TDS:%02d ACP] accept error: %s", cepid, itron_strerror(error));
     110                syslog(LOG_NOTICE, "[TDSn:%02u ACP] accept error: %s", cepid, itron_strerror(error));
    124111                return error;
    125112                }
    126113
    127114#ifdef USE_TCP_EXTENTIONS
    128         if ((error = free_tcp_rep(repid, true)) != E_OK) {
    129                 syslog(LOG_NOTICE, "[TDS:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
     115        if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
     116                syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
    130117                return error;
    131118                }
     
    134121        count = total = 0;
    135122        get_tim(&time);
    136         syslog(LOG_NOTICE, "[TDS:%02d RCV] connected:  %6ld, from: %s.%d",
     123        syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
    137124                           cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    138125        while ((rlen = tcp_rcv_buf(cepid, (void*)&buf, TMO_FEVR)) > 0) {
     
    140127
    141128#ifdef SHOW_RCV_RANGE
    142                 syslog(LOG_NOTICE, "[TDS:%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",
     129                syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
    143130                       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
    144131#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    150137
    151138                if ((error = tcp_rel_buf(cepid, rlen)) != E_OK) {
    152                         syslog(LOG_NOTICE, "[TDS:%02d RCV] rel buf error: %s",
     139                        syslog(LOG_NOTICE, "[TDSn:%02u RCV] rel buf error: %s",
    153140                                            cepid, itron_strerror(error));
    154141                        rlen = 0;
     
    159146
    160147        if (rlen != 0)
    161                 syslog(LOG_NOTICE, "[TDS:%02d RCV] recv buf error: %s", cepid, itron_strerror(rlen));
     148                syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv buf error: %s", cepid, itron_strerror(rlen));
    162149
    163150        if ((error = tcp_sht_cep(cepid)) != E_OK)
    164                 syslog(LOG_NOTICE, "[TDS:%02d RCV] shutdown error: %s", cepid, itron_strerror(error));
     151                syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
    165152
    166153        if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
    167                 syslog(LOG_NOTICE, "[TDS:%02d RCV] close error: %s", cepid, itron_strerror(error));
     154                syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
    168155
    169156        get_tim(&time);
    170         syslog(LOG_NOTICE, "[TDS:%02d RCV] finished:   %6ld,            rcv: %4d, len: %ld",
     157        syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
    171158                           cepid, time / SYSTIM_HZ, count, total);
    172159
     
    190177
    191178        if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    192                 syslog(LOG_NOTICE, "[TDS:%02d RCV] accept error: %s", cepid, itron_strerror(error));
     179                syslog(LOG_NOTICE, "[TDSn:%02u RCV] accept error: %s", cepid, itron_strerror(error));
    193180                return error;
    194181                }
    195182
    196183#ifdef USE_TCP_EXTENTIONS
    197         if ((error = free_tcp_rep(repid, true)) != E_OK) {
    198                 syslog(LOG_NOTICE, "[TDS:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
     184        if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
     185                syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
    199186                return error;
    200187                }
     
    203190        count = total = 0;
    204191        get_tim(&time);
    205         syslog(LOG_NOTICE, "[TDS:%02d RCV] connected:  %6ld, from: %s.%d",
     192        syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
    206193                           cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    207194        while ((rlen = tcp_rcv_dat(cepid, buf, BUF_SIZE - 1, TMO_FEVR)) > 0) {
     
    209196
    210197#ifdef SHOW_RCV_RANGE
    211                 syslog(LOG_NOTICE, "[TDS:%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",
     198                syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
    212199                       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
    213200#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    216203                }
    217204        if (rlen != 0)
    218                 syslog(LOG_NOTICE, "[TDS:%02d RCV] recv error: %s", cepid, itron_strerror(rlen));
     205                syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv error: %s", cepid, itron_strerror(rlen));
    219206
    220207        if ((error = tcp_sht_cep(cepid)) != E_OK)
    221                 syslog(LOG_NOTICE, "[TDS:%02d RCV] shutdown error: %s", cepid, itron_strerror(error));
     208                syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
    222209
    223210        if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
    224                 syslog(LOG_NOTICE, "[TDS:%02d RCV] close error: %s", cepid, itron_strerror(error));
     211                syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
    225212
    226213        get_tim(&time);
    227         syslog(LOG_NOTICE, "[TDS:%02d RCV] finished:   %6ld,            rcv: %4d, len: %ld",
     214        syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
    228215                           cepid, time / SYSTIM_HZ, count, total);
    229216
     
    243230{
    244231        ID              tskid;
    245         T_TCP_CREP      crep;
     232        T_TCPN_CREP     crep;
    246233
    247234        get_tid(&tskid);
     
    250237        crep.myaddr.portno = UINT_C(9);
    251238
     239#if defined(SUPPORT_INET6)
     240
     241        memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     242
     243#else   /* #if defined(SUPPORT_INET6) */
     244
    252245#if defined(SUPPORT_INET4)
    253246        crep.myaddr.ipaddr = IPV4_ADDRANY;
    254247#endif
    255248
    256 #if defined(SUPPORT_INET6)
    257         memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
    258 #endif
    259 
    260         return alloc_tcp_rep(repid, tskid, &crep);
     249#endif  /* #if defined(SUPPORT_INET6) */
     250
     251        return ALLOC_TCP_REP(repid, tskid, &crep);
    261252        }
    262253
     
    285276#endif
    286277
    287         return alloc_tcp_cep(cepid, tskid, &ccep);
     278        return ALLOC_TCP_CEP(cepid, tskid, &ccep);
    288279        }
    289280
     
    299290
    300291        syscall(get_tid(&tskid));
    301         syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid);
     292
     293#if defined(SUPPORT_INET6)
     294#if defined(SUPPORT_INET4)
     295        syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d] started.", tskid);
     296#else
     297        syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d] started.", tskid);
     298#endif
     299#else
     300        syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d] started.", tskid);
     301#endif
     302
    302303        while (true) {
    303304
    304305                syscall(slp_tsk());
    305306                if ((error = get_tcp_cep (&cepid)) != E_OK) {
    306                         syslog(LOG_NOTICE, "[TDS:00 EXT] CEP create error: %s", itron_strerror(error));
     307                        syslog(LOG_NOTICE, "[TDSn:00 EXT] CEP create error: %s", itron_strerror(error));
    307308                        continue;
    308309                        }
     
    311312
    312313                        if ((error = get_tcp_rep (&repid)) != E_OK) {
    313                                 syslog(LOG_NOTICE, "[TDS:00 EXT] REP create error: %s", itron_strerror(error));
     314                                syslog(LOG_NOTICE, "[TDSn:00 EXT] REP create error: %s", itron_strerror(error));
    314315                                break;
    315316                                }
    316317                        else if ((error = tcp_discard_srv(cepid, repid)) != E_OK) {
    317                                 error = free_tcp_rep(repid, error != E_DLT);
     318                                error = FREE_TCP_REP(repid, error != E_DLT);
    318319                                break;
    319320                                }
    320321                        }
    321322
    322                 if ((error = free_tcp_cep(cepid)) != E_OK)
    323                         syslog(LOG_NOTICE, "[TDS:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
     323                if ((error = FREE_TCP_CEP(cepid)) != E_OK)
     324                        syslog(LOG_NOTICE, "[TDSn:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
    324325
    325326                }
     
    334335
    335336        get_tid(&tskid);
    336         syslog(LOG_NOTICE, "[TCP DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
     337
     338#if defined(SUPPORT_INET6)
     339#if defined(SUPPORT_INET4)
     340        syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
     341#else
     342        syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
     343#endif
     344#else
     345        syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
     346#endif
     347
    337348        while (true) {
    338349                while (tcp_discard_srv((ID)exinf, TCP_DISCARD_SRV_REPID) == E_OK)
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.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 *
     
    5050#include <t_syslog.h>
    5151#include "kernel_cfg.h"
     52#include "tinet_cfg.h"
    5253
    5354#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    5758#include <t_services.h>
    5859#include "kernel_id.h"
     60#include "tinet_id.h"
    5961
    6062#endif  /* of #ifdef TARGET_KERNEL_JSP */
    61 
    62 #include <tinet_defs.h>
    63 #include <tinet_config.h>
    64 
    65 #include <net/if.h>
    66 #include <net/if_ppp.h>
    67 #include <net/if_loop.h>
    68 #include <net/net.h>
    69 #include <net/ethernet.h>
    70 #include <net/net_var.h>
    71 #include <net/net_timer.h>
    7263
    7364#include <netinet/in.h>
    7465#include <netinet/in_itron.h>
    75 #include <netinet/ip.h>
    76 #include <netinet/ip6.h>
    77 #include <netinet/tcp.h>
    7866
    7967#include <netapp/netapp.h>
    8068#include <netapp/netapp_var.h>
    81 #include <netapp/echo.h>
     69#include <netapp/tcp_echo_cli.h>
    8270
    8371#ifdef USE_TCP_ECHO_CLI
     
    9684#endif  /* of #ifdef USE_TCP_EXTENTIONS */
    9785
    98 /* 表示 */
    99 
    100 //#define SHOW_RCV_RANGE
    101 
    102 /* タイムアウト */
    103 
    104 #define CON_TMO         TMO_FEVR
    105 //#define CON_TMO               (60*SYSTIM_HZ)
    106 //#define CLS_TMO               TMO_FEVR                                /* Close Wait は標準で 60秒 */
    107 #define CLS_TMO         (70*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*10)
    108 //#define RCV_TMO               TMO_FEVR
    109 #define RCV_TMO         (40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20)
    110 //#define SND_TMO               TMO_FEVR
    111 #define SND_TMO         (30*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*30)
    112 
    11386/* 送信間隔 */
    11487
    115 //#define SND_DLY                       ULONG_C(500)
    116 #define SND_ITV         (5*SYSTM_HZ)
     88#ifdef TOPPERS_S810_CLG3_85
     89
     90//#define SND_DLY               (500)
     91#define START_DLY       (10*SYSTIM_HZ)
     92#define SND_ITV         (5*SYSTIM_HZ)
     93#define SLP_ITV         (30*SYSTIM_HZ)
     94
     95#else   /* of #ifdef TOPPERS_S810_CLG3_85 */
     96
     97//#define SND_DLY               (500)
     98#define START_DLY       (10*SYSTIM_HZ)
     99#define SND_ITV         (5*SYSTIM_HZ)
    117100#define SLP_ITV         (60*SYSTIM_HZ)
    118101
     102#endif  /* of #ifdef TOPPERS_S810_CLG3_85 */
     103
    119104/* 自動実行 */
    120105
     106#if defined(TCP_ECHO_CLI_AUTO_RUN_STR)
     107#else
    121108#if 0
    122109#if defined(SUPPORT_INET6)
    123 #define AUTO_RUN_STR    "fe80::211:2fff:fe8a:e8c0 - 0"
    124 #else
    125 #define AUTO_RUN_STR    "172.25.193.140 - 0"
    126 #endif
    127 #endif
    128 
    129 /*
    130  *  バッファサイズの定義
    131  */
    132 
    133 #define NUM_ECHO                20
    134 #define NUM_REP_PAT             20
    135 #define PAT_BEGIN               ' '
    136 #define PAT_END                 '~'
    137 #define SND_BUF_SIZE            ((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)
    138 #define RCV_BUF_SIZE            (SND_BUF_SIZE*15/10)
     110#define TCP_ECHO_CLI_AUTO_RUN_STR       "fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
     111#else
     112#define TCP_ECHO_CLI_AUTO_RUN_STR       "172.25.129.140 - 0"
     113#endif
     114#endif
     115#endif
     116
     117#if defined(SUPPORT_INET6)
     118#if defined(SUPPORT_INET4)
     119#define API_PROTO               'n'
     120#else
     121#define API_PROTO               '6'
     122#endif
     123#else
     124#define API_PROTO               '4'
     125#endif
    139126
    140127/*
     
    142129 */
    143130
    144 bool_t tcp_echo_cli_valid;
     131bool_t  tcp_echo_cli_valid;
     132uint_t  tcp_echo_cli_scount;
    145133
    146134/* TCP 送受信ウィンドバッファ */
     
    154142#endif
    155143
    156 /*
    157  *  変数
    158  */
    159 
    160 static uint_t   scount;
    161 static uint_t   rcount;
    162 
    163144#ifdef USE_TCP_NON_BLOCKING
    164145
    165 static T_IPEP   nblk_src = {
    166                         IP_ADDRANY,
    167                         TCP_PORTANY,
    168                         };
    169 static T_IPEP   nblk_dst;
    170 static ER_UINT  nblk_error;
     146/*
     147 *  全域変数
     148 */
     149
     150ER_UINT tcp_echo_cli_nblk_error;
    171151
    172152/*
     
    179159        ER      error = E_OK;
    180160
    181         nblk_error = *(ER*)p_parblk;
     161        tcp_echo_cli_nblk_error = *(ER*)p_parblk;
    182162
    183163        switch (fncd) {
     
    188168
    189169        case TFN_TCP_RCV_BUF:
    190                 if (nblk_error < 0)
    191                         syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv buf error: %s", cepid, itron_strerror(nblk_error));
     170                if (tcp_echo_cli_nblk_error < 0)
     171                        syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
     172                                           API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
    192173                syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    193174                break;
    194175
    195176        case TFN_TCP_CLS_CEP:
    196                 if (nblk_error < 0)
    197                         syslog(LOG_NOTICE, "[TEC:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
     177                if (tcp_echo_cli_nblk_error < 0)
     178                        syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
     179                                           API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
    198180                syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    199181                break;
    200182
    201183        case TFN_TCP_RCV_DAT:
    202                 if (nblk_error < 0)
    203                         syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv dat error: %s", cepid, itron_strerror(nblk_error));
     184                if (tcp_echo_cli_nblk_error < 0)
     185                        syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
     186                                           API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
    204187                syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    205188                break;
    206189
    207190        case TFN_TCP_SND_OOB:
    208                 if (nblk_error > 0)
    209                         syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg: %4d", cepid, nblk_error);
     191                if (tcp_echo_cli_nblk_error > 0)
     192                        syslog(LOG_NOTICE, "[TEC%c:%02u CBN] snd urg: %4u",
     193                                           API_PROTO, cepid, tcp_echo_cli_nblk_error);
    210194                else
    211                         syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg error: %s", cepid, itron_strerror(nblk_error));
     195                        syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
     196                                           API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
    212197                break;
    213198
     
    222207        }
    223208
    224 /*
    225  *  send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。
    226  */
    227 
    228 static ER
    229 send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
    230 {
    231         static char smsg[SND_BUF_SIZE];
    232 
    233         ER_UINT         slen;
    234         ER              error;
    235         SYSTIM          time;
    236         uint32_t        total;
    237         uint16_t        soff, echo, rep;
    238         char            *p, pat;
    239 
    240 #ifdef SND_URG_DATA_SIZE
    241         int_t   urg = SND_URG_COUNT;
    242 #endif
    243 
    244         nblk_dst.ipaddr = *ipaddr;
    245         nblk_dst.portno = portno;
    246 
    247         p = smsg;
    248         for (rep = NUM_REP_PAT; rep -- > 0; )
    249                 for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
    250                         *p ++ = pat;
    251 
    252         if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
    253                 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));
    254                 return error;
    255                 }
    256 
    257         /* 接続が完了するまで待つ。*/
    258         syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    259 
    260         if (nblk_error != E_OK)
    261                 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(nblk_error));
    262         else {
    263                 get_tim(&time);
    264                 syslog(LOG_NOTICE, "[TEC:%02d SND] connecting: %6lu, to:   %s.%u",
    265                                    cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);
    266 
    267                 if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
    268                         syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));
    269                         goto cls_ret;
    270                         }
    271 
    272                 scount = total = 0;
    273                 for (echo = NUM_ECHO; echo -- > 0; ) {
    274                         soff = 0;
    275                         while (soff < SND_BUF_SIZE) {
    276                                 if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
    277                                         syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s",
    278                                                            cepid, itron_strerror(slen));
    279                                         goto cls_ret;
    280                                         }
    281                                 soff  += (uint16_t)slen;
    282                                 total +=     slen;
    283                                 scount ++;
    284 #ifdef SHOW_RCV_RANGE
    285                                 syslog(LOG_NOTICE, "[TEC:%02d SND] send cnt: %2d, len: %4d, off: %4d",
    286                                                    cepid, scount, (uint16_t)slen, soff);
    287 #endif  /* of #ifdef SHOW_RCV_RANGE */
    288 
    289 #ifdef SND_URG_DATA_SIZE
    290                                 if (urg) {
    291                                         if (urg == 1) {
    292                                                 if ((error = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, TMO_NBLK)) != E_WBLK)
    293                                                         syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",
    294                                                                            cepid, itron_strerror(error));
    295                                                 }
    296                                         urg --;
    297                                         }
    298 #endif  /* of #ifdef SND_URG_DATA_SIZE */
    299 
    300 #if SND_DLY > 0
    301                                 syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));
    302 #endif
    303                                 }
    304                         }
    305 
    306         cls_ret:
    307                 if ((error = tcp_sht_cep(cepid)) < 0)
    308                         syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
    309 
    310                 /* 受信が完了するまで待つ。*/
    311                 syscall(slp_tsk());
    312                 }
    313 
    314         return error;
    315         }
    316 
    317 /*
    318  *  TCP ECHO クライアント受信タスク
    319  */
    320 
    321 #ifdef USE_COPYSAVE_API
    322 
    323 void
    324 tcp_echo_cli_rcv_task (intptr_t exinf)
    325 {
    326         ID              tskid, cepid;
    327         ER              error;
    328         SYSTIM          time;
    329         uint32_t        total;
    330         uint16_t        roff, rlen;
    331         char            *rmsg, head, tail;
    332 
    333         get_tid(&tskid);
    334         syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK,CS) RCV:%d] started.", tskid);
    335         while (true) {
    336                 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
    337                         syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
    338                                            cepid, itron_strerror(error));
    339                         }
    340                 else {
    341                         roff = rcount = total = 0;
    342                         while (true) {
    343                                 if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {
    344                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s", cepid, itron_strerror(error));
    345                                         break;
    346                                         }
    347 
    348                                 /* 受信バッファの獲得が完了するまで待つ。*/
    349                                 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    350                                 if (nblk_error < 0)
    351                                         break;
    352 
    353                                 rlen = nblk_error;
    354                                 head = *rmsg;
    355                                 tail = *(rmsg + rlen - 1);
    356                                 if (rlen > 0) {
    357                                         roff  += rlen;
    358                                         total += rlen;
    359                                         rcount ++;
    360 #ifdef SHOW_RCV_RANGE
    361                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] "
    362                                                            "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",
    363                                                            cepid, rcount, rlen, roff, head, tail);
    364 #endif  /* of #ifdef SHOW_RCV_RANGE */
    365                                         }
    366                                 else
    367                                         break;
    368 
    369                                 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
    370                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s",
    371                                                            cepid, itron_strerror(error));
    372                                 }
    373 
    374                         if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
    375                                 syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));
    376 
    377                         /* 切断が完了するまで待つ。*/
    378                         syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    379 
    380                         get_tim(&time);
    381                         syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
    382                                            cepid, time / SYSTIM_HZ, scount, rcount, total);
    383                         }
    384 
    385                 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
    386                 }
    387         }
    388 
    389 #else   /* of #ifdef USE_COPYSAVE_API */
    390 
    391 void
    392 tcp_echo_cli_rcv_task (intptr_t exinf)
    393 {
    394         static char rmsg[RCV_BUF_SIZE];
    395 
    396         ID              tskid, cepid;
    397         ER              error;
    398         SYSTIM          time;
    399         uint32_t        total;
    400         uint16_t        roff, rlen;
    401         char            head, tail;
    402 
    403         get_tid(&tskid);
    404         syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK) RCV:%d] started.", tskid);
    405         while (true) {
    406                 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
    407                         syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
    408                                            cepid, itron_strerror(error));
    409                         }
    410                 else {
    411                         roff = rcount = total = 0;
    412                         while (true) {
    413                                 if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {
    414                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv error: %s", cepid, itron_strerror(error));
    415                                         break;
    416                                         }
    417 
    418                                 /* 受信が完了するまで待つ。*/
    419                                 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    420                                 if (nblk_error < 0)
    421                                         break;
    422 
    423                                 rlen = nblk_error;
    424                                 head = *rmsg;
    425                                 tail = *(rmsg + rlen - 1);
    426                                 rcount ++;
    427                                 if (rlen > 0) {
    428                                         roff  += rlen;
    429                                         total += rlen;
    430 #ifdef SHOW_RCV_RANGE
    431                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] "
    432                                                            "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",
    433                                                            cepid, rcount, rlen, roff, head, tail);
    434 #endif  /* of #ifdef SHOW_RCV_RANGE */
    435                                         }
    436                                 else
    437                                         break;
    438                                 }
    439 
    440                         if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
    441                                 syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));
    442 
    443                         /* 切断が完了するまで待つ。*/
    444                         syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
    445 
    446                         get_tim(&time);
    447                         syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
    448                                            cepid, time / SYSTIM_HZ, scount, rcount, total);
    449                         }
    450 
    451                 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
    452                 }
    453         }
    454 
    455 #endif  /* of #ifdef USE_COPYSAVE_API */
    456 
    457 #else   /* of #ifdef USE_TCP_NON_BLOCKING */
    458 
    459 /*
    460  *  send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。
    461  */
    462 
    463 static ER
    464 send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
    465 {
    466         static char smsg[SND_BUF_SIZE];
    467         static T_IPEP src = {
    468                 IP_ADDRANY,
    469                 TCP_PORTANY,
    470                 };
    471 
    472         T_IPEP          dst;
    473         ER_UINT         slen;
    474         ER              error;
    475         SYSTIM          time;
    476         uint32_t        total;
    477         uint16_t        soff, echo, rep;
    478         char            pat, *p;
    479 
    480 #ifdef SND_URG_DATA_SIZE
    481         int_t   urg = SND_URG_COUNT;
    482 #endif
    483 
    484         dst.ipaddr = *ipaddr;
    485         dst.portno = portno;
    486 
    487         p = smsg;
    488         for (rep = NUM_REP_PAT; rep -- > 0; )
    489                 for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
    490                         *p ++ = pat;
    491 
    492         if ((error = TCP_CON_CEP(cepid, &src, &dst, CON_TMO)) != E_OK) {
    493                 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));
    494                 return error;
    495                 }
    496 
    497         get_tim(&time);
    498         syslog(LOG_NOTICE, "[TEC:%02u SND] connecting: %6lu, to:   %s.%u",
    499                            cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    500 
    501         if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
    502                 syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));
    503                 goto cls_ret;
    504                 }
    505 
    506         scount = total = 0;
    507         for (echo = NUM_ECHO; echo -- > 0; ) {
    508                 soff = 0;
    509                 while (soff < SND_BUF_SIZE) {
    510                         if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
    511                                 syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s", cepid, itron_strerror(slen));
    512                                 goto cls_ret;
    513                                 }
    514                         soff  += (uint16_t)slen;
    515                         total +=     slen;
    516                         scount ++;
    517 #ifdef SHOW_RCV_RANGE
    518                         syslog(LOG_NOTICE, "[TEC:%02d SND] send count: %3d, len: %4d, offset: %4d",
    519                                            cepid, scount, (uint16_t)slen, soff);
    520 #endif  /* of #ifdef SHOW_RCV_RANGE */
    521 
    522 #ifdef SND_URG_DATA_SIZE
    523                         if (urg > 0) {
    524                                 if (urg == 1) {
    525                                         if ((slen = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, SND_TMO)) >= 0)
    526                                                 syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg: %4d",
    527                                                                    cepid, (uint16_6)slen);
    528                                         else
    529                                                 syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",
    530                                                                    cepid, itron_strerror(slen));
    531                                         }
    532                                 urg --;
    533                                 }
    534 #endif  /* of #ifdef SND_URG_DATA_SIZE */
    535 
    536 #if SND_DLY > 0
    537                         syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));
    538 #endif
    539                         }
    540                 }
    541 
    542 cls_ret:
    543         if ((error = tcp_sht_cep(cepid)) < 0)
    544                 syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
    545 
    546         /* 受信が完了するまで待つ。*/
    547         syscall(slp_tsk());
    548 
    549         return error;
    550         }
    551 
    552 /*
    553  *  TCP ECHO クライアント受信タスク
    554  */
    555 
    556 #ifdef USE_COPYSAVE_API
    557 
    558 void
    559 tcp_echo_cli_rcv_task (intptr_t exinf)
    560 {
    561         ID              tskid, cepid;
    562         ER_UINT         rlen;
    563         ER              error;
    564         SYSTIM          time;
    565         uint32_t        total;
    566         uint16_t        roff;
    567         char            *rmsg;
    568 
    569         get_tid(&tskid);
    570         syslog(LOG_NOTICE, "[TCP ECHO CLI (CS) RCV:%d] started.", tskid);
    571         while (true) {
    572                 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
    573                         syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
    574                                            cepid, itron_strerror(error));
    575                         }
    576                 else {
    577                         roff = rcount = total = 0;
    578                         while (true) {
    579                                 if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, RCV_TMO)) < 0) {
    580                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s",
    581                                                            cepid, itron_strerror(rlen));
    582                                         break;
    583                                         }
    584                                 else if (rlen > 0) {
    585                                         roff  += (uint16_t)rlen;
    586                                         total +=     rlen;
    587                                         rcount ++;
    588 #ifdef SHOW_RCV_RANGE
    589                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",
    590                                                            cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
    591 #endif  /* of #ifdef SHOW_RCV_RANGE */
    592                                         }
    593                                 else
    594                                         break;
    595                                 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
    596                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s", cepid, itron_strerror(error));
    597                                 }
    598 
    599                         if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)
    600                                 syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));
    601 
    602                         get_tim(&time);
    603                         syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
    604                                            cepid, time / SYSTIM_HZ, scount, rcount, total);
    605                         }
    606 
    607                 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
    608                 }
    609         }
    610 
    611 #else   /* of #ifdef USE_COPYSAVE_API */
    612 
    613 void
    614 tcp_echo_cli_rcv_task (intptr_t exinf)
    615 {
    616         static char rmsg[RCV_BUF_SIZE];
    617 
    618         ID              tskid, cepid;
    619         ER_UINT         rlen;
    620         ER              error;
    621         SYSTIM          time;
    622         uint32_t        total;
    623         uint16_t        roff;
    624 
    625         get_tid(&tskid);
    626         syslog(LOG_NOTICE, "[TCP ECHO CLI RCV:%d] started.", tskid);
    627         while (true) {
    628                 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
    629                         syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
    630                                            cepid, itron_strerror(error));
    631                         }
    632                 else {
    633                         roff = rcount = total = 0;
    634                         while (true) {
    635                                 if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), RCV_TMO)) < 0) {
    636                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv dat error: %s", cepid, itron_strerror(rlen));
    637                                         tcp_can_cep(cepid, TFN_TCP_ALL);
    638                                         break;
    639                                         }
    640                                 else if (rlen > 0) {
    641                                         roff  += (uint16_t)rlen;
    642                                         total +=     rlen;
    643                                         rcount ++;
    644 #ifdef SHOW_RCV_RANGE
    645                                         syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",
    646                                                            cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
    647 #endif  /* of #ifdef SHOW_RCV_RANGE */
    648                                         }
    649                                 else
    650                                         break;
    651                                 }
    652 
    653                         if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)
    654                                 syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));
    655 
    656                         get_tim(&time);
    657                         syslog(LOG_NOTICE, "[TEC:%02u RCV] received:   %6lu, snd: %4u, rcv: %4u, len: %u",
    658                                            cepid, time / SYSTIM_HZ, scount, rcount, total);
    659                         }
    660 
    661                 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
    662                 }
    663         }
    664 
    665 #endif  /* of #ifdef USE_COPYSAVE_API */
    666 
    667209#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    668210
     
    671213 */
    672214
    673 #ifdef AUTO_RUN_STR
     215#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
    674216
    675217static char *
    676 getcomd (ID cepid)
     218getcomd (ID cepid, bool_t retry, char *apip)
    677219{
    678220        ER              error;
    679221        char            *line = NULL;
    680         static char     auto_run_str[] = AUTO_RUN_STR;
     222        static char     auto_run_str[] = TCP_ECHO_CLI_AUTO_RUN_STR;
    681223        static int_t    count = 0;
    682224
    683         if (count == 0) {
     225        if (retry || (count == 0)) {
    684226                line = auto_run_str;
    685227                dly_tsk(3 * 1000);
     
    687229        else {
    688230                while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
    689                         syslog(LOG_NOTICE, "[TEC:%02d TSK] error: %s", cepid, itron_strerror(error));
     231                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
    690232                        dly_tsk(SLP_ITV);
    691233                        }
     
    696238        }
    697239
    698 #else   /* of #ifdef AUTO_RUN_STR */
     240#else   /* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
    699241
    700242static char *
    701 getcomd (ID cepid)
     243getcomd (ID cepid, bool_t retry, char *apip)
    702244{
    703245        ER      error;
     
    705247
    706248        while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
    707                 syslog(LOG_NOTICE, "[TEC:%02d TSK] error: %s", cepid, itron_strerror(error));
     249                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
    708250                dly_tsk(SLP_ITV);
    709251                }
     252
     253#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
     254
     255        if (*line == '6') {
     256                line ++;
     257                *apip = API_PROTO_IPV6;
     258                }
     259        else if (*line == '4') {
     260                line ++;
     261                *apip = API_PROTO_IPV4;
     262                }
     263        else {
     264                *apip= DEFAULT_API_PROTO;
     265                if (*line && *line != ' ')
     266                        line ++;
     267                }
     268
     269#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
     270
     271        *apip= DEFAULT_API_PROTO;
     272        if (*line && *line != ' ')
     273                line ++;
     274
     275#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
     276
    710277        return line;
    711278        }
    712279
    713 #endif  /* of #ifdef AUTO_RUN_STR */
     280#endif  /* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
    714281
    715282/*
    716283 *  TCP ECHO クライアント送信タスク
    717284 */
     285
     286/*
     287 *  IP アドレスの指定
     288 */
     289
     290#define ADDR_IPVn       'n'
     291#define ADDR_IPV6       '6'
     292#define ADDR_IPV4       '4'
    718293
    719294void
     
    723298        ER              error;
    724299        T_IN_ADDR       addr;
     300        char            *line;
     301        int_t           rep, count;
     302        bool_t          retry = false;
    725303        uint16_t        portno;
    726         int_t           rep, count;
    727         char            *line;
     304        char            apip;
    728305
    729306#ifdef USE_TCP_EXTENTIONS
     
    733310#endif  /* of #ifdef USE_TCP_EXTENTIONS */
    734311
     312#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
     313        dly_tsk(START_DLY);
     314#endif
    735315        get_tid(&tskid);
    736         syslog(LOG_NOTICE, "[TCP ECHO CLI SND:%d,%d] started.", tskid, (ID)exinf);
     316        syslog(LOG_NOTICE, "[TCP%c ECHO CLI SND:%d,%d] started.", DEFAULT_API_PROTO, tskid, (ID)exinf);
    737317        while (true) {
    738                 line = getcomd((ID)exinf);
    739                 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));       /* IP Address */
    740 
    741                 if ('0' <= *line && *line <= '9') {                             /* Port No */
     318                line = skip_blanks(getcomd((ID)exinf, retry, &apip));
     319
     320#if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR)
     321
     322                if (apip == API_PROTO_IPV4) {
     323                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
     324                        retry = true;
     325                        continue;
     326                        }
     327
     328#endif  /* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR) */
     329
     330                if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
     331                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], unknown host.",
     332                               API_PROTO, (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
     333                        dly_tsk(SLP_ITV);
     334                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", API_PROTO, (ID)exinf);
     335                        retry = true;
     336                        continue;
     337                        }
     338                else
     339                        retry = false;
     340
     341#if defined(SUPPORT_INET6)
     342
     343#if defined(USE_TCP4_ECHO_CLI)
     344
     345#else   /* of #if defined(USE_TCP4_ECHO_CLI) */
     346
     347                if (in6_is_addr_ipv4mapped(&addr))
     348                        apip = API_PROTO_IPV4;
     349                else
     350                        apip = API_PROTO_IPV6;
     351
     352#endif  /* of #if defined(USE_TCP4_ECHO_CLI) */
     353
     354#else   /* of #if defined(SUPPORT_INET6) */
     355
     356                if (apip == API_PROTO_IPV6) {
     357                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
     358                        retry = true;
     359                        continue;
     360                        }
     361
     362#endif  /* of #if defined(SUPPORT_INET6) */
     363
     364                line = skip_blanks(line);
     365                if ('0' <= *line && *line <= '9') {     /* Port No */
    742366                        line = get_int(&rep, line);
    743367                        portno = (uint16_t)rep;
     
    749373
    750374                line = skip_blanks(line);
    751                 if ('0' <= *line && *line <= '9')                               /* Repeat */
     375                if ('0' <= *line && *line <= '9')       /* Repeat */
    752376                        line = get_int(&rep, line);
    753                 else
     377                else {
     378                        line ++;
    754379                        rep = 1;
     380                        }
    755381
    756382#ifdef USE_TCP_EXTENTIONS
     
    776402#endif
    777403
    778                 if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) {
    779                         syslog(LOG_NOTICE, "[TEC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
     404#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
     405
     406                if (apip == API_PROTO_IPV6) {
     407                        if ((error = alloc_tcp6_cep(&cepid, tskid, &ccep)) != E_OK) {
     408                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
     409                                continue;
     410                                }
     411                        }
     412                else {
     413                        if ((error = alloc_tcp4_cep(&cepid, tskid, &ccep)) != E_OK) {
     414                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
     415                                continue;
     416                                }
     417                        }
     418
     419#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
     420
     421                if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
     422                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
    780423                        continue;
    781424                        }
    782425
     426#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
     427
    783428#else   /* of #ifdef USE_TCP_EXTENTIONS */
    784429
     430#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
     431
     432                if (apip == API_PROTO_IPV6)
     433                        cepid = (ID)exinf;
     434                else
     435                        cepid = TCP4_ECHO_CLI_CEPID;
     436
     437#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
     438
    785439                cepid = (ID)exinf;
     440
     441#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
    786442
    787443#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     
    791447                while (rep == 0 || count < rep) {
    792448                        if (!tcp_echo_cli_valid) {
    793                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] canceled.", cepid);
     449                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] canceled.", apip, cepid);
    794450                                break;
    795451                                }
     
    797453                        count ++;
    798454                        if (rep == 0) {
    799                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] start:              repeat: %d", cepid, count);
    800                                 error = send_tcp_echo(cepid, &addr, portno);
    801                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] finished:           repeat: %d", cepid, count);
     455                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d", apip, cepid, count);
     456                                error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
     457                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d", apip, cepid, count);
    802458                                }
    803459                        else {
    804                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] start:              repeat: %d/%d", cepid, count, rep);
    805                                 error = send_tcp_echo(cepid, &addr, portno);
    806                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] finished:           repeat: %d/%d", cepid, count, rep);
     460                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d/%d", apip, cepid, count, rep);
     461                                error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
     462                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d/%d", apip, cepid, count, rep);
    807463                                }
    808464
    809465                        if (error != E_OK) {
    810                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] sleep %d[ms], error: %s",
    811                                                    cepid, SLP_ITV, itron_strerror(error));
     466                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], error: %s",
     467                                                   apip, cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
    812468                                tslp_tsk(SLP_ITV);
    813                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] resume.", cepid);
     469                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", apip, cepid);
    814470                                }
    815471
    816472#if defined(SND_ITV)
    817473#if SND_ITV > 0
    818                         if (count > 0) {
     474                        if (count < rep) {
    819475                                uint_t itv;
    820476                               
    821477                                itv = SND_ITV;
    822                                 syslog(LOG_NOTICE, "[TEC:%02d TSK] interval: %d[ms].", cepid, itv);
     478                                syslog(LOG_NOTICE, "[TEC%c:%02u TSK] interval: %d[s].", apip, cepid, itv / SYSTIM_HZ);
    823479                                syscall(dly_tsk(SND_ITV));
    824480                                }
     
    829485#ifdef USE_TCP_EXTENTIONS
    830486
    831                 if ((error = free_tcp_cep(cepid)) != E_OK)
    832                         syslog(LOG_NOTICE, "[TEC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
     487                if ((error = FREE_TCP_CEP(cepid)) != E_OK)
     488                        syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
    833489
    834490#endif  /* of #ifdef USE_TCP_EXTENTIONS */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.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 *
     
    6262#endif  /* of #ifdef TARGET_KERNEL_JSP */
    6363
    64 #include <tinet_defs.h>
    65 #include <tinet_config.h>
    66 
    67 #include <net/if.h>
    68 #include <net/if_ppp.h>
    69 #include <net/if_loop.h>
    70 #include <net/ethernet.h>
    71 #include <net/net.h>
    72 #include <net/net_timer.h>
    73 
    7464#include <netinet/in.h>
    7565#include <netinet/in_itron.h>
    76 #include <netinet/ip.h>
    77 #include <netinet/ip6.h>
    78 #include <netinet/tcp.h>
    7966
    8067#include <netapp/netapp.h>
    8168#include <netapp/netapp_var.h>
    82 #include <netapp/echo.h>
     69#include <netapp/tcp_echo_srv1.h>
     70#include <netapp/tcp_echo_srv1_var.h>
     71
     72#if defined(_NET_CFG_BYTE_ORDER)
     73#error "net/net.h included."
     74#endif
    8375
    8476#ifdef USE_TCP_ECHO_SRV1
     
    10092 */
    10193
     94#ifdef TOPPERS_S810_CLG3_85
     95
     96#define CLS_TMO         TMO_FEVR                /* Close Wait は標準で 60秒 */
     97//#define RCV_TMO               TMO_FEVR
     98#define RCV_TMO         (30*SYSTIM_HZ)
     99//#define SND_TMO               TMO_FEVR
     100#define SND_TMO         (30*SYSTIM_HZ)
     101
     102#else   /* of #ifdef TOPPERS_S810_CLG3_85 */
     103
    102104//#define CLS_TMO               TMO_FEVR        /* Close Wait は標準で 60秒 */
    103 #define CLS_TMO         (70*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*10)
     105#define CLS_TMO         (70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
    104106//#define RCV_TMO               TMO_FEVR
    105 #define RCV_TMO         (30*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*30)
     107#define RCV_TMO         (30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
    106108//#define SND_TMO               TMO_FEVR
    107 #define SND_TMO         (40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20)
     109#define SND_TMO         (40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
     110
     111#endif  /* of #ifdef TOPPERS_S810_CLG3_85 */
    108112
    109113/*
     
    121125#endif
    122126
     127#ifndef USE_TCP_NON_BLOCKING
     128
    123129/*
    124130 *  変数
    125131 */
    126132
    127 /*
    128  *  注意:
    129  *
    130  *    BUF_SIZE は TCP の
    131  *    送信ウインドウバッファサイズ + 受信ウインドウバッファサイズの
    132  *    3/2 倍以上の大きさがなければ、デッドロックする可能性がある。
    133  */
    134 
    135 #define BUF_SIZE        ((TCP_ECHO_SRV_SWBUF_SIZE + \
    136                           TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
    137 
    138 static T_IPEP           dst;                    /* 接続相手         */
    139 
    140 #ifdef USE_TCP_NON_BLOCKING
    141 
    142 static char             buffer[BUF_SIZE];
    143 static ER               nblk_error = E_OK;
    144 static ER_UINT          nblk_slen  = 0;
    145 static ER_UINT          nblk_rlen  = 0;
    146 
    147 #else   /* of #ifdef USE_TCP_NON_BLOCKING */
    148 
    149 #ifdef USE_COPYSAVE_API
    150 
    151 #else   /* of #ifdef USE_COPYSAVE_API */
    152 
    153 static char             buffer[BUF_SIZE];
    154 
    155 #endif  /* of #ifdef USE_COPYSAVE_API */
    156 
    157 #endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    158 
    159 #ifdef USE_TCP_NON_BLOCKING
    160 
    161 /*
    162  *  ノンブロッキングコールのコールバック関数
    163  */
    164 
    165 ER
    166 callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
     133#ifdef USE_TCP_EXTENTIONS
     134
     135T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[NUM_TCP_ECHO_SRV_TASKS];
     136
     137#else   /* of #ifdef USE_TCP_EXTENTIONS */
     138
     139T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
     140
     141#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
     142
     143        { TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID },
     144
     145#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
     146
     147        { TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID },
     148
     149#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
     150
     151#if NUM_TCP_ECHO_SRV_TASKS >= 2
     152        { TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID },
     153#endif
     154#if NUM_TCP_ECHO_SRV_TASKS >= 3
     155        { TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID },
     156#endif
     157#if NUM_TCP_ECHO_SRV_TASKS >= 4
     158        { TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID },
     159#endif
     160#if NUM_TCP_ECHO_SRV_TASKS >= 5
     161        { TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID },
     162#endif
     163#if NUM_TCP_ECHO_SRV_TASKS >= 6
     164        { TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID },
     165#endif
     166#if NUM_TCP_ECHO_SRV_TASKS >= 7
     167        { TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID },
     168#endif
     169#if NUM_TCP_ECHO_SRV_TASKS >= 8
     170        { TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID },
     171#endif
     172
     173        };
     174
     175#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     176
     177/*
     178 *  tcp_passive_open -- 受動オープンを実行する。
     179 *
     180 *    USE_TCP_NON_BLOCKING      OFF
     181 */
     182
     183#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     184
     185static ER
     186tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
    167187{
    168         ER      error = E_OK;
    169 
    170         switch (fncd) {
    171 
    172         case TFN_TCP_ACP_CEP:
    173                 nblk_error = *(ER*)p_parblk;
    174                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    175                 break;
    176 
    177         case TFN_TCP_RCV_DAT:
    178                 if ((nblk_rlen = *(ER*)p_parblk) < 0)
    179                         syslog(LOG_NOTICE, "[TES:%02d CBN] recv error: %s", cepid, itron_strerror(nblk_rlen));
    180                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    181                 break;
    182 
    183         case TFN_TCP_SND_DAT:
    184                 if ((nblk_slen = *(ER*)p_parblk) < 0)
    185                         syslog(LOG_NOTICE, "[TES:%02d CBN] send error: %s", cepid, itron_strerror(nblk_slen));
    186                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    187                 break;
    188 
    189         case TFN_TCP_CLS_CEP:
    190                 if ((nblk_error = *(ER*)p_parblk) < 0)
    191                         syslog(LOG_NOTICE, "[TES:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
    192                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    193                 break;
    194 
    195         case TFN_TCP_RCV_BUF:
    196                 if ((nblk_rlen = *(ER*)p_parblk) < 0)
    197                         syslog(LOG_NOTICE, "[TES:%02d CBN] rbuf error: %s", cepid, itron_strerror(nblk_rlen));
    198                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    199                 break;
    200 
    201         case TFN_TCP_GET_BUF:
    202                 if ((nblk_slen = *(ER*)p_parblk) < 0)
    203                         syslog(LOG_NOTICE, "[TES:%02d CBN] sbuf error: %s", cepid, itron_strerror(nblk_slen));
    204                 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    205                 break;
     188        ER              error = E_OK;
     189
     190#if TNUM_TCP4_REPID > 0
     191        T_IPV4EP        dst4;
     192#endif
     193
     194        if (apip == API_PROTO_IPV6) {
     195
     196#if TNUM_TCP6_REPID > 0
     197
     198                /* 受付口は IPv6 */
     199                if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     200                        return error;
    206201
    207202#ifdef USE_TCP_EXTENTIONS
    208 
    209         case TEV_TCP_RCV_OOB:
    210                 if ((nblk_rlen = *(ER*)p_parblk) < 0)
    211                         syslog(LOG_NOTICE, "[TES:%02d OOB] callback error: %s", cepid, itron_strerror(nblk_rlen));
    212                 else if (nblk_rlen > 0) {
    213                         char ch;
    214 
    215                         if ((nblk_rlen = tcp_rcv_oob(cepid, &ch, sizeof(ch))) > 0)
    216                                 syslog(LOG_NOTICE, "[TES:%02d OOB] recv oob: 0x%02x", cepid, ch);
    217                         else if (nblk_rlen < 0)
    218                                 syslog(LOG_NOTICE, "[TES:%02d OOB] recv error: %s", cepid, itron_strerror(nblk_rlen));
    219                         }
    220                 break;
    221 
     203                if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
     204                        return error;
    222205#endif  /* of #ifdef USE_TCP_EXTENTIONS */
    223206
    224         case TFN_TCP_CON_CEP:
    225         case TFN_TCP_SND_OOB:
    226         default:
    227                 error = E_PAR;
    228                 break;
    229                 }
     207#endif  /* of #if TNUM_TCP6_REPID > 0 */
     208
     209                }
     210        else {
     211
     212#if TNUM_TCP4_REPID > 0
     213
     214                /* 受付口は IPv4 */
     215                if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
     216                        return error;
     217                in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
     218                info->dst.portno = dst4.portno;
     219
     220#ifdef USE_TCP_EXTENTIONS
     221                if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
     222                        return error;
     223#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     224
     225#endif  /* of #if TNUM_TCP4_REPID > 0 */
     226
     227                }
     228
    230229        return error;
    231230        }
    232231
     232#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     233
     234/*
     235 *  tcp_passive_open -- 受動オープンを実行する。
     236 *
     237 *    USE_TCP_NON_BLOCKING      OFF
     238 */
     239
     240static ER
     241tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
     242{
     243        ER              error = E_OK;
     244
     245        if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     246                return error;
     247
     248#ifdef USE_TCP_EXTENTIONS
     249        if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
     250                return error;
     251#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     252
     253        return error;
     254        }
     255
     256#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     257
    233258#ifdef USE_COPYSAVE_API
    234259
    235 static ER
    236 tcp_echo_srv (ID cepid, ID repid)
     260/*
     261 *  tcp_echo_srv -- TCP エコーサーバ
     262 *
     263 *    USE_TCP_NON_BLOCKING      OFF
     264 *    USE_COPYSAVE_API          ON
     265 */
     266
     267ER
     268tcp_echo_srv (uint_t six, char apip)
    237269{
    238         ER              error;
     270        ER              error = E_OK;
     271        ER_UINT         rblen, sblen;
    239272        SYSTIM          now;
    240273        uint32_t        total;
    241         uint16_t        rblen, sblen, rlen, slen, soff, scount, rcount;
    242         char            *rbuf, *sbuf, head, tail;
    243 
    244         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
    245                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
     274        uint16_t        rlen, slen, soff, scount, rcount;
     275        char            *rbuf, *sbuf;
     276
     277#ifdef SHOW_RCV_RANGE
     278        char            head, tail;
     279#endif
     280
     281        if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
     282                syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
     283                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
    246284                return error;
    247285                }
    248286
    249         /* 相手から接続されるまで待つ。*/
    250         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    251 
    252         if (nblk_error == E_OK) {
    253                 syscall(get_tim(&now));
    254                 syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
    255                                    cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    256                 }
     287        syscall(get_tim(&now));
     288
     289#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     290
     291        if (apip == API_PROTO_IPV6)
     292                syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
     293                                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     294                                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
     295                                   tcp_echo_srv_info[six].dst.portno);
    257296        else {
    258                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error));
    259                 return nblk_error;
    260                 }
    261 
    262 #ifdef USE_TCP_EXTENTIONS
    263         if ((error = free_tcp_rep(repid, true)) != E_OK)
    264                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
    265 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    266 
    267         rlen = scount = rcount = total = 0;
     297                T_IN4_ADDR      addr;
     298
     299                addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
     300                syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
     301                                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     302                                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
     303                }
     304
     305#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     306
     307        syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
     308                           apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     309                           IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
     310                           tcp_echo_srv_info[six].dst.portno);
     311
     312#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     313
     314        scount = rcount = total = 0;
    268315        while (true) {
    269                 if ((error = tcp_rcv_buf(cepid, (void**)&rbuf, TMO_NBLK)) != E_WBLK) {
    270                         syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", cepid, itron_strerror(error));
     316                if ((rblen = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, RCV_TMO)) <= 0) {
     317                        if (rblen != E_OK)
     318                                syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
     319                                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(rblen));
    271320                        break;
    272321                        }
    273322
    274                 /* 受信するまで待つ。*/
    275                 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    276 
    277                 if (nblk_rlen < 0) {    /* エラー */
    278                         syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
    279                                            cepid, itron_strerror(nblk_rlen));
    280                         break;
    281                         }
    282                 else if (nblk_rlen == 0)        /* 受信終了 */
    283                         break;
    284 
    285                 rblen = nblk_rlen;
    286 
    287                 /* バッファの残りにより、受信長を調整する。*/
    288                 if (rblen > BUF_SIZE - rlen)
    289                         rblen = BUF_SIZE - rlen;
    290                 total += rblen;
    291                 rlen   = rblen;
    292 
     323                rcount ++;
     324
     325#ifdef SHOW_RCV_RANGE
    293326                head = *rbuf;
    294327                tail = *(rbuf + rblen - 1);
    295                 rcount ++;
    296 
    297 #ifdef SHOW_RCV_RANGE
    298                 syslog(LOG_NOTICE, "[TES:%02d RCV] "
    299                                    "rcount: %4d, len: %4d, data %02x -> %02x",
    300                                    cepid, rcount, rblen, head, tail);
     328
     329                //syslog(LOG_NOTICE, "[TES%c:%02u RCV] len:   %7lu",
     330                //                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)rblen);
     331                syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %7lu, len: %6lu, data %02x -> %02x",
     332                                   apip, tcp_echo_srv_info[six].cepid, rcount, (uint16_t)rblen, head, tail);
    301333#endif  /* of #ifdef SHOW_RCV_RANGE */
    302334
    303                 memcpy(buffer, rbuf, rblen);
    304 
    305                 if ((error = tcp_rel_buf(cepid, rlen)) < 0) {
    306                         syslog(LOG_NOTICE, "[TES:%02d REL] error: %s",
    307                                            cepid, itron_strerror(error));
    308                         break;
    309                         }
    310 
     335                rlen   = (uint16_t)rblen;
     336                total +=     rblen;
    311337                soff = 0;
    312338                while (rlen > 0) {
    313339
    314                         if ((error = tcp_get_buf(cepid, (void**)&sbuf, TMO_NBLK)) != E_WBLK) {
    315                                 syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
    316                                                    cepid, itron_strerror(error));
     340                        if ((sblen = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, SND_TMO)) < 0) {
     341                                syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
     342                                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(sblen));
    317343                                goto err_fin;
    318344                                }
    319345
    320                         /* 送信バッファの獲得が完了するまで待つ。*/
    321                         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    322 
    323                         if (nblk_slen < 0) {
    324                                 syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
    325                                                    cepid, itron_strerror(nblk_slen));
    326                                 goto err_fin;
    327                                 }
    328 
    329                         sblen = nblk_slen;
     346                        //syslog(LOG_NOTICE, "[TES%c:%02u SND] len:   %7lu",
     347                        //                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)sblen);
    330348                        scount ++;
    331                         slen = sblen < rlen ? sblen : rlen;
    332                         memcpy(sbuf, buffer + soff, slen);
    333 
    334                         if ((error = tcp_snd_buf(cepid, slen)) != E_OK) {
    335                                 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
    336                                                    cepid, itron_strerror(error));
     349                        slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
     350                        memcpy(sbuf, rbuf + soff, slen);
     351                        if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) {
     352                                syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
     353                                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
    337354                                goto err_fin;
    338355                                }
    339356#ifdef SHOW_RCV_RANGE
    340                         syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d",
    341                                            cepid, scount, slen);
     357                        syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
     358                                           apip, tcp_echo_srv_info[six].cepid, scount, slen);
    342359#endif  /* of #ifdef SHOW_RCV_RANGE */
    343360
     
    345362                        soff += slen;
    346363                        }
     364
     365                if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rblen)) < 0) {
     366                        syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s",
     367                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
     368                        break;
     369                        }
    347370                }
    348371err_fin:
    349372
    350373#ifdef USE_TCP_SHT_CEP
    351         if ((error = tcp_sht_cep(cepid)) != E_OK)
    352                 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
     374        if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
     375                syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
     376                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
    353377#endif  /* of #ifdef USE_TCP_SHT_CEP */
    354378
    355         if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
    356                 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
    357 
    358         /* 開放が完了するまで待つ。*/
    359         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
     379        if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, CLS_TMO)) != E_OK)
     380                syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
     381                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
    360382
    361383        syscall(get_tim(&now));
    362         syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
    363                            cepid, now / SYSTIM_HZ, scount, rcount, total);
    364 
    365         return error == E_WBLK ? E_OK : error;
     384#if 1
     385        syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
     386                           apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
     387#else
     388        syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu, error: %s",
     389                           apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total, itron_strerror(error));
     390#endif
     391
     392        return error;
    366393        }
    367394
    368395#else   /* of #ifdef USE_COPYSAVE_API */
    369396
    370 static ER
    371 tcp_echo_srv (ID cepid, ID repid)
     397/*
     398 *  tcp_echo_srv -- TCP エコーサーバ
     399 *
     400 *    USE_TCP_NON_BLOCKING      OFF
     401 *    USE_COPYSAVE_API          OFF
     402 */
     403
     404ER
     405tcp_echo_srv (uint_t six, char apip)
    372406{
     407        ID              cepid;
     408        ER              error = E_OK;
     409        ER_UINT         rlen, slen;
    373410        SYSTIM          now;
    374         ER              error;
    375411        uint32_t        total;
    376         uint16_t        rlen, slen, soff, scount, rcount;
    377         char            head, tail;
    378 
    379         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
    380                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
     412        uint16_t        soff, scount, rcount;
     413
     414        if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
     415                syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
     416                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
    381417                return error;
    382418                }
    383 
    384         /* 相手から接続されるまで待つ。*/
    385         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    386 
    387         if (nblk_error == E_OK) {
    388                 syscall(get_tim(&now));
    389                 syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
    390                                    cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    391                 }
    392         else {
    393                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error));
    394                 return nblk_error;
    395                 }
    396 
    397 #ifdef USE_TCP_EXTENTIONS
    398         if ((error = free_tcp_rep(repid, true)) != E_OK)
    399                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
    400 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    401 
     419       
     420        syscall(get_tim(&now));
     421
     422#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     423
     424        if (apip == API_PROTO_IPV6)
     425                syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
     426                                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     427                                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
     428                                   tcp_echo_srv_info[six].dst.portno);
     429        else    {
     430                T_IN4_ADDR      addr;
     431
     432                addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
     433                syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
     434                                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     435                                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
     436                }
     437
     438#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     439
     440        syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
     441                           apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
     442                           IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
     443                           tcp_echo_srv_info[six].dst.portno);
     444
     445#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     446
     447        cepid =  tcp_echo_srv_info[six].cepid;
    402448        scount = rcount = total = 0;
    403449        while (true) {
    404                 if ((error = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
    405                         syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
    406                                            cepid, itron_strerror(error));
     450                if ((rlen = tcp_rcv_dat(cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {
     451                        if (rlen != E_OK)
     452                                syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
     453                                                   apip, cepid, itron_strerror(rlen));
    407454                        break;
    408455                        }
    409456
    410                 /* 受信完了まで待つ。*/
    411                 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    412 
    413                 if (nblk_rlen < 0) {
    414                         syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
    415                                            cepid, itron_strerror(nblk_rlen));
    416                         break;
    417                         }
    418                 else if (nblk_rlen == 0)
    419                         break;
    420 
    421                 rlen = nblk_rlen;
    422                 head = *buffer;
    423                 tail = *(buffer + rlen - 1);
    424457                rcount ++;
    425 
    426458#ifdef SHOW_RCV_RANGE
    427                 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
    428                                    cepid, rcount, rlen, head, tail);
     459                syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x",
     460                                   apip, cepid, rcount,
     461                                   (uint16_t)rlen, * tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer,
     462                                                   *(tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer + rlen - 1));
    429463#endif  /* of #ifdef SHOW_RCV_RANGE */
    430464
     
    433467                while (rlen > 0) {
    434468                        scount ++;
    435                         if ((error = tcp_snd_dat(cepid, &buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
    436                                 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
    437                                                    cepid, itron_strerror(error));
     469                        if ((slen = tcp_snd_dat(cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, SND_TMO)) < 0) {
     470                                syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
     471                                                   apip, cepid, itron_strerror(slen));
    438472                                goto err_fin;
    439473                                }
    440 
    441                         /* 送信完了まで待つ。*/
    442                         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
    443 
    444                         if (nblk_slen < 0) {
    445                                 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
    446                                                    cepid, itron_strerror(nblk_slen));
    447                                 goto err_fin;
    448                                 }
    449 
    450                         slen = nblk_slen;
    451 
    452474#ifdef SHOW_RCV_RANGE
    453                         syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d",
    454                                            cepid, scount, slen);
     475                        syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
     476                                           apip, cepid, scount, (uint16_t)slen);
    455477#endif  /* of #ifdef SHOW_RCV_RANGE */
    456478
     
    463485#ifdef USE_TCP_SHT_CEP
    464486        if ((error = tcp_sht_cep(cepid)) != E_OK)
    465                 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
     487                syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
     488                                    apip, cepid, itron_strerror(error));
    466489#endif  /* of #ifdef USE_TCP_SHT_CEP */
    467490
    468         if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
    469                 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
    470 
    471         /* 開放が完了するまで待つ。*/
    472         syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
     491        if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
     492                syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
     493                                   apip, cepid, itron_strerror(error));
    473494
    474495        syscall(get_tim(&now));
    475         syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
    476                            cepid, now / SYSTIM_HZ, scount, rcount, total);
    477 
    478         return error == E_WBLK ? E_OK : error;
    479         }
    480 
    481 #endif  /* of #ifdef USE_COPYSAVE_API */
    482 
    483 #else   /* of #ifdef USE_TCP_NON_BLOCKING */
    484 
    485 #ifdef USE_COPYSAVE_API
    486 
    487 static ER
    488 tcp_echo_srv (ID cepid, ID repid)
    489 {
    490         ER_UINT         rblen, sblen;
    491         SYSTIM          now;
    492         ER              error;
    493         uint32_t        total;
    494         uint16_t        rlen, slen, soff, scount, rcount;
    495         char            *rbuf, *sbuf, head, tail;
    496 
    497         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    498                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
    499                 return error;
    500                 }
    501 
    502 #ifdef USE_TCP_EXTENTIONS
    503         if ((error = free_tcp_rep(repid, true)) != E_OK)
    504                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
    505 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    506 
    507         scount = rcount = total = 0;
    508         syscall(get_tim(&now));
    509         syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
    510                            cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    511         while (true) {
    512                 if ((rblen = tcp_rcv_buf(cepid, (void**)&rbuf, RCV_TMO)) <= 0) {
    513                         if (rblen != E_OK)
    514                                 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
    515                                                    cepid, itron_strerror(rblen));
    516                         break;
    517                         }
    518 
    519                 head = *rbuf;
    520                 tail = *(rbuf + rblen - 1);
    521                 rcount ++;
    522 
    523                 //syslog(LOG_NOTICE, "[TES:%02d RCV] len: %4d", cepid, (uint16_t)rblen);
    524 #ifdef SHOW_RCV_RANGE
    525                 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
    526                        cepid, rcount, (uint16_t)rblen, head, tail);
    527 #endif  /* of #ifdef SHOW_RCV_RANGE */
    528 
    529                 rlen   = (uint16_t)rblen;
    530                 total +=     rblen;
    531                 soff = 0;
    532                 while (rlen > 0) {
    533 
    534                         if ((sblen = tcp_get_buf(cepid, (void**)&sbuf, SND_TMO)) < 0) {
    535                                 syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
    536                                                    cepid, itron_strerror(sblen));
    537                                 goto err_fin;
    538                                 }
    539 
    540                         //syslog(LOG_NOTICE, "[TES:%02d SND] len: %4d", cepid, (uint16_t)sblen);
    541                         scount ++;
    542                         slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
    543                         memcpy(sbuf, rbuf + soff, slen);
    544                         if ((error = tcp_snd_buf(cepid, slen)) != E_OK) {
    545                                 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
    546                                                    cepid, itron_strerror(error));
    547                                 goto err_fin;
    548                                 }
    549 #ifdef SHOW_RCV_RANGE
    550                         syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, slen);
    551 #endif  /* of #ifdef SHOW_RCV_RANGE */
    552 
    553                         rlen -= slen;
    554                         soff += slen;
    555                         }
    556 
    557                 if ((error = tcp_rel_buf(cepid, rblen)) < 0) {
    558                         syslog(LOG_NOTICE, "[TES:%02d REL] error: %s", cepid, itron_strerror(error));
    559                         break;
    560                         }
    561                 }
    562 err_fin:
    563 
    564 #ifdef USE_TCP_SHT_CEP
    565         if ((error = tcp_sht_cep(cepid)) != E_OK)
    566                 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
    567 #endif  /* of #ifdef USE_TCP_SHT_CEP */
    568 
    569         if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
    570                 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
    571 
    572         syscall(get_tim(&now));
    573         syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
    574                            cepid, now / SYSTIM_HZ, scount, rcount, total);
     496        syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
     497                           apip, cepid, now / SYSTIM_HZ, total);
    575498
    576499        return error;
    577500        }
    578501
    579 #else   /* of #ifdef USE_COPYSAVE_API */
    580 
    581 /*
    582  *  tcp_echo_srv -- TCP エコーサーバ
    583  */
    584 
    585 static ER
    586 tcp_echo_srv (ID cepid, ID repid)
    587 {
    588         ER_UINT         rlen, slen;
    589         ER              error = E_OK;
    590         SYSTIM          now;
    591         uint32_t        total;
    592         uint16_t        soff, scount, rcount;
    593 
    594         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    595                 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
    596                 return error;
    597                 }
    598 
    599 #ifdef USE_TCP_EXTENTIONS
    600         if ((error = free_tcp_rep(repid, true)) != E_OK)
    601                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
    602 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    603 
    604         scount = rcount = total = 0;
    605         syscall(get_tim(&now));
    606         syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
    607                            cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    608         while (true) {
    609                 if ((rlen = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {
    610                         if (rlen != E_OK)
    611                                 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
    612                                                    cepid, itron_strerror(rlen));
    613                         break;
    614                         }
    615 
    616                 rcount ++;
    617 #ifdef SHOW_RCV_RANGE
    618                 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
    619                        cepid, rcount, (uint16_t)rlen, *buffer, *(buffer + rlen - 1));
    620 #endif  /* of #ifdef SHOW_RCV_RANGE */
    621 
    622                 total += rlen;
    623                 soff = 0;
    624                 while (rlen > 0) {
    625                         scount ++;
    626                         if ((slen = tcp_snd_dat(cepid, &buffer[soff], rlen, SND_TMO)) < 0) {
    627                                 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
    628                                                    cepid, itron_strerror(slen));
    629                                 goto err_fin;
    630                                 }
    631 #ifdef SHOW_RCV_RANGE
    632                         syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, (uint16_t)slen);
    633 #endif  /* of #ifdef SHOW_RCV_RANGE */
    634 
    635                         rlen -= slen;
    636                         soff += slen;
    637                         }
    638                 }
    639 err_fin:
    640 
    641 #ifdef USE_TCP_SHT_CEP
    642         if ((error = tcp_sht_cep(cepid)) != E_OK)
    643                 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
    644 #endif  /* of #ifdef USE_TCP_SHT_CEP */
    645 
    646         if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
    647                 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
    648 
    649         syscall(get_tim(&now));
    650         syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
    651                            cepid, now / SYSTIM_HZ, scount, rcount, total);
    652 
    653         return error;
    654         }
    655 
    656502#endif  /* of #ifdef USE_COPYSAVE_API */
    657503
    658 #endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    659 
    660 #ifdef USE_TCP_EXTENTIONS
    661 
    662 /*
    663  *  get_tcp_rep -- TCP 受付口を獲得する。
    664  */
    665 
    666 static ER
    667 get_tcp_rep (ID *repid)
    668 {
    669         ID              tskid;
    670         T_TCP_CREP      crep;
    671 
    672         get_tid(&tskid);
    673 
    674         crep.repatr = UINT_C(0);
    675         crep.myaddr.portno = UINT_C(7);
    676 
    677 #if defined(SUPPORT_INET4)
    678         crep.myaddr.ipaddr = IPV4_ADDRANY;
    679 #endif
    680 
    681 #if defined(SUPPORT_INET6)
    682         memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
    683 #endif
    684 
    685         return alloc_tcp_rep(repid, tskid, &crep);
    686         }
    687 
    688 /*
    689  *  get_tcp_cep -- TCP 通信端点とを獲得する。
    690  */
    691 
    692 static ER
    693 get_tcp_cep (ID *cepid)
    694 {
    695         ID              tskid;
    696         T_TCP_CCEP      ccep;
    697 
    698         get_tid(&tskid);
    699 
    700         ccep.cepatr = UINT_C(0);
    701         ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE;
    702         ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE;
    703 
    704 #ifdef TCP_CFG_SWBUF_CSAVE
    705         ccep.sbuf = NADR;
    706 #else
    707         ccep.sbuf = tcp_echo_srv_swbuf;
    708 #endif
    709 #ifdef TCP_CFG_RWBUF_CSAVE
    710         ccep.rbuf = NADR;
    711 #else
    712         ccep.rbuf = tcp_echo_srv_rwbuf;
    713 #endif
    714 #ifdef USE_TCP_NON_BLOCKING
    715         ccep.callback = (FP)callback_nblk_tcp_echo_srv;
    716 #else
    717         ccep.callback = NULL;
    718 #endif
    719 
    720         return alloc_tcp_cep(cepid, tskid, &ccep);
    721         }
    722 
    723 /*
    724  *  tcp_echo_srv_task -- TCP エコーサーバタスク
    725  */
    726 
    727 void
    728 tcp_echo_srv_task (intptr_t exinf)
    729 {
    730         ID      tskid, cepid, repid;
    731         ER      error = E_OK;
    732 
    733         syscall(get_tid(&tskid));
    734         syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid);
    735         while (true) {
    736 
    737                 syscall(slp_tsk());
    738                 if ((error = get_tcp_cep (&cepid)) != E_OK) {
    739                         syslog(LOG_NOTICE, "[TES:00 EXT] CEP create error: %s", itron_strerror(error));
    740                         continue;
    741                         }
    742 
    743                 while (true) {
    744 
    745                         if ((error = get_tcp_rep (&repid)) != E_OK) {
    746                                 syslog(LOG_NOTICE, "[TES:00 EXT] REP create error: %s", itron_strerror(error));
    747                                 break;
    748                                 }
    749                         else if ((error = tcp_echo_srv(cepid, repid)) != E_OK) {
    750                                 error = free_tcp_rep(repid, error != E_DLT);
    751                                 break;
    752                                 }
    753                         }
    754 
    755                 if ((error = free_tcp_cep(cepid)) != E_OK)
    756                         syslog(LOG_NOTICE, "[TES:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
    757 
    758                 }
    759         }
    760 
    761 #else   /* of #ifdef USE_TCP_EXTENTIONS */
     504#endif  /* of #ifndef USE_TCP_NON_BLOCKING */
     505
     506#ifndef USE_TCP_EXTENTIONS
    762507
    763508/*
     
    768513tcp_echo_srv_task(intptr_t exinf)
    769514{
    770         ID      tskid;
     515        ID      tskid, cepid;
    771516        ER      error;
     517        uint_t  six;
     518        char    apip;
     519
     520        six = INDEX_SRV_INFO((ID)exinf);
     521
     522#if defined(SUPPORT_INET6)
     523
     524#if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
     525
     526        if (six >= NUM_TCP4_ECHO_SRV_TASKS)
     527                apip = API_PROTO_IPV6;
     528        else
     529                apip = API_PROTO_IPV4;
     530
     531#else   /* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
     532
     533        apip = API_PROTO_IPV6;
     534
     535#endif  /* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
     536
     537#else   /* of #if defined(SUPPORT_INET6) */
     538
     539        apip = API_PROTO_IPV4;
     540
     541#endif  /* of #if defined(SUPPORT_INET6) */
    772542
    773543        syscall(get_tid(&tskid));
    774         syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
     544        cepid = tcp_echo_srv_info[six].cepid;
     545        syslog(LOG_NOTICE, "[TCP%c ECHO SRV:%d,%d] started.", apip, tskid, cepid);
     546
    775547        while (true) {
    776                 while ((error = tcp_echo_srv((ID)exinf, TCP_ECHO_SRV_REPID)) == E_OK)
     548                while ((error = tcp_echo_srv(six, apip)) == E_OK)
    777549                        ;
    778                 syslog(LOG_NOTICE, "[TES:%02d] goto sleep 60[s], error: %s", (ID)exinf, itron_strerror(error));
    779                 tslp_tsk(60 * 1000);
     550                syslog(LOG_NOTICE, "[TES%c:%02u TSK] sleep 60[s], error: %s", apip, cepid, itron_strerror(error));
     551                tslp_tsk(60 * 1000 * 1000);
     552                syslog(LOG_NOTICE, "[TES%c:%02u TSK] resume.", apip, cepid);
    780553                }
    781554        }
    782555
    783 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
     556#endif  /* of #ifndef USE_TCP_EXTENTIONS */
    784557
    785558#endif  /* of #ifdef USE_TCP_ECHO_SRV1 */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.cfg

    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 *
     
    4141/* タスク */
    4242
    43 #ifdef USE_TCP_EXTENTIONS
    44 
    45 CRE_TSK(TCP_ECHO_SRV_TASK,  {
     43CRE_TSK(TCP_ECHO_SRV_TASK1,  {
    4644        TA_HLNG | TA_ACT,
    47         0,
     45        1,
    4846        tcp_echo_srv_task,
    4947        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    5250        });
    5351
    54 #else   /* of #ifdef USE_TCP_EXTENTIONS */
    55 
    56 CRE_TSK(TCP_ECHO_SRV_TASK,  {
    57         TA_HLNG | TA_ACT,
    58         TCP_ECHO_SRV_CEPID1,
    59         tcp_echo_srv_task,
    60         TCP_ECHO_SRV_MAIN_PRIORITY,
    61         TCP_ECHO_SRV_STACK_SIZE,
    62         NULL
    63         });
    64 
    65 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    66 
    6752#if NUM_TCP_ECHO_SRV_TASKS >= 2
    6853
    6954CRE_TSK(TCP_ECHO_SRV_TASK2,  {
    7055        TA_HLNG | TA_ACT,
    71         TCP_ECHO_SRV_CEPID2,
     56        2,
    7257        tcp_echo_srv_task,
    7358        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    8267CRE_TSK(TCP_ECHO_SRV_TASK3,  {
    8368        TA_HLNG | TA_ACT,
    84         TCP_ECHO_SRV_CEPID3,
     69        3,
    8570        tcp_echo_srv_task,
    8671        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    9580CRE_TSK(TCP_ECHO_SRV_TASK4,  {
    9681        TA_HLNG | TA_ACT,
    97         TCP_ECHO_SRV_CEPID4,
     82        4,
    9883        tcp_echo_srv_task,
    9984        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    10893CRE_TSK(TCP_ECHO_SRV_TASK5,  {
    10994        TA_HLNG | TA_ACT,
    110         TCP_ECHO_SRV_CEPID5,
     95        5,
    11196        tcp_echo_srv_task,
    11297        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    121106CRE_TSK(TCP_ECHO_SRV_TASK6,  {
    122107        TA_HLNG | TA_ACT,
    123         TCP_ECHO_SRV_CEPID6,
     108        6,
    124109        tcp_echo_srv_task,
    125110        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    134119CRE_TSK(TCP_ECHO_SRV_TASK7,  {
    135120        TA_HLNG | TA_ACT,
    136         TCP_ECHO_SRV_CEPID7,
     121        7,
    137122        tcp_echo_srv_task,
    138123        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    147132CRE_TSK(TCP_ECHO_SRV_TASK8,  {
    148133        TA_HLNG | TA_ACT,
    149         TCP_ECHO_SRV_CEPID8,
     134        8,
    150135        tcp_echo_srv_task,
    151136        TCP_ECHO_SRV_MAIN_PRIORITY,
     
    160145#ifdef USE_TCP_NON_BLOCKING
    161146
    162 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY,    { TA_TPRI, 0, 1 });
     147CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY1,   { TA_TPRI, 0, 1 });
     148
     149#if NUM_TCP_ECHO_SRV_TASKS >= 2
     150CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY2,   { TA_TPRI, 0, 1 });
     151#endif
     152#if NUM_TCP_ECHO_SRV_TASKS >= 3
     153CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY3,   { TA_TPRI, 0, 1 });
     154#endif
     155#if NUM_TCP_ECHO_SRV_TASKS >= 4
     156CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY4,   { TA_TPRI, 0, 1 });
     157#endif
     158#if NUM_TCP_ECHO_SRV_TASKS >= 5
     159CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY5,   { TA_TPRI, 0, 1 });
     160#endif
     161#if NUM_TCP_ECHO_SRV_TASKS >= 6
     162CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY6,   { TA_TPRI, 0, 1 });
     163#endif
     164#if NUM_TCP_ECHO_SRV_TASKS >= 7
     165CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY7,   { TA_TPRI, 0, 1 });
     166#endif
     167#if NUM_TCP_ECHO_SRV_TASKS >= 8
     168CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY8,   { TA_TPRI, 0, 1 });
     169#endif
    163170
    164171#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.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 *
     
    7070#include <netinet/in_itron.h>
    7171#include <netinet/ip.h>
    72 #include <netinet/ip6.h>
    7372#include <netinet/tcp.h>
    7473
    7574#include <netapp/netapp.h>
    7675#include <netapp/netapp_var.h>
    77 #include <netapp/echo.h>
     76#include <netapp/tcp_echo_srv2.h>
    7877
    7978#ifdef USE_TCP_ECHO_SRV2
     
    161160                        snd_error = 1;
    162161                        ena_rcv   = true;
    163                         syslog(LOG_NOTICE, "[TES:%02d CBN] connected:  %6ld, from: %s.%d",
     162                        syslog(LOG_NOTICE, "[TES:%02u CBN] connect: %6lu, from: %s.%d",
    164163                                           cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    165164                        }
    166165                else
    167                         syslog(LOG_NOTICE, "[TES:%02d CBN] accept error: %s\n", cepid, itron_strerror(rcv_error));
     166                        syslog(LOG_NOTICE, "[TES:%02u CBN] accept error: %s\n", cepid, itron_strerror(rcv_error));
    168167
    169168                syscall(sig_sem(SEM_TCP_ECHO_SRV_RCV_READY));
     
    176175                        tail = *(sptr + slen - 1);
    177176#ifdef SHOW_RCV_RANGE
    178                         syslog(LOG_NOTICE, "[TES:%02d CBN] send len: %4d, data %02x -> %02x",
     177                        syslog(LOG_NOTICE, "[TES:%02u CBN] send len: %4u, data %02x -> %02x",
    179178                                           cepid, (uint16_t)slen, head, tail);
    180179#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    205204                        }
    206205                else {
    207                         syslog(LOG_NOTICE, "[TES:%02d CBN] send error = %s", cepid, itron_strerror(snd_error));
     206                        syslog(LOG_NOTICE, "[TES:%02u CBN] send error = %s", cepid, itron_strerror(snd_error));
    208207                        sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
    209208                        }
     
    216215                        tail = *(rptr + rlen - 1);
    217216#ifdef SHOW_RCV_RANGE
    218                         syslog(LOG_NOTICE, "[TES:%02d CBN] recv len: %4d, data %02x -> %02x",
     217                        syslog(LOG_NOTICE, "[TES:%02u CBN] recv len: %4u, data %02x -> %02x",
    219218                                           cepid, (uint16_t)rlen, head, tail);
    220219#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    246245                else {
    247246                        if (rlen < 0)
    248                                 syslog(LOG_NOTICE, "[TES:%02d CBN] recv error = %s", cepid, itron_strerror(rcv_error));
     247                                syslog(LOG_NOTICE, "[TES:%02u CBN] recv error = %s", cepid, itron_strerror(rcv_error));
    249248                        sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
    250249                        }
     
    254253                snd_error = *(ER*)p_parblk;
    255254                if (snd_error != E_OK)
    256                         syslog(LOG_NOTICE, "[TES:%02d CBN] close error = %s", cepid, itron_strerror(snd_error));
    257 
    258                 syslog(LOG_NOTICE, "[TES:%02d CBN] finished:   %6ld, snd: %4d, rcv: %4d, len: %ld",
     255                        syslog(LOG_NOTICE, "[TES:%02u CBN] close error = %s", cepid, itron_strerror(snd_error));
     256
     257                syslog(LOG_NOTICE, "[TES:%02u CBN] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
    259258                                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
    260259
     
    283282
    284283        if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
    285                 syslog(LOG_NOTICE, "[TES:%02d RCV] sync error: %s", cepid, itron_strerror(error));
     284                syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
    286285                return error;
    287286                }
    288287
    289288        if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
    290                 syslog(LOG_NOTICE, "[TES:%02d ACP] accept error = %s", cepid, itron_strerror(error));
     289                syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error));
    291290                return error;
    292291                }
     
    300299
    301300#ifdef USE_TCP_EXTENTIONS
    302         if ((error = free_tcp_rep(repid, true)) != E_OK) {
    303                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
     301        if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
     302                syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
    304303                return error;
    305304                }
     
    318317                /* 受信する。*/
    319318                if ((error = tcp_rcv_dat(cepid, rptr, blen, TMO_NBLK)) != E_WBLK) {
    320                         syslog(LOG_NOTICE, "[TES:%02d RCV] recv error = %s", cepid, itron_strerror(error));
     319                        syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s", cepid, itron_strerror(error));
    321320                        break;
    322321                        }
     
    359358        while (true) {
    360359                if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
    361                         syslog(LOG_NOTICE, "[TES:%02d SND] sync error: %s",
     360                        syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
    362361                                           cepid, itron_strerror(error));
    363362                        continue;
     
    387386                        /* 送信する。*/
    388387                        if ((error = tcp_snd_dat(cepid, sptr, blen, TMO_NBLK)) != E_WBLK) {
    389                                 syslog(LOG_NOTICE, "[TES:%02d SND] send error = %s", cepid, itron_strerror(error));
     388                                syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(error));
    390389                                break;
    391390                                }
     
    398397#ifdef USE_TCP_SHT_CEP
    399398                if ((error = tcp_sht_cep(cepid)) != E_OK)
    400                         syslog(LOG_NOTICE, "[TES:%02d SND] shutdown error = %s", cepid, itron_strerror(error));
     399                        syslog(LOG_NOTICE, "[TES:%02u SND] shutdown error = %s", cepid, itron_strerror(error));
    401400#endif  /* of #ifdef USE_TCP_SHT_CEP */
    402401
    403402                if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) {
    404                         syslog(LOG_NOTICE, "[TES:%02d SND] close error = %s", cepid, itron_strerror(error));
     403                        syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
    405404                        }
    406405
     
    426425
    427426        if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
    428                 syslog(LOG_NOTICE, "[TES:%02d RCV] sync error: %s", cepid, itron_strerror(error));
     427                syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
    429428                return error;
    430429                }
    431430
    432431        if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    433                 syslog(LOG_NOTICE, "[TES:%02d ACP] accept error = %s", cepid, itron_strerror(error));
     432                syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error));
    434433                return error;
    435434                }
    436435
    437436#ifdef USE_TCP_EXTENTIONS
    438         if ((error = free_tcp_rep(repid, true)) != E_OK) {
    439                 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
     437        if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
     438                syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
    440439                return error;
    441440                }
     
    443442
    444443        syscall(get_tim(&now));
    445         syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6ld, from: %s.%d",
     444        syslog(LOG_NOTICE, "[TES:%02u ACP] connect: %6lu, from: %s.%d",
    446445                           cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    447446        sptr = rptr = buffer;
     
    461460                if ((rlen = tcp_rcv_dat(cepid, rptr, blen, TMO_FEVR)) <= 0) {
    462461                        if (rlen < 0)
    463                                 syslog(LOG_NOTICE, "[TES:%02d RCV] recv error = %s",
     462                                syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s",
    464463                                                   cepid, itron_strerror(rlen));
    465464                        break;
     
    468467                tail = *(rptr + rlen - 1);
    469468#ifdef SHOW_RCV_RANGE
    470                 syslog(LOG_NOTICE, "[TES:%02d RCV] len: %4d, data %02x -> %02x",
     469                syslog(LOG_NOTICE, "[TES:%02u RCV] len: %4u, data %02x -> %02x",
    471470                                   cepid, (uint16_t)rlen, head, tail);
    472471#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    531530        while (true) {
    532531                if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
    533                         syslog(LOG_NOTICE, "[TES:%02d SND] sync error: %s",
     532                        syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
    534533                                           cepid, itron_strerror(error));
    535534                        continue;
     
    554553
    555554                        if ((slen = tcp_snd_dat(cepid, sptr, blen, TMO_FEVR)) <= 0) {
    556                                 syslog(LOG_NOTICE, "[TES:%02d SND] send error = %s", cepid, itron_strerror(slen));
     555                                syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(slen));
    557556                                break;
    558557                                }
     
    561560                        tail = *(sptr + slen - 1);
    562561#ifdef SHOW_RCV_RANGE
    563                         syslog(LOG_NOTICE, "[TES:%02d SND] len: %4d, data %02x -> %02x",
     562                        syslog(LOG_NOTICE, "[TES:%02u SND] len: %4u, data %02x -> %02x",
    564563                                           cepid, (uint16_t)slen, head, tail);
    565564#endif  /* of #ifdef SHOW_RCV_RANGE */
     
    602601#ifdef USE_TCP_SHT_CEP
    603602                if ((error = tcp_sht_cep(cepid)) != E_OK)
    604                         syslog(LOG_NOTICE, "[TES:%02d SND] shtudown error = %s", cepid, itron_strerror(error));
     603                        syslog(LOG_NOTICE, "[TES:%02u SND] shtudown error = %s", cepid, itron_strerror(error));
    605604#endif  /* of #ifdef USE_TCP_SHT_CEP */
    606605
    607606                if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
    608                         syslog(LOG_NOTICE, "[TES:%02d SND] close error = %s", cepid, itron_strerror(error));
     607                        syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
    609608
    610609                get_tim(&now);
    611                 syslog(LOG_NOTICE, "[TES:%02d SND] finished:   %6ld, snd: %4d, rcv: %4d, len: %ld",
     610                syslog(LOG_NOTICE, "[TES:%02u SND] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
    612611                                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
    613612
     
    646645#endif
    647646
    648         return alloc_tcp_rep(repid, tskid, &crep);
     647        return ALLOC_TCP_REP(repid, tskid, &crep);
    649648        }
    650649
     
    681680#endif
    682681
    683         return alloc_tcp_cep(cepid, tskid, &ccep);
     682        return ALLOC_TCP_CEP(cepid, tskid, &ccep);
    684683        }
    685684
     
    711710                                }
    712711                        else if ((error = tcp_echo_srv_rcv(cepid, repid)) != E_OK) {
    713                                 error = free_tcp_rep(repid, error != E_DLT);
     712                                error = FREE_TCP_REP(repid, error != E_DLT);
    714713                                break;
    715714                                }
     
    717716
    718717                if ((error = free_tcp_cep(cepid)) != E_OK)
    719                         syslog(LOG_NOTICE, "[TES:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
     718                        syslog(LOG_NOTICE, "[TES:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
    720719
    721720                }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dbg_cons.cfg

    r321 r331  
    22 *  TINET (UDP/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 *
     
    4343/* TCP 受付口 */
    4444
     45#ifdef SUPPORT_INET6
     46
     47#if NUM_VRID_TCP6_REPS >= 1
     48VRID_TCP6_REP (TCP6_RSV_REPID1);
     49#endif
     50
     51#if NUM_VRID_TCP6_REPS >= 2
     52VRID_TCP6_REP (TCP6_RSV_REPID2);
     53#endif
     54
     55#endif  /* of #ifdef SUPPORT_INET6 */
     56
    4557#ifdef SUPPORT_INET4
    4658
    47 #if NUM_VRID_TCP_REPS >= 1
    48 VRID_TCP_REP (TCP_RSV_REPID1);
     59#if NUM_VRID_TCP4_REPS >= 1
     60VRID_TCP_REP (TCP4_RSV_REPID1);
    4961#endif
    5062
    51 #if NUM_VRID_TCP_REPS >= 2
    52 VRID_TCP_REP (TCP_RSV_REPID2);
     63#if NUM_VRID_TCP4_REPS >= 2
     64VRID_TCP_REP (TCP4_RSV_REPID2);
    5365#endif
    5466
    5567#endif  /* of #ifdef SUPPORT_INET4 */
    5668
     69/* TCP 通信端点 */
     70
    5771#ifdef SUPPORT_INET6
    5872
    59 #if NUM_VRID_TCP_REPS >= 1
    60 VRID_TCP6_REP (TCP_RSV_REPID1);
     73#if NUM_VRID_TCP6_CEPS >= 1
     74VRID_TCP6_CEP (TCP6_RSV_CEPID1);
    6175#endif
    6276
    63 #if NUM_VRID_TCP_REPS >= 2
    64 VRID_TCP6_REP (TCP_RSV_REPID2);
     77#if NUM_VRID_TCP6_CEPS >= 2
     78VRID_TCP6_CEP (TCP6_RSV_CEPID2);
     79#endif
     80
     81#if NUM_VRID_TCP6_CEPS >= 3
     82VRID_TCP6_CEP (TCP6_RSV_CEPID3);
     83#endif
     84
     85#if NUM_VRID_TCP6_CEPS >= 4
     86VRID_TCP6_CEP (TCP6_RSV_CEPID4);
    6587#endif
    6688
    6789#endif  /* of #ifdef SUPPORT_INET6 */
    6890
    69 /* TCP 通信端点 */
    70 
    7191#ifdef SUPPORT_INET4
    7292
    73 #if NUM_VRID_TCP_CEPS >= 1
    74 VRID_TCP_CEP (TCP_RSV_CEPID1);
     93#if NUM_VRID_TCP4_CEPS >= 1
     94VRID_TCP_CEP (TCP4_RSV_CEPID1);
    7595#endif
    7696
    77 #if NUM_VRID_TCP_CEPS >= 2
    78 VRID_TCP_CEP (TCP_RSV_CEPID2);
     97#if NUM_VRID_TCP4_CEPS >= 2
     98VRID_TCP_CEP (TCP4_RSV_CEPID2);
    7999#endif
    80100
    81 #if NUM_VRID_TCP_CEPS >= 3
    82 VRID_TCP_CEP (TCP_RSV_CEPID3);
     101#if NUM_VRID_TCP4_CEPS >= 3
     102VRID_TCP_CEP (TCP4_RSV_CEPID3);
    83103#endif
    84104
    85 #if NUM_VRID_TCP_CEPS >= 4
    86 VRID_TCP_CEP (TCP_RSV_CEPID4);
     105#if NUM_VRID_TCP4_CEPS >= 4
     106VRID_TCP_CEP (TCP4_RSV_CEPID4);
    87107#endif
    88108
    89109#endif  /* of #ifdef SUPPORT_INET4 */
    90 
    91 #ifdef SUPPORT_INET6
    92 
    93 #if NUM_VRID_TCP_CEPS >= 1
    94 VRID_TCP6_CEP (TCP_RSV_CEPID1);
    95 #endif
    96 
    97 #if NUM_VRID_TCP_CEPS >= 2
    98 VRID_TCP6_CEP (TCP_RSV_CEPID2);
    99 #endif
    100 
    101 #if NUM_VRID_TCP_CEPS >= 3
    102 VRID_TCP6_CEP (TCP_RSV_CEPID3);
    103 #endif
    104 
    105 #if NUM_VRID_TCP_CEPS >= 4
    106 VRID_TCP6_CEP (TCP_RSV_CEPID4);
    107 #endif
    108 
    109 #endif  /* of #ifdef SUPPORT_INET6 */
    110110
    111111#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     
    115115/* UDP 通信端点 */
    116116
     117#ifdef SUPPORT_INET6
     118
     119#if NUM_VRID_UDP6_CEPS >= 1
     120VRID_UDP6_CEP (UDP6_RSV_CEPID1);
     121#endif
     122
     123#if NUM_VRID_UDP6_CEPS >= 2
     124VRID_UDP6_CEP (UDP6_RSV_CEPID2);
     125#endif
     126
     127#endif  /* of #ifdef SUPPORT_INET6 */
     128
    117129#ifdef SUPPORT_INET4
    118130
    119 #if NUM_VRID_UDP_CEPS >= 1
    120 VRID_UDP_CEP (UDP_RSV_CEPID1);
     131#if NUM_VRID_UDP4_CEPS >= 1
     132VRID_UDP_CEP (UDP4_RSV_CEPID1);
    121133#endif
    122134
    123 #if NUM_VRID_UDP_CEPS >= 2
    124 VRID_UDP_CEP (UDP_RSV_CEPID2);
     135#if NUM_VRID_UDP4_CEPS >= 2
     136VRID_UDP_CEP (UDP4_RSV_CEPID2);
    125137#endif
    126138
    127139#endif  /* of #ifdef SUPPORT_INET4 */
    128140
    129 #ifdef SUPPORT_INET6
    130 
    131 #if NUM_VRID_UDP_CEPS >= 1
    132 VRID_UDP6_CEP (UDP_RSV_CEPID1);
    133 #endif
    134 
    135 #if NUM_VRID_UDP_CEPS >= 2
    136 VRID_UDP6_CEP (UDP_RSV_CEPID2);
    137 #endif
    138 
    139 #endif  /* of #ifdef SUPPORT_INET6 */
    140 
    141141#endif  /* of #ifdef USE_UDP_EXTENTIONS */
    142142
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_net_cons.cfg

    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 *
     
    4141/* TCP 受付口 */
    4242
     43#ifdef SUPPORT_INET6
     44
     45TCP6_CRE_REP (NET_CONS_REPID, {
     46        0,
     47        { IPV6_ADDRANY, 23 }
     48        } );
     49
     50#else   /* of #ifdef SUPPORT_INET6 */
     51
    4352#ifdef SUPPORT_INET4
    4453
     
    5059#endif  /* of #ifdef SUPPORT_INET4 */
    5160
    52 #ifdef SUPPORT_INET6
    53 
    54 TCP6_CRE_REP (NET_CONS_REPID, {
    55         0,
    56         { IPV6_ADDRANY, 23 }
    57         } );
    58 
    5961#endif  /* of #ifdef SUPPORT_INET6 */
    6062
    6163/* TCP 通信端点 */
     64
     65#ifdef SUPPORT_INET6
     66
     67#ifdef TCP_CFG_SWBUF_CSAVE
     68
     69TCP6_CRE_CEP (NET_CONS_CEPID, {
     70        0,
     71        NADR,
     72        NET_CONS_SWBUF_SIZE,
     73        NADR,
     74        NET_CONS_RWBUF_SIZE,
     75        callback_nblk_net_cons
     76        } );
     77
     78#else   /* of #ifdef TCP_CFG_SWBUF_CSAVE */
     79
     80TCP6_CRE_CEP (NET_CONS_CEPID, {
     81        0,
     82        net_cons_swbuf,
     83        NET_CONS_SWBUF_SIZE,
     84        net_cons_rwbuf,
     85        NET_CONS_RWBUF_SIZE,
     86        callback_nblk_net_cons
     87        } );
     88
     89#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
     90
     91#else   /* of #ifdef SUPPORT_INET6 */
    6292
    6393#ifdef SUPPORT_INET4
     
    89119#endif  /* of #ifdef SUPPORT_INET4 */
    90120
    91 #ifdef SUPPORT_INET6
    92 
    93 #ifdef TCP_CFG_SWBUF_CSAVE
    94 
    95 TCP6_CRE_CEP (NET_CONS_CEPID, {
    96         0,
    97         NADR,
    98         NET_CONS_SWBUF_SIZE,
    99         NADR,
    100         NET_CONS_RWBUF_SIZE,
    101         callback_nblk_net_cons
    102         } );
    103 
    104 #else   /* of #ifdef TCP_CFG_SWBUF_CSAVE */
    105 
    106 TCP6_CRE_CEP (NET_CONS_CEPID, {
    107         0,
    108         net_cons_swbuf,
    109         NET_CONS_SWBUF_SIZE,
    110         net_cons_rwbuf,
    111         NET_CONS_RWBUF_SIZE,
    112         callback_nblk_net_cons
    113         } );
    114 
    115 #endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
    116 
    117121#endif  /* of #ifdef SUPPORT_INET6 */
    118122
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_cli.cfg

    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 *
     
    4343/* TCP 通信端点 */
    4444
     45#ifdef SUPPORT_INET6
     46
     47#ifdef USE_TCP_NON_BLOCKING
     48
     49#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
     50
     51TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
     52        TA_NULL,
     53        NADR,
     54        TCP_DISCARD_CLI_SWBUF_SIZE,
     55        NADR,
     56        0,
     57        callback_nblk_tcp_discard_cli
     58        } );
     59
     60#else   /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
     61
     62TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
     63        TA_NULL,
     64        tcp_discard_cli_swbuf,
     65        TCP_DISCARD_CLI_SWBUF_SIZE,
     66        NADR,
     67        0,
     68        callback_nblk_tcp_discard_cli
     69        } );
     70
     71#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
     72
     73#else   /* of #ifdef USE_TCP_NON_BLOCKING */
     74
     75#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
     76
     77TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
     78        TA_NULL,
     79        NADR,
     80        TCP_DISCARD_CLI_SWBUF_SIZE,
     81        NADR,
     82        0,
     83        NULL
     84        } );
     85
     86#else   /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
     87
     88TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
     89        TA_NULL,
     90        tcp_discard_cli_swbuf,
     91        TCP_DISCARD_CLI_SWBUF_SIZE,
     92        NADR,
     93        0,
     94        NULL
     95        } );
     96
     97#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
     98
     99#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
     100
     101#else   /* of #ifdef SUPPORT_INET6 */
     102
    45103#ifdef SUPPORT_INET4
    46104
     
    50108
    51109TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    52         0,
     110        TA_NULL,
    53111        NADR,
    54112        TCP_DISCARD_CLI_SWBUF_SIZE,
     
    61119
    62120TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    63         0,
     121        TA_NULL,
    64122        tcp_discard_cli_swbuf,
    65123        TCP_DISCARD_CLI_SWBUF_SIZE,
     
    76134
    77135TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    78         0,
     136        TA_NULL,
    79137        NADR,
    80138        TCP_DISCARD_CLI_SWBUF_SIZE,
     
    87145
    88146TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    89         0,
     147        TA_NULL,
    90148        tcp_discard_cli_swbuf,
    91149        TCP_DISCARD_CLI_SWBUF_SIZE,
     
    101159#endif  /* of #ifdef SUPPORT_INET4 */
    102160
    103 #ifdef SUPPORT_INET6
    104 
    105 #ifdef USE_TCP_NON_BLOCKING
    106 
    107 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY
    108 
    109 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    110         0,
    111         NADR,
    112         TCP_DISCARD_CLI_SWBUF_SIZE,
    113         NADR,
    114         0,
    115         callback_nblk_tcp_discard_cli
    116         } );
    117 
    118 #else   /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
    119 
    120 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    121         0,
    122         tcp_discard_cli_swbuf,
    123         TCP_DISCARD_CLI_SWBUF_SIZE,
    124         NADR,
    125         0,
    126         callback_nblk_tcp_discard_cli
    127         } );
    128 
    129 #endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
    130 
    131 #else   /* of #ifdef USE_TCP_NON_BLOCKING */
    132 
    133 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY
    134 
    135 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    136         0,
    137         NADR,
    138         TCP_DISCARD_CLI_SWBUF_SIZE,
    139         NADR,
    140         0,
    141         NULL
    142         } );
    143 
    144 #else   /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
    145 
    146 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
    147         0,
    148         tcp_discard_cli_swbuf,
    149         TCP_DISCARD_CLI_SWBUF_SIZE,
    150         NADR,
    151         0,
    152         NULL
    153         } );
    154 
    155 #endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
    156 
    157 #endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    158 
    159161#endif  /* of #ifdef SUPPORT_INET6 */
    160162
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_srv.cfg

    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 *
     
    4242/* TCP 受付口 */
    4343
     44#ifdef SUPPORT_INET6
     45
     46TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {
     47        TA_NULL,
     48        { IPV6_ADDRANY, 9 }
     49        } );
     50
     51#else   /* of #ifdef SUPPORT_INET6 */
     52
    4453#ifdef SUPPORT_INET4
    4554
    4655TCP_CRE_REP (TCP_DISCARD_SRV_REPID, {
    47         0,
     56        TA_NULL,
    4857        { IPV4_ADDRANY, 9 }
    4958        } );
     
    5160#endif  /* of #ifdef SUPPORT_INET4 */
    5261
    53 #ifdef SUPPORT_INET6
    54 
    55 TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {
    56         0,
    57         { IPV6_ADDRANY, 9 }
    58         } );
    59 
    6062#endif  /* of #ifdef SUPPORT_INET6 */
    6163
    6264/* TCP 通信端点 */
     65
     66#ifdef SUPPORT_INET6
     67
     68#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
     69
     70TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
     71        TA_NULL,
     72        NADR,
     73        0,
     74        NADR,
     75        TCP_DISCARD_SRV_RWBUF_SIZE,
     76        NULL
     77        } );
     78
     79#else   /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
     80
     81TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
     82        TA_NULL,
     83        NADR,
     84        0,
     85        tcp_discard_srv_rwbuf,
     86        TCP_DISCARD_SRV_RWBUF_SIZE,
     87        NULL
     88        } );
     89
     90#endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
     91
     92#else   /* of #ifdef SUPPORT_INET6 */
    6393
    6494#ifdef SUPPORT_INET4
     
    6797
    6898TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
    69         0,
     99        TA_NULL,
    70100        NADR,
    71101        0,
     
    78108
    79109TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
    80         0,
     110        TA_NULL,
    81111        NADR,
    82112        0,
     
    90120#endif  /* of #ifdef SUPPORT_INET4 */
    91121
    92 #ifdef SUPPORT_INET6
    93 
    94 #ifdef TCP_CFG_RWBUF_CSAVE_ONLY
    95 
    96 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
    97         0,
    98         NADR,
    99         0,
    100         NADR,
    101         TCP_DISCARD_SRV_RWBUF_SIZE,
    102         NULL
    103         } );
    104 
    105 #else   /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
    106 
    107 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
    108         0,
    109         NADR,
    110         0,
    111         tcp_discard_srv_rwbuf,
    112         TCP_DISCARD_SRV_RWBUF_SIZE,
    113         NULL
    114         } );
    115 
    116 #endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
    117 
    118122#endif  /* of #ifdef SUPPORT_INET6 */
    119123
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_cli.cfg

    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 *
     
    4343/* TCP 通信端点 */
    4444
     45#ifdef SUPPORT_INET6
     46
     47#ifdef USE_TCP_NON_BLOCKING
     48
     49#if defined(TCP_CFG_SWBUF_CSAVE)
     50
     51#if defined(TCP_CFG_RWBUF_CSAVE)
     52
     53TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     54        0,
     55        NADR,
     56        TCP_ECHO_CLI_SWBUF_SIZE,
     57        NADR,
     58        TCP_ECHO_CLI_RWBUF_SIZE,
     59        callback_nblk_tcp_echo_cli
     60        } );
     61
     62#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     63
     64TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     65        0,
     66        NADR,
     67        TCP_ECHO_CLI_SWBUF_SIZE,
     68        tcp_echo_cli_rwbuf,
     69        TCP_ECHO_CLI_RWBUF_SIZE,
     70        callback_nblk_tcp_echo_cli
     71        } );
     72
     73#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     74
     75#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     76
     77#if defined(TCP_CFG_RWBUF_CSAVE)
     78
     79TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     80        0,
     81        tcp_echo_cli_swbuf,
     82        TCP_ECHO_CLI_SWBUF_SIZE,
     83        NADR,
     84        TCP_ECHO_CLI_RWBUF_SIZE,
     85        callback_nblk_tcp_echo_cli
     86        } );
     87
     88#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     89
     90TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     91        0,
     92        tcp_echo_cli_swbuf,
     93        TCP_ECHO_CLI_SWBUF_SIZE,
     94        tcp_echo_cli_rwbuf,
     95        TCP_ECHO_CLI_RWBUF_SIZE,
     96        callback_nblk_tcp_echo_cli
     97        } );
     98
     99#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     100
     101#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     102
     103#else   /* of #ifdef USE_TCP_NON_BLOCKING */
     104
     105#if defined(TCP_CFG_SWBUF_CSAVE)
     106
     107#if defined(TCP_CFG_RWBUF_CSAVE)
     108
     109TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     110        0,
     111        NADR,
     112        TCP_ECHO_CLI_SWBUF_SIZE,
     113        NADR,
     114        TCP_ECHO_CLI_RWBUF_SIZE,
     115        NULL
     116        } );
     117
     118#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     119
     120TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     121        0,
     122        NADR,
     123        TCP_ECHO_CLI_SWBUF_SIZE,
     124        tcp_echo_cli_rwbuf,
     125        TCP_ECHO_CLI_RWBUF_SIZE,
     126        NULL
     127        } );
     128
     129#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     130
     131#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     132
     133#if defined(TCP_CFG_RWBUF_CSAVE)
     134
     135TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     136        0,
     137        tcp_echo_cli_swbuf,
     138        TCP_ECHO_CLI_SWBUF_SIZE,
     139        NADR,
     140        TCP_ECHO_CLI_RWBUF_SIZE,
     141        NULL
     142        } );
     143
     144#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     145
     146TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     147        0,
     148        tcp_echo_cli_swbuf,
     149        TCP_ECHO_CLI_SWBUF_SIZE,
     150        tcp_echo_cli_rwbuf,
     151        TCP_ECHO_CLI_RWBUF_SIZE,
     152        NULL
     153        } );
     154
     155#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     156
     157#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     158
     159#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
     160
    45161#ifdef SUPPORT_INET4
    46162
     163#ifdef USE_TCP4_ECHO_CLI
     164
    47165#ifdef USE_TCP_NON_BLOCKING
    48166
     
    51169#if defined(TCP_CFG_RWBUF_CSAVE)
    52170
    53 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    54         0,
    55         NADR,
    56         TCP_ECHO_CLI_SWBUF_SIZE,
    57         NADR,
    58         TCP_ECHO_CLI_RWBUF_SIZE,
    59         callback_nblk_tcp_echo_cli
    60         } );
    61 
    62 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    63 
    64 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    65         0,
    66         NADR,
    67         TCP_ECHO_CLI_SWBUF_SIZE,
    68         tcp_echo_cli_rwbuf,
    69         TCP_ECHO_CLI_RWBUF_SIZE,
    70         callback_nblk_tcp_echo_cli
    71         } );
    72 
    73 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    74 
    75 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    76 
    77 #if defined(TCP_CFG_RWBUF_CSAVE)
    78 
    79 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    80         0,
    81         tcp_echo_cli_swbuf,
    82         TCP_ECHO_CLI_SWBUF_SIZE,
    83         NADR,
    84         TCP_ECHO_CLI_RWBUF_SIZE,
    85         callback_nblk_tcp_echo_cli
    86         } );
    87 
    88 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    89 
    90 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     171TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     172        0,
     173        NADR,
     174        TCP_ECHO_CLI_SWBUF_SIZE,
     175        NADR,
     176        TCP_ECHO_CLI_RWBUF_SIZE,
     177        callback_nblk_tcp_echo_cli
     178        } );
     179
     180#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     181
     182TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     183        0,
     184        NADR,
     185        TCP_ECHO_CLI_SWBUF_SIZE,
     186        tcp_echo_cli_rwbuf,
     187        TCP_ECHO_CLI_RWBUF_SIZE,
     188        callback_nblk_tcp_echo_cli
     189        } );
     190
     191#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     192
     193#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     194
     195#if defined(TCP_CFG_RWBUF_CSAVE)
     196
     197TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     198        0,
     199        tcp_echo_cli_swbuf,
     200        TCP_ECHO_CLI_SWBUF_SIZE,
     201        NADR,
     202        TCP_ECHO_CLI_RWBUF_SIZE,
     203        callback_nblk_tcp_echo_cli
     204        } );
     205
     206#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     207
     208TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
    91209        0,
    92210        tcp_echo_cli_swbuf,
     
    107225#if defined(TCP_CFG_RWBUF_CSAVE)
    108226
    109 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    110         0,
    111         NADR,
    112         TCP_ECHO_CLI_SWBUF_SIZE,
    113         NADR,
    114         TCP_ECHO_CLI_RWBUF_SIZE,
    115         NULL
    116         } );
    117 
    118 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    119 
    120 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    121         0,
    122         NADR,
    123         TCP_ECHO_CLI_SWBUF_SIZE,
    124         tcp_echo_cli_rwbuf,
    125         TCP_ECHO_CLI_RWBUF_SIZE,
    126         NULL
    127         } );
    128 
    129 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    130 
    131 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    132 
    133 #if defined(TCP_CFG_RWBUF_CSAVE)
    134 
    135 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    136         0,
    137         tcp_echo_cli_swbuf,
    138         TCP_ECHO_CLI_SWBUF_SIZE,
    139         NADR,
    140         TCP_ECHO_CLI_RWBUF_SIZE,
    141         NULL
    142         } );
    143 
    144 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    145 
    146 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     227TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     228        0,
     229        NADR,
     230        TCP_ECHO_CLI_SWBUF_SIZE,
     231        NADR,
     232        TCP_ECHO_CLI_RWBUF_SIZE,
     233        NULL
     234        } );
     235
     236#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     237
     238TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     239        0,
     240        NADR,
     241        TCP_ECHO_CLI_SWBUF_SIZE,
     242        tcp_echo_cli_rwbuf,
     243        TCP_ECHO_CLI_RWBUF_SIZE,
     244        NULL
     245        } );
     246
     247#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     248
     249#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     250
     251#if defined(TCP_CFG_RWBUF_CSAVE)
     252
     253TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
     254        0,
     255        tcp_echo_cli_swbuf,
     256        TCP_ECHO_CLI_SWBUF_SIZE,
     257        NADR,
     258        TCP_ECHO_CLI_RWBUF_SIZE,
     259        NULL
     260        } );
     261
     262#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     263
     264TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
    147265        0,
    148266        tcp_echo_cli_swbuf,
     
    159277#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    160278
     279#endif  /* of #ifdef USE_TCP4_ECHO_CLI */
     280
    161281#endif  /* of #ifdef SUPPORT_INET4 */
    162282
    163 #ifdef SUPPORT_INET6
     283#else   /* of #ifdef SUPPORT_INET6 */
     284
     285#ifdef SUPPORT_INET4
    164286
    165287#ifdef USE_TCP_NON_BLOCKING
     
    169291#if defined(TCP_CFG_RWBUF_CSAVE)
    170292
    171 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    172         0,
    173         NADR,
    174         TCP_ECHO_CLI_SWBUF_SIZE,
    175         NADR,
    176         TCP_ECHO_CLI_RWBUF_SIZE,
    177         callback_nblk_tcp_echo_cli
    178         } );
    179 
    180 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    181 
    182 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    183         0,
    184         NADR,
    185         TCP_ECHO_CLI_SWBUF_SIZE,
    186         tcp_echo_cli_rwbuf,
    187         TCP_ECHO_CLI_RWBUF_SIZE,
    188         callback_nblk_tcp_echo_cli
    189         } );
    190 
    191 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    192 
    193 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    194 
    195 #if defined(TCP_CFG_RWBUF_CSAVE)
    196 
    197 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    198         0,
    199         tcp_echo_cli_swbuf,
    200         TCP_ECHO_CLI_SWBUF_SIZE,
    201         NADR,
    202         TCP_ECHO_CLI_RWBUF_SIZE,
    203         callback_nblk_tcp_echo_cli
    204         } );
    205 
    206 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    207 
    208 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     293TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     294        0,
     295        NADR,
     296        TCP_ECHO_CLI_SWBUF_SIZE,
     297        NADR,
     298        TCP_ECHO_CLI_RWBUF_SIZE,
     299        callback_nblk_tcp_echo_cli
     300        } );
     301
     302#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     303
     304TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     305        0,
     306        NADR,
     307        TCP_ECHO_CLI_SWBUF_SIZE,
     308        tcp_echo_cli_rwbuf,
     309        TCP_ECHO_CLI_RWBUF_SIZE,
     310        callback_nblk_tcp_echo_cli
     311        } );
     312
     313#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     314
     315#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     316
     317#if defined(TCP_CFG_RWBUF_CSAVE)
     318
     319TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     320        0,
     321        tcp_echo_cli_swbuf,
     322        TCP_ECHO_CLI_SWBUF_SIZE,
     323        NADR,
     324        TCP_ECHO_CLI_RWBUF_SIZE,
     325        callback_nblk_tcp_echo_cli
     326        } );
     327
     328#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     329
     330TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    209331        0,
    210332        tcp_echo_cli_swbuf,
     
    225347#if defined(TCP_CFG_RWBUF_CSAVE)
    226348
    227 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    228         0,
    229         NADR,
    230         TCP_ECHO_CLI_SWBUF_SIZE,
    231         NADR,
    232         TCP_ECHO_CLI_RWBUF_SIZE,
    233         NULL
    234         } );
    235 
    236 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    237 
    238 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    239         0,
    240         NADR,
    241         TCP_ECHO_CLI_SWBUF_SIZE,
    242         tcp_echo_cli_rwbuf,
    243         TCP_ECHO_CLI_RWBUF_SIZE,
    244         NULL
    245         } );
    246 
    247 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    248 
    249 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    250 
    251 #if defined(TCP_CFG_RWBUF_CSAVE)
    252 
    253 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    254         0,
    255         tcp_echo_cli_swbuf,
    256         TCP_ECHO_CLI_SWBUF_SIZE,
    257         NADR,
    258         TCP_ECHO_CLI_RWBUF_SIZE,
    259         NULL
    260         } );
    261 
    262 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    263 
    264 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     349TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     350        0,
     351        NADR,
     352        TCP_ECHO_CLI_SWBUF_SIZE,
     353        NADR,
     354        TCP_ECHO_CLI_RWBUF_SIZE,
     355        NULL
     356        } );
     357
     358#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     359
     360TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     361        0,
     362        NADR,
     363        TCP_ECHO_CLI_SWBUF_SIZE,
     364        tcp_echo_cli_rwbuf,
     365        TCP_ECHO_CLI_RWBUF_SIZE,
     366        NULL
     367        } );
     368
     369#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     370
     371#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     372
     373#if defined(TCP_CFG_RWBUF_CSAVE)
     374
     375TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
     376        0,
     377        tcp_echo_cli_swbuf,
     378        TCP_ECHO_CLI_SWBUF_SIZE,
     379        NADR,
     380        TCP_ECHO_CLI_RWBUF_SIZE,
     381        NULL
     382        } );
     383
     384#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     385
     386TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
    265387        0,
    266388        tcp_echo_cli_swbuf,
     
    277399#endif  /* of #ifdef USE_TCP_NON_BLOCKING */
    278400
     401#endif  /* of #ifdef SUPPORT_INET4 */
     402
    279403#endif  /* of #ifdef SUPPORT_INET6 */
    280404
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_discard_cli.cfg

    r321 r331  
    22 *  TINET (UDP/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 *
     
    4343/* UDP 通信端点 */
    4444
     45#ifdef SUPPORT_INET6
     46
     47UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, {
     48        0,
     49        { IPV6_ADDRANY, UDP_PORTANY },
     50        NULL
     51        } );
     52
     53#else   /* of #ifdef SUPPORT_INET6 */
     54
    4555#ifdef SUPPORT_INET4
    4656
     
    5363#endif  /* of #ifdef SUPPORT_INET4 */
    5464
    55 #ifdef SUPPORT_INET6
    56 
    57 UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, {
    58         0,
    59         { IPV6_ADDRANY, UDP_PORTANY },
    60         NULL
    61         } );
    62 
    6365#endif  /* of #ifdef SUPPORT_INET6 */
    6466
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_wwws.cfg

    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 *
     
    3434/*
    3535 *  WWW サーバの TCP/IP コンフィギュレーションファイル
     36 *
     37 *    SUPPORT_INET6
     38 *    SUPPORT_INET4
     39 *    USE_TCP_NON_BLOCKING: OFF
     40 *    USE_TCP_EXTENTIONS:   OFF
     41 *    TCP 受付口
     42 *    TCP 通信端点
     43 *
    3644 */
    3745
    38 #ifdef USE_WWW_SRV
    39 
    40 #ifndef USE_TCP_EXTENTIONS
    41 
    42 /* TCP 受付口 */
    43 
    44 #ifdef SUPPORT_INET4
     46#if defined(USE_WWW_SRV)
     47
     48/*
     49 * TCP 受付口
     50 */
     51
     52#if defined(USE_TCP_EXTENTIONS)
     53
     54#else   /* of #if defined(USE_TCP_EXTENTIONS) */
     55
     56#if defined(SUPPORT_INET6)
     57
     58TCP6_CRE_REP (WWW_SRV_REPID, {
     59        0,
     60        { IPV6_ADDRANY, 80 }
     61        } );
     62
     63#if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     64
     65TCP_CRE_REP (WWW4_SRV_REPID, {
     66        0,
     67        { IPV4_ADDRANY, 80 }
     68        } );
     69
     70#endif  /* of #if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     71
     72#else   /* of #if defined(SUPPORT_INET6 */
     73
     74#if defined(SUPPORT_INET4)
    4575
    4676TCP_CRE_REP (WWW_SRV_REPID, {
     
    4979        } );
    5080
    51 #endif  /* of #ifdef SUPPORT_INET4 */
    52 
    53 #ifdef SUPPORT_INET6
    54 
    55 TCP6_CRE_REP (WWW_SRV_REPID, {
    56         0,
    57         { IPV6_ADDRANY, 80 }
    58         } );
    59 
    60 #endif  /* of #ifdef SUPPORT_INET6 */
    61 
    62 /* TCP 通信端点 */
    63 
    64 #ifdef SUPPORT_INET4
     81#endif  /* of #if defined(SUPPORT_INET4 */
     82
     83#endif  /* of #if defined(SUPPORT_INET6 */
     84
     85#endif  /* of #if defined(USE_TCP_EXTENTIONS */
     86
     87/*
     88 * TCP 通信端点
     89 *
     90 * 定義する TCP 通信端点(WWW?_CEPID1)の選択
     91 *
     92 *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
     93 *     ○    ○     ○          ×         WWW4
     94 *     ○    ○     ×          WWW        ×
     95 *     ○    ×     ○          WWW        ×
     96 *     ○    ×     ×          WWW        ×
     97 *     ×    ○     ○          ×         WWW
     98 *     ×    ○     ×          ×         WWW
     99 *     ×    ×     ○          ×         ×
     100 *     ×    ×     ×          ×         ×
     101 *
     102 */
     103
     104#if defined(USE_TCP_EXTENTIONS)
     105
     106#else   /* of #if defined(USE_TCP_EXTENTIONS */
     107
     108#if defined(SUPPORT_INET6)
     109
     110#if defined(SUPPORT_INET4)
     111
     112#if defined(USE_WWW4_SRV)
     113
     114#if defined(TCP_CFG_SWBUF_CSAVE)
     115
     116#if defined(TCP_CFG_RWBUF_CSAVE)
     117
     118TCP_CRE_CEP (WWW4_SRV_CEPID1, {
     119        0,
     120        NADR,
     121        WWW_SRV_SWBUF_SIZE,
     122        NADR,
     123        WWW_SRV_RWBUF_SIZE,
     124        NULL
     125        } );
     126
     127#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     128
     129TCP_CRE_CEP (WWW4_SRV_CEPID1, {
     130        0,
     131        NADR,
     132        WWW_SRV_SWBUF_SIZE,
     133        www_srv_rwbuf[0],
     134        WWW_SRV_RWBUF_SIZE,
     135        NULL
     136        } );
     137
     138#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     139
     140#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     141
     142#if defined(TCP_CFG_RWBUF_CSAVE)
     143
     144TCP_CRE_CEP (WWW4_SRV_CEPID1, {
     145        0,
     146        www_srv_swbuf[0],
     147        WWW_SRV_SWBUF_SIZE,
     148        NADR,
     149        WWW_SRV_RWBUF_SIZE,
     150        NULL
     151        } );
     152
     153#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     154
     155TCP_CRE_CEP (WWW4_SRV_CEPID1, {
     156        0,
     157        www_srv_swbuf[0],
     158        WWW_SRV_SWBUF_SIZE,
     159        www_srv_rwbuf[0],
     160        WWW_SRV_RWBUF_SIZE,
     161        NULL
     162        } );
     163
     164#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     165
     166#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     167
     168#else   /* of #if defined(USE_WWW4_SRV) */
     169
     170#if defined(TCP_CFG_SWBUF_CSAVE)
     171
     172#if defined(TCP_CFG_RWBUF_CSAVE)
     173
     174TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     175        0,
     176        NADR,
     177        WWW_SRV_SWBUF_SIZE,
     178        NADR,
     179        WWW_SRV_RWBUF_SIZE,
     180        NULL
     181        } );
     182
     183#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     184
     185TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     186        0,
     187        NADR,
     188        WWW_SRV_SWBUF_SIZE,
     189        www_srv_rwbuf[0],
     190        WWW_SRV_RWBUF_SIZE,
     191        NULL
     192        } );
     193
     194#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     195
     196#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     197
     198#if defined(TCP_CFG_RWBUF_CSAVE)
     199
     200TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     201        0,
     202        www_srv_swbuf[0],
     203        WWW_SRV_SWBUF_SIZE,
     204        NADR,
     205        WWW_SRV_RWBUF_SIZE,
     206        NULL
     207        } );
     208
     209#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     210
     211TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     212        0,
     213        www_srv_swbuf[0],
     214        WWW_SRV_SWBUF_SIZE,
     215        www_srv_rwbuf[0],
     216        WWW_SRV_RWBUF_SIZE,
     217        NULL
     218        } );
     219
     220#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     221
     222#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     223
     224#endif  /* of #if defined(USE_WWW4_SRV) */
     225
     226#else   /* of #if defined(SUPPORT_INET4 */
     227
     228#if defined(TCP_CFG_SWBUF_CSAVE)
     229
     230#if defined(TCP_CFG_RWBUF_CSAVE)
     231
     232TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     233        0,
     234        NADR,
     235        WWW_SRV_SWBUF_SIZE,
     236        NADR,
     237        WWW_SRV_RWBUF_SIZE,
     238        NULL
     239        } );
     240
     241#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     242
     243TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     244        0,
     245        NADR,
     246        WWW_SRV_SWBUF_SIZE,
     247        www_srv_rwbuf[0],
     248        WWW_SRV_RWBUF_SIZE,
     249        NULL
     250        } );
     251
     252#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     253
     254#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     255
     256#if defined(TCP_CFG_RWBUF_CSAVE)
     257
     258TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     259        0,
     260        www_srv_swbuf[0],
     261        WWW_SRV_SWBUF_SIZE,
     262        NADR,
     263        WWW_SRV_RWBUF_SIZE,
     264        NULL
     265        } );
     266
     267#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     268
     269TCP6_CRE_CEP (WWW_SRV_CEPID1, {
     270        0,
     271        www_srv_swbuf[0],
     272        WWW_SRV_SWBUF_SIZE,
     273        www_srv_rwbuf[0],
     274        WWW_SRV_RWBUF_SIZE,
     275        NULL
     276        } );
     277
     278#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     279
     280#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     281
     282#endif  /* of #if defined(SUPPORT_INET4 */
     283
     284#if NUM_WWW_SRV_TASKS >= 2
     285
     286#if defined(TCP_CFG_SWBUF_CSAVE)
     287
     288#if defined(TCP_CFG_RWBUF_CSAVE)
     289
     290TCP6_CRE_CEP (WWW_SRV_CEPID2, {
     291        0,
     292        NADR,
     293        WWW_SRV_SWBUF_SIZE,
     294        NADR,
     295        WWW_SRV_RWBUF_SIZE,
     296        NULL
     297        } );
     298
     299#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     300
     301TCP6_CRE_CEP (WWW_SRV_CEPID2, {
     302        0,
     303        NADR,
     304        WWW_SRV_SWBUF_SIZE,
     305        www_srv_rwbuf[1],
     306        WWW_SRV_RWBUF_SIZE,
     307        NULL
     308        } );
     309
     310#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     311
     312#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     313
     314#if defined(TCP_CFG_RWBUF_CSAVE)
     315
     316TCP6_CRE_CEP (WWW_SRV_CEPID2, {
     317        0,
     318        www_srv_swbuf[1],
     319        WWW_SRV_SWBUF_SIZE,
     320        NADR,
     321        WWW_SRV_RWBUF_SIZE,
     322        NULL
     323        } );
     324
     325#else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     326
     327TCP6_CRE_CEP (WWW_SRV_CEPID2, {
     328        0,
     329        www_srv_swbuf[1],
     330        WWW_SRV_SWBUF_SIZE,
     331        www_srv_rwbuf[1],
     332        WWW_SRV_RWBUF_SIZE,
     333        NULL
     334        } );
     335
     336#endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
     337
     338#endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
     339
     340#endif  /* of #if NUM_WWW_SRV_TASKS >= 2 */
     341
     342#elif defined(SUPPORT_INET4)    /* of #if defined(SUPPORT_INET6) */
    65343
    66344#if defined(TCP_CFG_SWBUF_CSAVE)
     
    176454#endif  /* of #if NUM_WWW_SRV_TASKS >= 2 */
    177455
    178 #endif  /* of #ifdef SUPPORT_INET4 */
    179 
    180 #ifdef SUPPORT_INET6
    181 
    182 #if defined(TCP_CFG_SWBUF_CSAVE)
    183 
    184 #if defined(TCP_CFG_RWBUF_CSAVE)
    185 
    186 TCP6_CRE_CEP (WWW_SRV_CEPID1, {
    187         0,
    188         NADR,
    189         WWW_SRV_SWBUF_SIZE,
    190         NADR,
    191         WWW_SRV_RWBUF_SIZE,
    192         NULL
    193         } );
    194 
    195 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    196 
    197 TCP6_CRE_CEP (WWW_SRV_CEPID1, {
    198         0,
    199         NADR,
    200         WWW_SRV_SWBUF_SIZE,
    201         www_srv_rwbuf[0],
    202         WWW_SRV_RWBUF_SIZE,
    203         NULL
    204         } );
    205 
    206 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    207 
    208 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    209 
    210 #if defined(TCP_CFG_RWBUF_CSAVE)
    211 
    212 TCP6_CRE_CEP (WWW_SRV_CEPID1, {
    213         0,
    214         www_srv_swbuf[0],
    215         WWW_SRV_SWBUF_SIZE,
    216         NADR,
    217         WWW_SRV_RWBUF_SIZE,
    218         NULL
    219         } );
    220 
    221 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    222 
    223 TCP6_CRE_CEP (WWW_SRV_CEPID1, {
    224         0,
    225         www_srv_swbuf[0],
    226         WWW_SRV_SWBUF_SIZE,
    227         www_srv_rwbuf[0],
    228         WWW_SRV_RWBUF_SIZE,
    229         NULL
    230         } );
    231 
    232 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    233 
    234 #endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    235 
    236 #if NUM_WWW_SRV_TASKS >= 2
    237 
    238 #if defined(TCP_CFG_SWBUF_CSAVE)
    239 
    240 #if defined(TCP_CFG_RWBUF_CSAVE)
    241 
    242 TCP6_CRE_CEP (WWW_SRV_CEPID2, {
    243         0,
    244         NADR,
    245         WWW_SRV_SWBUF_SIZE,
    246         NADR,
    247         WWW_SRV_RWBUF_SIZE,
    248         NULL
    249         } );
    250 
    251 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    252 
    253 TCP6_CRE_CEP (WWW_SRV_CEPID2, {
    254         0,
    255         NADR,
    256         WWW_SRV_SWBUF_SIZE,
    257         www_srv_rwbuf[1],
    258         WWW_SRV_RWBUF_SIZE,
    259         NULL
    260         } );
    261 
    262 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    263 
    264 #else   /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    265 
    266 #if defined(TCP_CFG_RWBUF_CSAVE)
    267 
    268 TCP6_CRE_CEP (WWW_SRV_CEPID2, {
    269         0,
    270         www_srv_swbuf[1],
    271         WWW_SRV_SWBUF_SIZE,
    272         NADR,
    273         WWW_SRV_RWBUF_SIZE,
    274         NULL
    275         } );
    276 
    277 #else   /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    278 
    279 TCP6_CRE_CEP (WWW_SRV_CEPID2, {
    280         0,
    281         www_srv_swbuf[1],
    282         WWW_SRV_SWBUF_SIZE,
    283         www_srv_rwbuf[1],
    284         WWW_SRV_RWBUF_SIZE,
    285         NULL
    286         } );
    287 
    288 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) */
    289 
    290 #endif  /* of #if defined(TCP_CFG_SWBUF_CSAVE) */
    291 
    292 #endif  /* of #if NUM_WWW_SRV_TASKS >= 2 */
    293 
    294 #endif  /* of #ifdef SUPPORT_INET6 */
    295 
    296 #endif  /* of #ifndef USE_TCP_EXTENTIONS */
    297 
    298 #endif  /* of #ifdef USE_WWW_SRV */
     456#endif  /* of #if defined(SUPPORT_INET6) */
     457
     458#endif  /* of #if defined(USE_TCP_EXTENTIONS) */
     459
     460#endif  /* of #if defined(USE_WWW_SRV) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.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 *
     
    5656#endif  /* of #ifdef TARGET_KERNEL_JSP */
    5757
    58 #include <tinet_defs.h>
    59 #include <tinet_config.h>
    60 
    61 #include <net/if.h>
    62 #include <net/if_ppp.h>
    63 #include <net/if_loop.h>
    64 #include <net/ethernet.h>
    65 #include <net/net.h>
    66 #include <net/net_var.h>
    67 #include <net/net_timer.h>
    68 
    6958#include <netinet/in.h>
     59#include <netinet/in_itron.h>
    7060#include <netinet/ip.h>
    71 #include <netinet/ip6.h>
    7261#include <netinet/udp.h>
    73 #include <netinet/udp_var.h>
    74 #include <netinet/in_itron.h>
    7562
    7663#include <netapp/netapp.h>
    7764#include <netapp/netapp_var.h>
    78 #include <netapp/discard.h>
     65#include <netapp/udp_discard_cli.h>
    7966
    8067#ifdef USE_UDP_DISCARD_CLI
     
    9077#define PAT_BEGIN       ' '
    9178#define PAT_END         '~'
     79
     80#if defined(SUPPORT_INET6)
     81#define API_PROTO               '6'
     82#else
     83#define API_PROTO               '4'
     84#endif
    9285
    9386/*
     
    10497send_udp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
    10598{
    106         static char smsg[IF_MTU - IP_UDP_HDR_SIZE];
     99#if defined(SUPPORT_INET6)
     100        static char smsg[IPV6_MMTU - (IP6_HDR_SIZE + UDP_HDR_SIZE)];
     101#else
     102        static char smsg[IP4_MSS - (IP4_HDR_SIZE + UDP_HDR_SIZE)];
     103#endif
    107104
    108105        T_IPEP          dst;
     
    117114
    118115        p = smsg;
    119         for (slen = IF_MTU - IP_UDP_HDR_SIZE; slen > 0; )
     116        for (slen = sizeof(smsg); slen > 0; )
    120117                for (pat = PAT_BEGIN; slen > 0 && pat <= PAT_END; pat ++, slen --)
    121118                        *p ++ = pat;
    122119
    123120        get_tim(&time);
    124         syslog(LOG_NOTICE, "[UDC:%02d SND] sending:    %6ld, to:   %s.%d",
    125                            cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
     121        syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, to:   %s.%d",
     122                           API_PROTO, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    126123
    127124        scount = total = 0;
    128125        udp_discard_cli_valid = true;
    129         for (slen = IF_MTU - IP_UDP_HDR_SIZE; udp_discard_cli_valid && slen > 0; slen --) {
     126        for (slen = sizeof(smsg); udp_discard_cli_valid && slen > 0; slen --) {
    130127                scount ++;
    131128                if ((len = UDP_SND_DAT(cepid, &dst, smsg, slen, TMO_FEVR)) < 0) {
    132                         syslog(LOG_NOTICE, "[UDC:%02d SND] send error: %s", cepid, itron_strerror(len));
     129                        syslog(LOG_NOTICE, "[UDC%c:%02u SND] error: %s", API_PROTO, cepid, itron_strerror(len));
    133130                        return len;
    134131                        }
    135132                else
    136                         syslog(LOG_NOTICE, "[UDC:%02d SND] send: %4d, %4d", cepid, scount, slen);
     133                        syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, %4u", API_PROTO, cepid, scount, slen);
    137134                total += len;
    138                 dly_tsk(10 * SYSTIM_HZ + net_rand() % (10 * SYSTIM_HZ));
     135                dly_tsk(10 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
    139136                }
    140137
    141138        get_tim(&time);
    142         syslog(LOG_NOTICE, "[UDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
    143                            cepid, time / SYSTIM_HZ, scount, total);
     139        syslog(LOG_NOTICE, "[UDC%c:%02u SND] finsh: %7lu, snd: %4u,            len: %ld",
     140                           API_PROTO, cepid, time / SYSTIM_HZ, scount, total);
    144141        return E_OK;
    145142        }
     
    158155        int_t           no;
    159156        uint16_t        portno;
     157        char            apip;
    160158
    161159#ifdef USE_UDP_EXTENTIONS
    162160
     161#if defined(SUPPORT_INET6)
     162        T_UDP6_CCEP     ccep;
     163#else
    163164        T_UDP_CCEP      ccep;
     165#endif
    164166
    165167#endif  /* of #ifdef USE_UDP_EXTENTIONS */
     168
     169#if defined(SUPPORT_INET6)
     170        apip = API_PROTO_IPV6;
     171#else
     172        apip = API_PROTO_IPV4;
     173#endif
    166174
    167175        get_tid(&tskid);
     
    171179                        line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));       /* IP Address */
    172180
     181                        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
     182                                syslog(LOG_NOTICE, "[UDC%c:%02u TSK] unknown host.", (ID)exinf);
     183                                continue;
     184                                }
     185
    173186                        if ('0' <= *line && *line <= '9') {                             /* Port No */
    174187                                line = get_int(&no, line);
     
    186199                        ccep.myaddr.portno = UDP_PORTANY;
    187200
     201#if defined(SUPPORT_INET6)
     202
     203                        memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     204
     205#else   /* #if defined(SUPPORT_INET6) */
     206
    188207#if defined(SUPPORT_INET4)
    189208                        ccep.myaddr.ipaddr = IPV4_ADDRANY;
    190209#endif
    191210
    192 #if defined(SUPPORT_INET6)
    193                         memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
    194 #endif
    195 
    196                         if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) {
    197                                 syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
     211#endif  /* #if defined(SUPPORT_INET6) */
     212
     213                        if ((error = ALLOC_UDP_CEP(&cepid, tskid, &ccep)) != E_OK) {
     214                                syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP create error: %s", API_PROTO, cepid, itron_strerror(error));
    198215                                continue;
    199216                                }
     
    206223
    207224                        if ((error = send_udp_discard(cepid, &addr, portno)) != E_OK)
    208                                 syslog(LOG_NOTICE, "[UDC:%02d TSK] error: %s", cepid, itron_strerror(error));
     225                                syslog(LOG_NOTICE, "[UDC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
    209226
    210227#ifdef USE_UDP_EXTENTIONS
    211228
    212                         if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
    213                                 syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
     229                        if ((error = FREE_UDP_CEP(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
     230                                syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP delete error: %s", API_PROTO, cepid, itron_strerror(error));
    214231
    215232#endif  /* of #ifdef USE_UDP_EXTENTIONS */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.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 *
     
    7575#include <net/ethernet.h>
    7676#include <net/net.h>
     77#include <net/net_endian.h>
    7778#include <net/net_buf.h>
    78 #include <net/net_timer.h>
    7979#include <net/net_count.h>
    8080
    8181#include <netinet/in.h>
    8282#include <netinet/in_itron.h>
    83 #include <netinet/ip.h>
    84 #include <netinet/ip6.h>
    85 #include <netinet/tcp.h>
    86 
     83
     84#include <netapp/netapp.h>
    8785#include <netapp/netapp_var.h>
    8886#include <netapp/wwws.h>
     
    118116#endif  /* of #if NET_COUNT_ENABLE */
    119117
     118#ifdef USE_TCP_EXTENTIONS
     119
     120#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     121
     122#if NUM_WWW_SRV_TASKS >= 2              /* 2 を超える個数は想定していない。    */
     123
     124#define WWW4_SRV_TASK   WWW_SRV_TASK1
     125#define WWW6_SRV_TASK   WWW_SRV_TASK2
     126
     127#else   /* of #if NUM_WWW_SRV_TASKS >= 2 */
     128
     129#define WWW4_SRV_TASK   WWW_SRV_TASK1
     130#define WWW6_SRV_TASK   WWW_SRV_TASK1
     131
     132#endif  /* of #if NUM_WWW_SRV_TASKS >= 2 */
     133
     134#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     135
     136#define WWW4_SRV_TASK   WWW_SRV_TASK1
     137#define WWW6_SRV_TASK   WWW_SRV_TASK1
     138
     139#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     140
     141#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     142
     143
    120144/*
    121145 *  全域変数
     
    161185#define ST_NOT_FOUND    1
    162186
     187/*
     188 *  接続相手の情報構造体
     189 */
     190
     191#ifdef  NUM_WWW4_SRV_TASKS
     192#undef  NUM_WWW4_SRV_TASKS
     193#endif
     194#define NUM_WWW4_SRV_TASKS              1
     195
     196typedef struct t_www_srv_info {
     197        ID      cepid;          /* 通信端点 ID              */
     198        ID      repid;          /* 受付口   ID             */
     199        T_IPEP  dst;            /* 接続相手アドレス情報   */
     200        } T_WWW_SRV_INFO;
     201
     202#define INDEX_SRV_INFO(id)      ((id)-1)
     203
     204#ifdef USE_TCP_EXTENTIONS
     205
     206static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS];
     207                                        /* 2 を超える個数は想定していない。    */
     208
     209#else   /* of #ifdef USE_TCP_EXTENTIONS */
     210
     211static T_WWW_SRV_INFO www_srv_info[] = {
     212
     213#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     214
     215        { WWW4_SRV_CEPID1, WWW4_SRV_REPID },
     216
     217#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     218
     219        { WWW_SRV_CEPID1, WWW_SRV_REPID },
     220
     221#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     222
     223#if NUM_WWW_SRV_TASKS >= 2              /* 2 を超える個数は想定していない。    */
     224        { WWW_SRV_CEPID2, WWW_SRV_REPID },
     225#endif
     226
     227        };
     228
     229#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     230
    163231#ifdef USE_COPYSAVE_API
    164232
     
    180248                if (srbuf->rbuf.index >= srbuf->rbuf.len) {
    181249                        if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK)
    182                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_rel_buf error: %s",
     250                                syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s",
    183251                                       cepid, itron_strerror(error));
    184252                        srbuf->rbuf.index = 0;
    185253                        if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) {
    186254                                if (len < 0)
    187                                         syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_buf error: %s",
     255                                        syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s",
    188256                                               cepid, itron_strerror(len));
    189257                                srbuf->rbuf.len = 0;
     
    228296                if (srbuf->sbuf.index >= srbuf->sbuf.len)
    229297                        if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
    230                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
     298                                syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
    231299                        return 0;
    232300                        }
     
    234302                if (srbuf->sbuf.len == 0) {
    235303                        if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) {
    236                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_get_buf error: %s", cepid, itron_strerror(srbuf->sbuf.len));
     304                                syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len));
    237305                                return 0;
    238306                                }
     
    272340                        if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) {
    273341                                if (len < 0) {
    274                                         syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_dat error: %s",
     342                                        syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s",
    275343                                               cepid, itron_strerror(len));
    276344                                        }
     
    321389                if (srbuf->sbuf.index >= srbuf->sbuf.len)
    322390                        if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
    323                                 syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
     391                                syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
    324392                        return 0;
    325393                        }
     
    476544        int_t   ix;
    477545
    478         for (ix = NUM_FILES; ix -- > 0; )
     546        for (ix = NUM_FILES; ix -- > 0; ) {
    479547                if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) {
     548                        //syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]);
    480549                        return (*file[ix].func)(cepid, srbuf);
    481550                        }
     551                }
    482552        put_status(cepid, srbuf, ST_NOT_FOUND);
    483553        return E_NOEXS;
     
    494564        ER              error = E_OK;
    495565        int_t           blen = 0;
    496         uint16_t        len;
    497566
    498567        if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) {
    499                 syslog(LOG_CRIT, "[WWW:%02d] get line error: %s.",
     568                syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.",
    500569                       cepid, itron_strerror(error));
    501570                return error;
    502571                }
    503572
    504         if ((len = get_line(cepid, method, srbuf)) == 0) {
     573        if (get_line(cepid, method, srbuf) == 0) {
    505574                if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    506                         syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     575                        syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    507576                               cepid, itron_strerror(error));
    508577                return error;
     
    510579
    511580        if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) {
    512                 syslog(LOG_CRIT, "[WWW:%02d] get line buffer error: %s.",
     581                syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.",
    513582                       cepid, itron_strerror(error));
    514583                if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    515                         syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     584                        syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    516585                               cepid, itron_strerror(error));
    517586                return error;
    518587                }
    519588
    520         while ((len = get_line(cepid, line, srbuf)) > 0) {      /* ヘッダをスキップする。*/
     589        while (get_line(cepid, line, srbuf) > 0) {      /* ヘッダをスキップする。*/
    521590                split_fields(line, ": ");
    522591                if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0)
    523592                        blen = atoi(&line->buf[line->off[1]]);
    524593                }
    525         while (blen > 0 && (len = get_line(cepid, line, srbuf)) > 0) {
     594        while (blen > 0 && get_line(cepid, line, srbuf) > 0) {
    526595                /* エンティティ・ボディをスキップする。*/
    527596                blen -= line->len;
     
    529598
    530599        if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK)
    531                 syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     600                syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    532601                       cepid, itron_strerror(error));
    533602       
     
    539608
    540609        if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
    541                 syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
     610                syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
    542611                       cepid, itron_strerror(error));
    543612
     
    567636
    568637#ifdef TARGET_KERNEL_ASP
    569                 "ASP Kernel Release 1.3 (patchlevel = 2) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
     638                "ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
    570639#endif
    571640
    572641#ifdef TARGET_KERNEL_JSP
    573                 "JSP Kernel Release 1.4 (patchlevel = 3) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
     642                "JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
    574643#endif
    575644
    576645                "TINET TCP/IP プロトコルスタックによりサービスしています。<br><hr>\r\n"
     646
     647#if NET_COUNT_ENABLE
     648
    577649                "<ul><li type=\"square\"><a href=\"stat.html\">ネットワーク統計情報</a></ul><hr>\r\n"
     650
     651#else   /* of #if NET_COUNT_ENABLE */
     652
     653                "<ul><li type=\"square\">ネットワーク統計情報</ul><hr>\r\n"
     654
     655#endif  /* of #if NET_COUNT_ENABLE */
     656
    578657                "FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n"
    579658                "The Regents of the University of California.  All rights reserved.<br><br>\r\n"
     
    629708        len += put_str(cepid, srbuf, response);
    630709        get_tim(&finish);
    631         syslog(LOG_NOTICE, "[WWW:%02u]     send:              index.html, len: %4u, time: %lu [ms]",
     710        syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
    632711                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    633712        return E_OK;
     
    15301609
    15311610        get_tim(&finish);
    1532         syslog(LOG_NOTICE, "[WWW:%02u]     send:              stat.html,  len: %4u, time: %lu [ms]",
     1611        syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
    15331612                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    15341613        return E_OK;
     
    15371616#endif  /* of #if NET_COUNT_ENABLE */
    15381617
    1539 /*
    1540  *  WWW サーバ
    1541  */
    1542 
    1543 static ER
    1544 www_srv (ID cepid, ID repid)
    1545 {
    1546 #if defined(SUPPORT_INET4)
    1547 
    1548         T_IPV4EP        dst;
    1549 
    1550 #endif  /* of #if defined(SUPPORT_INET4) */
    1551 
    1552 #if defined(SUPPORT_INET6)
    1553 
    1554         T_IPV6EP        dst;
    1555 
    1556 #endif  /* of #if defined(SUPPORT_INET6) */
    1557 
    1558         T_WWW_RWBUF     *srbuf;
    1559         ER              error;
    1560         SYSTIM          time;
    1561 
    1562         if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
    1563                 syslog(LOG_WARNING, "[WWW:%02d] accept error: %s", cepid, itron_strerror(error));
    1564                 return error;
    1565                 }
    1566 
    1567         get_tim(&time);
    1568         syslog(LOG_NOTICE, "[WWW:%02u]     connected:  %6lu, from: %s.%u",
    1569                            cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
    1570 
    1571         if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
    1572                 syslog(LOG_CRIT, "[WWW:%02d] get buffer error: %s.", cepid, itron_strerror(error));
    1573                 srbuf = NULL;
    1574                 }
    1575         else {
    1576                 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
    1577 
    1578 #ifdef USE_COPYSAVE_API
    1579 
    1580                 srbuf->sbuf.len = 0;
    1581 
    1582 #else   /* of #ifdef USE_COPYSAVE_API */
    1583 
    1584                 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
    1585 
    1586 #endif  /* of #ifdef USE_COPYSAVE_API */
    1587 
    1588                 if ((error = parse_request(cepid, srbuf)) != E_OK)
    1589                         syslog(LOG_WARNING, "[WWW:%02d] parse request error: %s",
    1590                                cepid, itron_strerror(error));
    1591                 }
    1592 
    1593         if ((error = tcp_sht_cep(cepid)) != E_OK)
    1594                 syslog(LOG_WARNING, "[WWW:%02d] shutdown error: %s", cepid, itron_strerror(error));
    1595 
    1596         if (srbuf != NULL) {
    1597                 while (get_char(cepid, srbuf) != EOF)
    1598                         ;
    1599                 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
    1600                         syslog(LOG_WARNING, "[WWW:%02d] release buffer error: %s.",
    1601                                cepid, itron_strerror(error));
    1602                 }
    1603 
    1604         if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
    1605                 syslog(LOG_WARNING, "[WWW:%02d] close error: %s", cepid, itron_strerror(error));
    1606 
    1607         get_tim(&time);
    1608         syslog(LOG_NOTICE, "[WWW:%02u]     finished:   %6lu", cepid, time / SYSTIM_HZ);
    1609 
    1610         return error;
    1611         }
    1612 
    16131618#ifdef USE_TCP_EXTENTIONS
    16141619
     
    16161621 *  get_tcp_rep -- TCP 受付口を獲得する。
    16171622 */
     1623
     1624#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
    16181625
    16191626static ER
     
    16211628{
    16221629        ID              tskid;
    1623         T_TCP_CREP      crep;
     1630        T_TCP6_CREP     crep6;
     1631        T_TCP_CREP      crep4;
     1632
     1633        get_tid(&tskid);
     1634        if (tskid == WWW4_SRV_TASK) {
     1635                crep4.repatr = UINT_C(0);
     1636                crep4.myaddr.portno = UINT_C(80);
     1637                crep4.myaddr.ipaddr = IPV4_ADDRANY;
     1638                return alloc_tcp4_rep(repid, tskid, &crep4);
     1639                }
     1640        else {
     1641                crep6.repatr = UINT_C(0);
     1642                crep6.myaddr.portno = UINT_C(80);
     1643                memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     1644                return alloc_tcp6_rep(repid, tskid, &crep6);
     1645                }
     1646        }
     1647
     1648#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1649
     1650static ER
     1651get_tcp_rep (ID *repid)
     1652{
     1653        ID              tskid;
     1654        T_TCPN_CREP     crep;
    16241655
    16251656        get_tid(&tskid);
     
    16271658        crep.repatr = UINT_C(0);
    16281659        crep.myaddr.portno = UINT_C(80);
     1660
     1661#if defined(SUPPORT_INET6)
     1662
     1663        memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
     1664
     1665#else   /* #if defined(SUPPORT_INET6) */
    16291666
    16301667#if defined(SUPPORT_INET4)
     
    16321669#endif
    16331670
    1634 #if defined(SUPPORT_INET6)
    1635         memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
    1636 #endif
    1637 
    1638 
    1639         return alloc_tcp_rep(repid, tskid, &crep);
    1640         }
    1641 
    1642 /*
    1643  *  get_tcp_cep -- TCP 通信端点とを獲得する。
     1671#endif  /* #if defined(SUPPORT_INET6) */
     1672
     1673        return ALLOC_TCP_REP(repid, tskid, &crep);
     1674        }
     1675
     1676#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1677
     1678/*
     1679 *  get_tcp_cep -- TCP 通信端点を獲得する。
    16441680 */
    16451681
     
    16681704#endif
    16691705
    1670         return alloc_tcp_cep(cepid, tskid, &ccep);
    1671         }
     1706#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1707
     1708        if (tskid == WWW4_SRV_TASK)
     1709                return alloc_tcp4_cep(cepid, tskid, &ccep);
     1710        else
     1711                return alloc_tcp6_cep(cepid, tskid, &ccep);
     1712
     1713#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1714
     1715        return ALLOC_TCP_CEP(cepid, tskid, &ccep);
     1716
     1717#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1718
     1719        }
     1720
     1721#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1722
     1723/*
     1724 *  tcp_passive_open -- 受動オープンを実行する。
     1725 *
     1726 *    USE_TCP_NON_BLOCKING      OFF
     1727 */
     1728
     1729#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1730
     1731static ER
     1732tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
     1733{
     1734        ER              error = E_OK;
     1735        T_IPV4EP        dst4;
     1736
     1737        if (apip == API_PROTO_IPV6) {
     1738                /* 受付口は IPv6 */
     1739                if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     1740                        return error;
     1741
     1742#ifdef USE_TCP_EXTENTIONS
     1743                if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
     1744                        return error;
     1745#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1746
     1747                }
     1748        else {
     1749                /* 受付口は IPv4 */
     1750                if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
     1751                        return error;
     1752                in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
     1753                info->dst.portno = dst4.portno;
     1754
     1755#ifdef USE_TCP_EXTENTIONS
     1756                if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
     1757                        return error;
     1758#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1759                }
     1760
     1761        return error;
     1762        }
     1763
     1764#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1765
     1766static ER
     1767tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
     1768{
     1769        ER              error = E_OK;
     1770
     1771        if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
     1772                return error;
     1773
     1774#ifdef USE_TCP_EXTENTIONS
     1775        if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
     1776                return error;
     1777#endif  /* of #ifdef USE_TCP_EXTENTIONS */
     1778
     1779        return error;
     1780        }
     1781
     1782#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1783
     1784/*
     1785 *  WWW サーバ
     1786 */
     1787
     1788static ER
     1789www_srv (uint_t six, char apip)
     1790{
     1791        T_WWW_RWBUF     *srbuf;
     1792        ER              error;
     1793        SYSTIM          now;
     1794
     1795        if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK)
     1796                return error;
     1797
     1798        syscall(get_tim(&now));
     1799
     1800#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     1801
     1802        if (apip == API_PROTO_IPV6)
     1803                syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct:  %6lu,from: %s.%u",
     1804                                   www_srv_info[six].cepid, now / SYSTIM_HZ,
     1805                                   ipv62str(NULL, &www_srv_info[six].dst.ipaddr),
     1806                                   www_srv_info[six].dst.portno);
     1807        else
     1808                syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct:  %6lu,from: %s.%u",
     1809                                   www_srv_info[six].cepid, now / SYSTIM_HZ,
     1810                                   ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]),
     1811                                   www_srv_info[six].dst.portno);
     1812
     1813#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1814
     1815        syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct:  %6lu,from: %s.%u",
     1816                           www_srv_info[six].cepid, now / SYSTIM_HZ,
     1817                           IP2STR(NULL, &www_srv_info[six].dst.ipaddr),
     1818                           www_srv_info[six].dst.portno);
     1819
     1820#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1821
     1822        if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
     1823                syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.",
     1824                                 www_srv_info[six].cepid, itron_strerror(error));
     1825                srbuf = NULL;
     1826                }
     1827        else {
     1828                srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
     1829
     1830#ifdef USE_COPYSAVE_API
     1831
     1832                srbuf->sbuf.len = 0;
     1833
     1834#else   /* of #ifdef USE_COPYSAVE_API */
     1835
     1836                srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
     1837
     1838#endif  /* of #ifdef USE_COPYSAVE_API */
     1839
     1840                if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK)
     1841                        syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s",
     1842                                            www_srv_info[six].cepid, itron_strerror(error));
     1843                }
     1844
     1845        if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK)
     1846                syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s",
     1847                                    www_srv_info[six].cepid, itron_strerror(error));
     1848
     1849        if (srbuf != NULL) {
     1850                while (get_char(www_srv_info[six].cepid, srbuf) != EOF)
     1851                        ;
     1852                if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
     1853                        syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.",
     1854                                            www_srv_info[six].cepid, itron_strerror(error));
     1855                }
     1856
     1857        if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK)
     1858                syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s",
     1859                                    www_srv_info[six].cepid, itron_strerror(error));
     1860
     1861        get_tim(&now);
     1862        syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh:  %6lu",
     1863                           www_srv_info[six].cepid, now / SYSTIM_HZ);
     1864
     1865        return error;
     1866        }
     1867
     1868#ifdef USE_TCP_EXTENTIONS
    16721869
    16731870/*
     
    16781875www_srv_task(intptr_t exinf)
    16791876{
    1680         ID      tskid, cepid, repid;
     1877        ID      tskid;
    16811878        ER      error = E_OK;
     1879        uint_t  six;
     1880        char    apip;
    16821881
    16831882        syscall(get_tid(&tskid));
    1684         syslog(LOG_NOTICE, "[WWW:%d] started.", tskid);
     1883        six = INDEX_SRV_INFO((ID)exinf);
     1884
     1885#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     1886
     1887        if (six >= NUM_WWW4_SRV_TASKS)
     1888                apip = API_PROTO_IPV6;
     1889        else
     1890                apip = API_PROTO_IPV4;
     1891
     1892#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1893
     1894        apip = API_PROTO_IPVn;
     1895
     1896#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     1897
     1898        syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid);
    16851899        while (true) {
    16861900
    16871901                syscall(slp_tsk());
    1688                 if ((error = get_tcp_cep (&cepid)) != E_OK) {
    1689                         syslog(LOG_NOTICE, "[WWW:00 EXT] CEP create error: %s", itron_strerror(error));
     1902                if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) {
     1903                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s",
     1904                                           apip, www_srv_info[six].cepid, itron_strerror(error));
    16901905                        continue;
    16911906                        }
    16921907
    1693                 if ((error = get_tcp_rep (&repid)) != E_OK) {
    1694                         syslog(LOG_NOTICE, "[WWW:00 EXT] REP create error: %s", itron_strerror(error));
    1695                         free_tcp_cep(cepid);
    1696                         continue;
    1697                         }
    1698 
    1699                 while (true)
    1700                         if ((error = www_srv(cepid, repid)) != E_OK) {
    1701                                 error = free_tcp_rep(repid, error != E_DLT);
     1908                while (true) {
     1909
     1910                        if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) {
     1911                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s",
     1912                                                   apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error));
    17021913                                break;
    17031914                                }
    1704 
    1705                 if ((error = free_tcp_cep(cepid)) != E_OK)
    1706                         syslog(LOG_NOTICE, "[WWW:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
    1707 
    1708                 }
     1915                        else if ((error = www_srv(six, apip)) != E_OK) {
     1916
     1917#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1918
     1919                                if (tskid == WWW4_SRV_TASK)
     1920                                        error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT);
     1921                                else
     1922                                        error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT);
     1923
     1924#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1925
     1926                                error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT);
     1927
     1928#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1929
     1930                                if (error != E_OK) {
     1931                                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s",
     1932                                                           apip, www_srv_info[six].cepid,
     1933                                                                              www_srv_info[six].repid, itron_strerror(error));
     1934
     1935                                        }
     1936                                break;
     1937                                }
     1938                        }
     1939
     1940#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     1941
     1942                if (tskid == WWW4_SRV_TASK) {
     1943                        if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK)
     1944                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1945                                                   apip, www_srv_info[six].cepid, itron_strerror(error));
     1946                        }
     1947                else {
     1948                        if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK)
     1949                                syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1950                                                   apip, www_srv_info[six].cepid, itron_strerror(error));
     1951                        }
     1952
     1953#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1954
     1955                if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK)
     1956                        syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
     1957                                           apip, www_srv_info[six].cepid, itron_strerror(error));
     1958
     1959#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
     1960
     1961                }
     1962        }
     1963
     1964/*
     1965 *  wakeup_www_srv -- WWW サーバタスクの休止解除
     1966 */
     1967
     1968ER
     1969wakeup_www_srv (char apip)
     1970{
     1971        ID      taskid;
     1972
     1973        if (apip == API_PROTO_IPV6)
     1974                taskid = WWW6_SRV_TASK;
     1975        else
     1976                taskid = WWW4_SRV_TASK;
     1977        syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid);
     1978        return wup_tsk(taskid);
    17091979        }
    17101980
     
    17181988www_srv_task(intptr_t exinf)
    17191989{
    1720         ID      tskid;
     1990        ID      tskid, cepid;
     1991        uint_t  six;
     1992        char    apip;
    17211993
    17221994        get_tim(&srv_start);
    17231995        get_tid(&tskid);
    1724         syslog(LOG_NOTICE, "[WWW:%d,%d] started.", tskid, (int_t)exinf);
     1996        six = INDEX_SRV_INFO((ID)exinf);
     1997        cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid;
     1998
     1999#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
     2000
     2001        if (six >= NUM_WWW4_SRV_TASKS)
     2002                apip = API_PROTO_IPV6;
     2003        else
     2004                apip = API_PROTO_IPV4;
     2005
     2006#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     2007
     2008        apip = API_PROTO_IPVn;
     2009
     2010#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
     2011
     2012        syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid);
     2013
    17252014        while (true) {
    1726                 while (www_srv((int_t)exinf, WWW_SRV_REPID) == E_OK)
     2015                while (www_srv(six, apip) == E_OK)
    17272016                        ;
    17282017                }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.cfg

    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 *
     
    4040/* タスク */
    4141
    42 #ifdef USE_TCP_EXTENTIONS
    43 
    4442CRE_TSK(WWW_SRV_TASK1,  {
    4543        TA_HLNG | TA_ACT,
    46         0,
     44        1,
    4745        www_srv_task,
    4846        WWW_SRV_MAIN_PRIORITY,
     
    5149        });
    5250
    53 #else   /* of #ifdef USE_TCP_EXTENTIONS */
    54 
    55 CRE_TSK(WWW_SRV_TASK1,  {
    56         TA_HLNG | TA_ACT,
    57         WWW_SRV_CEPID1,
    58         www_srv_task,
    59         WWW_SRV_MAIN_PRIORITY,
    60         WWW_SRV_STACK_SIZE,
    61         NULL
    62         });
    63 
    64 #endif  /* of #ifdef USE_TCP_EXTENTIONS */
    65 
    6651#if NUM_WWW_SRV_TASKS >= 2
    6752
    6853CRE_TSK(WWW_SRV_TASK2,  {
    6954        TA_HLNG | TA_ACT,
    70         WWW_SRV_CEPID2,
     55        2,
    7156        www_srv_task,
    7257        WWW_SRV_MAIN_PRIORITY,
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.h

    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 *
     
    3939 */
    4040
    41 #include <tinet_defs.h>
    42 
    43 #include <net/if.h>
    44 #include <net/if_ppp.h>
    45 #include <net/if_loop.h>
    46 #include <net/ethernet.h>
    47 
    48 #include <netinet6/in6.h>
    49 #include <netinet/ip.h>
    50 #include <netinet/ip6.h>
    51 #include <netinet/tcp.h>
    52 
    5341#ifdef TOPPERS_S810_CLG3_85
    5442#define WWW_SRV_STACK_SIZE              768             /* タスクのスタックサイズ  */
     
    6250 */
    6351
    64 #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
     52#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
    6553
    66 #define WWW_SRV_SWBUF_SIZE      ((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
    67 
    68 #else   /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
    69 
    70 #if defined(SUPPORT_INET4)
    71 #define WWW_SRV_SWBUF_SIZE      (TCP_MSS)
     54#if defined(SUPPORT_INET6)
     55#define WWW_SRV_SWBUF_SIZE      (1024)
     56#elif defined(SUPPORT_INET4)
     57#define WWW_SRV_SWBUF_SIZE      (512)
    7258#endif
    7359
    74 #if defined(SUPPORT_INET6)
    75 #define WWW_SRV_SWBUF_SIZE      (TCP6_MSS)
    76 #endif
     60#else   /* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
    7761
    78 #endif  /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
     62#define WWW_SRV_SWBUF_SIZE      (2048)
    7963
    80 #if defined(SUPPORT_INET4)
    81 #define WWW_SRV_RWBUF_SIZE      (TCP_MSS)
    82 #endif
     64#endif  /* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
    8365
    8466#if defined(SUPPORT_INET6)
    85 #define WWW_SRV_RWBUF_SIZE      (TCP6_MSS)
     67#define WWW_SRV_RWBUF_SIZE      (1024)
     68#elif defined(SUPPORT_INET4)
     69#define WWW_SRV_RWBUF_SIZE      (512)
    8670#endif
    8771
     
    8973#define WWW_LINE_SIZE           80
    9074#define WWW_NUM_FIELDS          4
     75
     76/*
     77 *  タスク数
     78 */
    9179
    9280#ifndef _MACRO_ONLY
     
    128116
    129117/*
    130  *  TCP 送受信バッファ
     118 *  変数
    131119 */
     120
     121/* TCP 送受信ウィンドバッファ */
     122
     123#ifdef NUM_WWW_SRV_TASKS
    132124
    133125extern uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE];
    134126extern uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE];
    135127
     128#endif  /* of #ifdef NUM_WWW_SRV_TASKS */
     129
     130/*
     131 *  関数
     132 */
     133
     134extern ER       wakeup_www_srv (char apip);
     135
    136136#endif  /* of #ifndef _MACRO_ONLY */
    137137
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_asp.cfg

    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 *
     
    4242INCLUDE("netapp/wwws.cfg");
    4343
     44#ifdef USE_WWW_SRV
     45
    4446/*
    4547 * 固定メモリプール
     
    6567        NULL
    6668        });
     69
     70#endif  /* of #ifdef USE_WWW_SRV */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_jsp.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/Makefile.tinet

    r321 r331  
    3636#
    3737INCLUDES        := $(INCLUDES) -I$(TINET_ROOT)/netdev/$(NET_DEV)
    38 TINET_DIR       := $(TINET_DIR):$(TINET_ROOT)/netdev/$(NET_DEV)
     38TINET_DIRS      := $(TINET_DIRS):$(TINET_ROOT)/netdev/$(NET_DEV)
    3939TINET_COBJS     := $(TINET_COBJS) if_mbed.o
    4040TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netdev/$(NET_DEV)/if_mbed.cfg
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c

    r321 r331  
    210210if_mbed_addmulti(T_IF_SOFTC *ic)
    211211{
    212         mbed_setrcr(ic);
     212        if_mbed_setrcr(ic);
    213213        return E_OK;
    214214}
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed_sym.def

    • Property svn:keywords deleted
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h

    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 *
     
    102102#define _IP_ICMP6_H_
    103103
    104 #ifdef SUPPORT_INET6
    105 
    106104/*
    107105 *  ICMPv6 ヘッダ
     
    117115                uint8_t         data8[4];
    118116                } data;
    119         } __attribute__((packed, aligned(2)))T_ICMP6_HDR;
     117        } __attribute__((packed, aligned(2))) T_ICMP6_HDR;
    120118
    121119#define icmp6_data32                    data.data32
     
    133131#define GET_ICMP6_SDU(nbuf,ihoff)       ((uint8_t*)((nbuf)->buf) + ihoff + ICMP6_HDR_SIZE)
    134132
    135 #define GET_IP6_ICMP6_HDR_SIZE(nbuf)    (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ICMP6_HDR_SIZE)
     133#define GET_IP6_ICMP6_HDR_SIZE(nbuf)    (GET_IP6_HDR_SIZE(nbuf) + ICMP6_HDR_SIZE)
    136134#define GET_IF_IP6_ICMP6_HDR_SIZE(nbuf) (IF_HDR_SIZE + GET_IP6_ICMP6_HDR_SIZE(nbuf))
    137135
     
    218216        T_IN6_ADDR      target;
    219217        /* この後にオプションが続く */
    220         } __attribute__((packed, aligned(2)))T_NEIGHBOR_SOLICIT_HDR;
     218        } T_NEIGHBOR_SOLICIT_HDR;
    221219
    222220#define NEIGHBOR_SOLICIT_HDR_SIZE       (sizeof(T_NEIGHBOR_SOLICIT_HDR))
     
    230228
    231229#define GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)         \
    232                                         (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + NEIGHBOR_SOLICIT_HDR_SIZE)
     230                                        (GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_SOLICIT_HDR_SIZE)
    233231#define GET_IF_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)      \
    234232                                        (GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
     
    242240        T_IN6_ADDR      target;
    243241        /* この後にオプションが続く */
    244         } __attribute__((packed, aligned(2)))T_NEIGHBOR_ADVERT_HDR;
     242        } __attribute__((packed, aligned(2))) T_NEIGHBOR_ADVERT_HDR;
    245243
    246244/* ICMP6 ヘッダのデータ部の定義 */
     
    261259
    262260#define GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)          \
    263                                         (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + NEIGHBOR_ADVERT_HDR_SIZE)
     261                                        (GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_ADVERT_HDR_SIZE)
    264262#define GET_IF_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)       \
    265263                                        (GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
     
    285283/*
    286284 *  ルータ通知
     285 *
     286 *    RFC4291: IP Version 6 Addressing Architecture
     287 *    RFC4941: Privacy Extensions for Stateless Address Autoconfiguration in IPv6
     288 *    RFC6106: IPv6 Router Advertisement Options for DNS Configuration
    287289 */
    288290
     
    292294        uint32_t        retransmit;             /* [ms] 近隣要請送信間隔        */
    293295        /* この後にオプションが続く */
    294         } __attribute__((packed, aligned(2)))T_ROUTER_ADVERT_HDR;
     296        } __attribute__((packed, aligned(2))) T_ROUTER_ADVERT_HDR;
    295297
    296298/* ICMP6 ヘッダのデータ部の定義 */
     
    311313
    312314#define GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf)    \
    313                                         (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ROUTER_ADVERT_HDR_SIZE)
     315                                        (GET_IP6_HDR_SIZE(nbuf) + ROUTER_ADVERT_HDR_SIZE)
    314316#define GET_IF_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf) \
    315317                                        (GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
     
    324326
    325327/*
     328 *  M: RA以外の方法で自動的にアドレスを設定することを許可する。
     329 *  O: RA以外の方法で自動的にアドレス以外の情報を設定することをを許可する。
     330 *
     331 *   M   O
     332 *  ON  ON      アドレスとそれ以外の情報をDHCPv6で設定する(statefull)
     333 *  ON  OFF     アドレスはDHCPv6で設定するが、それ以外は手動で設定する。
     334 *  OFF ON      アドレスは RA で設定するが、それ以外の情報をDHCPv6で設定する(stateless)
     335 *  OFF OFF     DHCPv6 は使用しない。
     336 */
     337
     338/*
    326339 *  ルータ要請
    327340 */
     
    329342typedef struct t_router_solicit_hdr {
    330343        T_ICMP6_HDR     hdr;
    331         } __attribute__((packed, aligned(2)))T_ROUTER_SOLICIT_HDR;
     344        } __attribute__((packed, aligned(2))) T_ROUTER_SOLICIT_HDR;
    332345
    333346/* ICMP6 ヘッダのデータ部の定義 */
     
    347360
    348361#define GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)           \
    349                                         (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ROUTER_SOLICIT_HDR_SIZE)
     362                                        (GET_IP6_HDR_SIZE(nbuf) + ROUTER_SOLICIT_HDR_SIZE)
    350363#define GET_IF_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)        \
    351364                                        (GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
     
    360373        T_ICMP6_HDR     hdr;
    361374        T_IN6_ADDR      target;
    362         } __attribute__((packed, aligned(2)))T_NEIGHBOR_HDR;
     375        } __attribute__((packed, aligned(2))) T_NEIGHBOR_HDR;
    363376
    364377/* 近隣探索オプションヘッダ */
     
    367380        uint8_t         type;                   /* オプションタイプ                     */
    368381        uint8_t         len;                    /* オプション長、単位は 8 バイト     */
    369         } __attribute__((packed, aligned(2)))T_ND_OPT_HDR;
     382        } __attribute__((packed, aligned(2))) T_ND_OPT_HDR;
    370383
    371384#define ND_OPT_HDR_SIZE                 (sizeof(T_ND_OPT_HDR))
     
    393406        uint32_t        reserved;
    394407        T_IN6_ADDR      prefix;         /* プレフィックス              */
    395         } __attribute__((packed, aligned(2)))T_ND_OPT_PREFIX_INFO;
     408        } __attribute__((packed, aligned(2))) T_ND_OPT_PREFIX_INFO;
    396409
    397410#define ND_OPT_PI_FLAG_ONLINK   UINT_C(0x80)            /* オンリンクプレフィックス */
     
    405418        uint16_t        reserved;
    406419        uint32_t        mtu;            /* MTU                          */
    407         } __attribute__((packed, aligned(2)))T_ND_OPT_MTU_HDR;
     420        } __attribute__((packed, aligned(2))) T_ND_OPT_MTU_HDR;
    408421
    409422/*
     
    416429        T_IN6_ADDR      dst;            /* 向け直しの終点アドレス          */
    417430        /* この後にオプションが続く */
    418         } __attribute__((packed, aligned(2)))T_ND_REDIRECT_HDR;
     431        } __attribute__((packed, aligned(2))) T_ND_REDIRECT_HDR;
    419432
    420433#define ND_REDIRECT_HDR_SIZE            (sizeof(T_ND_REDIRECT_HDR))
     
    480493#endif  /* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
    481494
    482 #endif  /* of #ifdef SUPPORT_INET6 */
    483 
    484495#endif  /* of #ifndef _IP_ICMP6_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp_var.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.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 *
     
    9494#include <net/if_arp.h>
    9595#include <net/net.h>
     96#include <net/net_endian.h>
    9697#include <net/net_buf.h>
    9798#include <net/net_var.h>
     
    106107#include <net/if_var.h>
    107108
    108 #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER)
     109#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
    109110
    110111/*
     
    118119 */
    119120
    120 static T_ARP_ENTRY *arp_lookup (T_IN4_ADDR addr, bool_t create);
    121121static void in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input);
    122122static void arp_timer (void *ignore);
    123123
    124124/*
     125 *  in_arpinput -- TCP/IP 用 ARP の入力関数
     126 */
     127
     128static void
     129in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input)
     130{
     131        T_NET_BUF       *pending;
     132        T_ETHER_HDR     *eth;
     133        T_ARP_HDR       *arph;
     134        T_ETHER_ARP_HDR *et_arph;
     135        T_ARP_ENTRY     *ent;
     136        T_IFNET         *ifp = IF_GET_IFNET();
     137        T_IN4_ADDR      saddr, taddr;
     138
     139        et_arph = GET_ETHER_ARP_HDR(input);
     140
     141        ntoahl(saddr, et_arph->sproto);         /* 送信元 IP アドレス  */
     142        ntoahl(taddr, et_arph->tproto);         /* 解決対象 IP アドレス */
     143
     144        /*
     145         *  以下の場合はエラー
     146         *    ・送信ホストの物理アドレスが自分
     147         *    ・送信ホストの物理アドレスがブロードキャスト
     148         */
     149        if (memcmp(et_arph->shost, ifaddr->lladdr,        ETHER_ADDR_LEN) == 0 ||
     150            memcmp(et_arph->shost, ether_broad_cast_addr, ETHER_ADDR_LEN) == 0)
     151                goto err_ret;
     152
     153        /*
     154         *  送信ホストの IP アドレスが自分の場合は、重複しているので
     155         *  相手にも知らせる。
     156         *  ただし、自分と相手のアドレスが未定義(IPV4_ADDRANY)の時は何もしない。
     157         */
     158        if ((saddr == ifp->in4_ifaddr.addr) && (saddr != IPV4_ADDRANY)) {
     159
     160#ifdef ARP_CFG_CALLBACK_DUPLICATED
     161
     162                if (arp_callback_duplicated(et_arph->shost)) {
     163                        syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
     164                                          ip2str(NULL, &ifp->in4_ifaddr.addr),
     165                                          mac2str(NULL, et_arph->shost));
     166                        taddr = saddr;
     167                        goto reply;
     168                        }
     169                else
     170                        goto buf_rel;
     171
     172#else   /* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
     173
     174                syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
     175                                  ip2str(NULL, &ifp->in4_ifaddr.addr),
     176                                  mac2str(NULL, et_arph->shost));
     177                taddr = saddr;
     178                goto reply;
     179
     180#endif  /* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
     181
     182                }
     183
     184        /*
     185         *  以下の場合は何もしない。
     186         *    ・解決対象 IP アドレスが自分ではない、注: 元の FreeBSD の
     187         *      実装では、ARP PROXY 等のため、自分以外の IP アドレスの
     188         *      解決も行っているが、本実装では、自分以外の IP
     189         *      アドレスの解決は行わない。
     190         */
     191        if (taddr != ifp->in4_ifaddr.addr)
     192                goto buf_rel;
     193
     194        /*
     195         *  送信元 IP アドレスが ARP キャッシュにあるか調べる。
     196         *  キャッシュになければ、新たにエントリを登録する。
     197         */
     198        syscall(wai_sem(SEM_ARP_CACHE_LOCK));
     199        ent = arp_lookup(saddr, true);
     200
     201        memcpy(ent->mac_addr, et_arph->shost, ETHER_ADDR_LEN);
     202        ent->expire = ARP_CACHE_KEEP;
     203
     204        /*
     205         *  送信がペンデングされているフレームがあれば送信する。
     206         */
     207        if (ent->hold) {
     208
     209                /* フレームの Ethernet ヘッダを設定する。*/
     210                memcpy(GET_ETHER_HDR(ent->hold)->dhost, ent->mac_addr, ETHER_ADDR_LEN);
     211
     212                pending = ent->hold;
     213                ent->hold = NULL;
     214                syscall(sig_sem(SEM_ARP_CACHE_LOCK));
     215
     216                /* ペンディングされているフレームを送信する。*/
     217                IF_RAW_OUTPUT(pending, TMO_FEVR);
     218
     219                }
     220        else
     221                syscall(sig_sem(SEM_ARP_CACHE_LOCK));
     222
     223reply:
     224
     225        arph = GET_ARP_HDR(input);
     226
     227        /* アドレス解決要求でなければ終了 */
     228        if (ntohs(arph->opcode) != ARPOP_REQUEST)
     229                goto buf_rel;
     230
     231        /* Ethernet ARP ヘッダを設定する。*/
     232        memcpy(et_arph->thost, et_arph->shost, ETHER_ADDR_LEN);
     233        memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
     234        memcpy(et_arph->tproto, (uint8_t*)&et_arph->sproto, sizeof(T_IN_ADDR));
     235        ahtonl(et_arph->sproto, taddr);
     236
     237        /* Ethernet ARP ヘッダを設定する。*/
     238        arph->opcode = htons(ARPOP_REPLY);
     239
     240        /* Ethernet ヘッダを設定する。*/
     241        eth = GET_ETHER_HDR(input);
     242        memcpy(eth->dhost, eth->shost,     ETHER_ADDR_LEN);
     243        memcpy(eth->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
     244
     245        /* ARP 応答を送信する。*/
     246        IF_RAW_OUTPUT(input, TMO_FEVR);
     247        return;
     248
     249err_ret:
     250        NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
     251buf_rel:
     252        syscall(rel_net_buf(input));
     253        }
     254
     255/*
     256 *  arp_timer -- ARP キャッシュの更新
     257 */
     258
     259static void
     260arp_timer (void *ignore)
     261{
     262        int_t   ix;
     263
     264        syscall(wai_sem(SEM_ARP_CACHE_LOCK));
     265
     266        for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
     267                if (arp_cache[ix].expire) {
     268                        arp_cache[ix].expire -= ARP_TIMER_TMO;
     269                        if (arp_cache[ix].expire == 0) {
     270                                /* 送信がペンデングされているフレームがあれば捨てる。*/
     271                                if (arp_cache[ix].hold) {
     272                                        NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
     273                                        syscall(rel_net_buf(arp_cache[ix].hold));
     274                                        }
     275                                memset(&arp_cache[ix], 0, sizeof(T_ARP_ENTRY));
     276                                }
     277                        }
     278                }
     279
     280        syscall(sig_sem(SEM_ARP_CACHE_LOCK));
     281        timeout(arp_timer, NULL, ARP_TIMER_TMO);
     282        }
     283
     284/*
    125285 *  arp_lookup -- ARP キャッシュの探索と登録
    126286 *
     
    128288 */
    129289
    130 static T_ARP_ENTRY *
     290T_ARP_ENTRY *
    131291arp_lookup (T_IN4_ADDR addr, bool_t create)
    132292{
     
    170330
    171331/*
    172  *  in_arpinput -- TCP/IP 用 ARP の入力関数
    173  */
    174 
    175 static void
    176 in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input)
    177 {
    178         T_NET_BUF       *pending;
    179         T_ETHER_HDR     *eth;
    180         T_ARP_HDR       *arph;
    181         T_ETHER_ARP_HDR *et_arph;
    182         T_ARP_ENTRY     *ent;
    183         T_IFNET         *ifp = IF_GET_IFNET();
    184         T_IN4_ADDR      saddr, taddr;
    185 
    186         et_arph = GET_ETHER_ARP_HDR(input);
    187 
    188         ntoahl(saddr, et_arph->sproto);         /* 送信元 IP アドレス  */
    189         ntoahl(taddr, et_arph->tproto);         /* 解決対象 IP アドレス */
    190 
    191         /*
    192          *  以下の場合はエラー
    193          *    ・送信ホストの物理アドレスが自分
    194          *    ・送信ホストの物理アドレスがブロードキャスト
    195          */
    196         if (memcmp(et_arph->shost, ifaddr->lladdr,        ETHER_ADDR_LEN) == 0 ||
    197             memcmp(et_arph->shost, ether_broad_cast_addr, ETHER_ADDR_LEN) == 0)
    198                 goto err_ret;
    199 
    200         /*
    201          *  送信ホストの IP アドレスが自分の場合は、重複しているので
    202          *  相手にも知らせる。
    203          */
    204         if (saddr == ifp->in_ifaddr.addr) {
    205 
    206 #ifdef ARP_CFG_CALLBACK_DUPLICATED
    207 
    208                 if (arp_callback_duplicated(et_arph->shost)) {
    209                         syslog(LOG_ERROR, "[ARP] IP address duplicated: %s", mac2str(NULL, et_arph->shost));
    210                         taddr = saddr;
    211                         goto reply;
    212                         }
    213                 else
    214                         goto buf_rel;
    215 
    216 #else   /* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
    217 
    218                 syslog(LOG_ERROR, "[ARP] IP address duplicated: %s", mac2str(NULL, et_arph->shost));
    219                 taddr = saddr;
    220                 goto reply;
    221 
    222 #endif  /* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
    223 
    224                 }
    225 
    226         /*
    227          *  以下の場合は何もしない。
    228          *    ・解決対象 IP アドレスが自分ではない、注: 元の FreeBSD の
    229          *      実装では、ARP PROXY 等のため、自分以外の IP アドレスの
    230          *      解決も行っているが、本実装では、自分以外の IP
    231          *      アドレスの解決は行わない。
    232          */
    233         if (taddr != ifp->in_ifaddr.addr)
    234                 goto buf_rel;
    235 
    236         /*
    237          *  送信元 IP アドレスが ARP キャッシュにあるか調べる。
    238          *  キャッシュになければ、新たにエントリを登録する。
    239          */
    240         syscall(wai_sem(SEM_ARP_CACHE_LOCK));
    241         ent = arp_lookup(saddr, true);
    242 
    243         memcpy(ent->mac_addr, et_arph->shost, ETHER_ADDR_LEN);
    244         ent->expire = ARP_CACHE_KEEP;
    245 
    246         /*
    247          *  送信がペンデングされているフレームがあれば送信する。
    248          */
    249         if (ent->hold) {
    250 
    251                 /* フレームの Ethernet ヘッダを設定する。*/
    252                 memcpy(GET_ETHER_HDR(ent->hold)->dhost, ent->mac_addr, ETHER_ADDR_LEN);
    253 
    254                 pending = ent->hold;
    255                 ent->hold = NULL;
    256                 syscall(sig_sem(SEM_ARP_CACHE_LOCK));
    257 
    258                 /* ペンディングされているフレームを送信する。*/
    259                 IF_RAW_OUTPUT(pending, TMO_FEVR);
    260 
    261                 }
    262         else
    263                 syscall(sig_sem(SEM_ARP_CACHE_LOCK));
    264 
    265 reply:
    266 
    267         arph = GET_ARP_HDR(input);
    268 
    269         /* アドレス解決要求でなければ終了 */
    270         if (ntohs(arph->opcode) != ARPOP_REQUEST)
    271                 goto buf_rel;
    272 
    273         /* Ethernet ARP ヘッダを設定する。*/
    274         memcpy(et_arph->thost, et_arph->shost, ETHER_ADDR_LEN);
    275         memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
    276         memcpy(et_arph->tproto, (uint8_t*)&et_arph->sproto, sizeof(T_IN_ADDR));
    277         ahtonl(et_arph->sproto, taddr);
    278 
    279         /* Ethernet ARP ヘッダを設定する。*/
    280         arph->opcode = htons(ARPOP_REPLY);
    281 
    282         /* Ethernet ヘッダを設定する。*/
    283         eth = GET_ETHER_HDR(input);
    284         memcpy(eth->dhost, eth->shost,     ETHER_ADDR_LEN);
    285         memcpy(eth->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
    286 
    287         /* ARP 応答を送信する。*/
    288         IF_RAW_OUTPUT(input, TMO_FEVR);
    289         return;
    290 
    291 err_ret:
    292         NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
    293 buf_rel:
    294         syscall(rel_net_buf(input));
    295         }
    296 
    297 /*
    298  *  arp_timer -- ARP キャッシュの更新
    299  */
    300 
    301 static void
    302 arp_timer (void *ignore)
    303 {
    304         int_t   ix;
    305 
    306         syscall(wai_sem(SEM_ARP_CACHE_LOCK));
    307 
    308         for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
    309                 if (arp_cache[ix].expire) {
    310                         arp_cache[ix].expire -= ARP_TIMER_TMO;
    311                         if (arp_cache[ix].expire == 0) {
    312                                 /* 送信がペンデングされているフレームがあれば捨てる。*/
    313                                 if (arp_cache[ix].hold) {
    314                                         NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
    315                                         syscall(rel_net_buf(arp_cache[ix].hold));
    316                                         }
    317                                 memset(&arp_cache[ix], 0, sizeof(T_ARP_ENTRY));
    318                                 }
    319                         }
    320                 }
    321 
    322         syscall(sig_sem(SEM_ARP_CACHE_LOCK));
    323         timeout(arp_timer, NULL, ARP_TIMER_TMO);
    324         }
    325 
    326 /*
    327332 *  arp_request -- MAC アドレス解決要求
    328333 */
     
    359364                /* イーサネット ARP ヘッダを設定する。*/
    360365                et_arph = GET_ETHER_ARP_HDR(arp_req);
    361                 src     = IF_GET_IFNET()->in_ifaddr.addr;
     366                src     = IF_GET_IFNET()->in4_ifaddr.addr;
    362367                memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
    363368                memset(et_arph->thost, 0,              ETHER_ADDR_LEN);
     
    444449         */
    445450        if (gw == IPV4_ADDR_BROADCAST ||
    446             gw == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask)) {
     451            gw == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask)) {
    447452                memcpy(eth->dhost, ether_broad_cast_addr, ETHER_ADDR_LEN);
    448453                return true;
     
    504509        eaddr->lladdr[1] = UINT_C(0x00);
    505510        eaddr->lladdr[2] = UINT_C(0x5E);
    506         eaddr->lladdr[3] = (maddr & 0x7F0000) >> 16;
    507         eaddr->lladdr[4] = (maddr & 0xFF00) >> 8;
    508         eaddr->lladdr[5] = maddr & 0xFF;
     511        eaddr->lladdr[3] = (uint8_t)((maddr & 0x7F0000) >> 16);
     512        eaddr->lladdr[4] = (uint8_t)((maddr & 0xFF00) >> 8);
     513        eaddr->lladdr[5] = (uint8_t)(maddr & 0xFF);
    509514        }
    510515#endif  /* ETHER_CFG_MULTICAST */
    511516
    512 #endif  /* of #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER) */
     517#endif  /* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.cfg

    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 *
     
    3636 */
    3737
    38 #ifdef SUPPORT_ETHER
     38#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
    3939
    4040/* ARP キャッシュ更新用セマフォ */
     
    4242CRE_SEM(SEM_ARP_CACHE_LOCK, { TA_TPRI, 1, 1 });
    4343
    44 #endif  /* of #ifdef SUPPORT_ETHER */
     44#endif  /* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.h

    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 *
     
    106106 */
    107107
     108extern T_ARP_ENTRY *arp_lookup (T_IN4_ADDR addr, bool_t create);
    108109extern ER arp_request (T_IF_ADDR *ifaddr, T_IN4_ADDR dst);
    109110extern void arp_input (T_IF_ADDR *ifaddr, T_NET_BUF *input);
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in.h

    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 <tinet_kernel_defs.h>
    7474
     75#include <netinet/in4.h>
    7576#include <netinet6/in6.h>
    7677
     
    7980 */
    8081
    81 #define TINET_PRVER             UINT_C(0x1054)  /* TINET のバージョン番号 */
     82#define TINET_PRVER             UINT_C(0x1070)  /* TINET のバージョン番号 */
    8283
    8384/*
     
    9293#define IPPROTO_HOPOPTS         UINT_C(0)       /* IPv6 中継点 (Hop-by-Hop) オプション  */
    9394#define IPPROTO_ICMP            UINT_C(1)       /* ICMP                                 */
     95#define IPPROTO_IGMP            UINT_C(2)       /* IGMP                                 */
    9496#define IPPROTO_TCP             UINT_C(6)       /* TCP                                  */
    9597#define IPPROTO_UDP             UINT_C(17)      /* UDP                                  */
     
    107109
    108110/*
    109  *  IPv4 アドレス
     111 *  ポートの長さ
    110112 */
    111113
    112 /* 前方参照 */
    113 
    114 #ifndef T_IN4_ADDR_DEFINED
    115 
    116 typedef uint32_t T_IN4_ADDR;
    117 
    118 #define T_IN4_ADDR_DEFINED
    119 
    120 #endif  /* of #ifndef T_IN4_ADDR_DEFINED */
    121 
    122 /*
    123  *  ITRON TCP/IPv4 アドレス/ポート番号の定義
    124  */
    125 
    126 typedef struct t_ipv4ep {
    127         uint32_t        ipaddr;         /* IPv4 アドレス    */
    128         uint16_t        portno;         /* ポート番号                */
    129         } T_IPV4EP;
    130 
    131 /*
    132  *  アドレス/ポートの長さ
    133  */
    134 
    135 #define IPV4_ADDR_LEN           4
    136114#define PORT_NUM_LEN            2
    137115
     
    152130
    153131/*
    154  *  IP アドレスの定義
     132 *  API IPプロトコルの指定
    155133 */
    156134
    157 #define IPV4_ADDRANY            ULONG_C(0x00000000)     /* ITRON TCP/IP 標準      */
    158 
    159 #define IPV4_ADDR_LOOPBACK      ULONG_C(0x7f000001)
    160 #define IPV4_ADDR_LOOPBACK_MASK IPV4_CLASS_A_MASK
    161 #define IPV4_ADDR_BROADCAST     ULONG_C(0xffffffff)
    162 
    163 #define IPV4_CLASS_A(i)         (((i) & ULONG_C(0x80000000)) == 0)
    164 #define IPV4_CLASS_A_NET        ULONG_C(0xff000000)
    165 #define IPV4_CLASS_A_MASK       ULONG_C(0xff000000)
    166 #define IPV4_CLASS_A_HOST       ULONG_C(0x00ffffff)
    167 
    168 #define IPV4_CLASS_B(i)         (((i) & ULONG_C(0xc0000000)) == ULONG_C(0x80000000))
    169 #define IPV4_CLASS_B_NET        ULONG_C(0xffff0000)
    170 #define IPV4_CLASS_B_MASK       ULONG_C(0xffff0000)
    171 #define IPV4_CLASS_B_HOST       ULONG_C(0x0000ffff)
    172 
    173 #define IPV4_CLASS_C(i)         (((i) & ULONG_C(0xe0000000)) == ULONG_C(0xc0000000))
    174 #define IPV4_CLASS_C_NET        ULONG_C(0xffffff00)
    175 #define IPV4_CLASS_C_MASK       ULONG_C(0xffffff00)
    176 #define IPV4_CLASS_C_HOST       ULONG_C(0x000000ff)
    177 
    178 #define IPV4_CLASS_D(i)         (((i) & ULONG_C(0xf0000000)) == ULONG_C(0xe0000000))
    179 
    180 #define IN4_IS_ADDR_MULTICAST(i)        IPV4_CLASS_D(i)
    181 
    182 #define MAKE_IPV4_LOCAL_BROADCAST(i)    (IPV4_CLASS_A(i)?((i)|IPV4_CLASS_A_HOST):\
    183                                          IPV4_CLASS_B(i)?((i)|IPV4_CLASS_B_HOST):\
    184                                          IPV4_CLASS_C(i)?((i)|IPV4_CLASS_C_HOST):\
    185                                          IPV4_ADDR_BROADCAST)
    186 
    187 #define MAKE_IPV4_LOCAL_MASK(i)         (IPV4_CLASS_A(i)?IPV4_CLASS_A_MASK:\
    188                                          IPV4_CLASS_B(i)?IPV4_CLASS_B_MASK:\
    189                                          IPV4_CLASS_C(i)?IPV4_CLASS_C_MASK:\
    190                                          IPV4_ADDRANY)
    191 
    192 #define MAKE_IPV4_ADDR(a,b,c,d)         ((T_IN4_ADDR)(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d)))
     135#define API_PROTO_IPVn                  'n'
     136#define API_PROTO_IPV6                  '6'
     137#define API_PROTO_IPV4                  '4'
    193138
    194139/*
    195  *  動的生成用 TCP 通信端点
     140 *  動的生成用 TCP/IPv6 通信端点
    196141 */
    197142
    198 typedef struct t_tcp_ccep {
    199         /* 標準 */
    200         ATR             cepatr;         /* 通信端点属性                       */
    201         void            *sbuf;          /* 送信用ウィンドバッファ  */
    202         int_t           sbufsz;         /* 送信用ウィンドバッファサイズ       */
    203         void            *rbuf;          /* 受信用ウィンドバッファ  */
    204         int_t           rbufsz;         /* 受信用ウィンドバッファサイズ       */
    205         FP              callback;       /* コールバック                       */
    206         /* 実装依存 */
    207         } T_TCP_CCEP;
     143#define T_TCP6_CCEP                     T_TCP_CCEP
    208144
    209145/*
    210  *  動的生成用 TCP 受付口
     146 *  バイトオーダ関数の定義
     147 *
     148 *    tinet/net/net.h でもバイトオーダの定義を行っているが、
     149 *    tinet/net/net.h をインクルードしない
     150 *    アプリケーションプログラム用に
     151 *    ターゲット依存しないバイトオーダ関数を定義する。
    211152 */
    212153
    213 #if defined(SUPPORT_INET4)
     154#if defined(_NET_CFG_BYTE_ORDER)
    214155
    215 typedef struct t_tcp_crep {
    216         /* 標準 */
    217         ATR             repatr;         /* 受付口属性                */
    218         T_IPV4EP        myaddr;         /* 自分のアドレス      */
    219         /* 実装依存 */
    220         } T_TCP_CREP;
     156/*  tinet/net/net.h をインクルードしている。*/
    221157
    222 #endif  /* of #if defined(SUPPORT_INET4) */
     158#else   /* of #if defined(_NET_CFG_BYTE_ORDER) */
    223159
    224 /*
    225  *  動的生成用 UDP 通信端点
    226  */
     160extern uint16_t ntohs (uint16_t net);
     161extern uint16_t htons (uint16_t host);
     162extern uint32_t ntohl (uint32_t net);
     163extern uint32_t htonl (uint32_t host);
    227164
    228 #if defined(SUPPORT_INET4)
     165#define NTOHS(n)        (n=ntohs(n))
     166#define HTONS(h)        (h=htons(h))
     167#define NTOHL(n)        (n=ntohl(n))
     168#define HTONL(h)        (h=htonl(h))
    229169
    230 typedef struct t_udp_ccep {
    231         /* 標準 */
    232         ATR             cepatr;         /* UDP 通信端点属性           */
    233         T_IPV4EP        myaddr;         /* 自分のアドレス              */
    234         FP              callback;       /* コールバック関数             */
    235         /* 実装依存 */
    236         } T_UDP_CCEP;
    237 
    238 #endif  /* of #if defined(SUPPORT_INET4) */
    239 
    240 /*
    241  *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
    242  */
    243 
    244 #if defined(SUPPORT_INET4)
    245 
    246 #define T_IN_ADDR                       T_IN4_ADDR
    247 #define T_IPEP                          T_IPV4EP
    248 #define IP_ADDRANY                      IPV4_ADDRANY
    249 
    250 #define IN_ARE_ADDR_EQUAL(n,h)          (*(n)==*(h))
    251 #define IN_ARE_NET_ADDR_EQUAL(n,h)      (ntohl(*(n))==*(h))
    252 #define IN_COPY_TO_NET(d,s)             (*(d)=htonl(*(s)))
    253 #define IN_COPY_TO_HOST(d,s)            (*(d)=ntohl(*(s)))
    254 #define IN_IS_ADDR_MULTICAST(a)         IN4_IS_ADDR_MULTICAST(*(a))
    255 #define IN_IS_NET_ADDR_MULTICAST(a)     IN4_IS_ADDR_MULTICAST(ntohl(*(a)))
    256 #define IN_IS_ADDR_ANY(a)               (*(a)==IPV4_ADDRANY)
    257 
    258 #endif  /* of #if defined(SUPPORT_INET4) */
     170#endif  /* of #if defined(_NET_CFG_BYTE_ORDER) */
    259171
    260172/*
     
    264176extern const char *in_strtfn (FN fncd);
    265177
    266 #if defined(SUPPORT_INET4)
    267 
    268 extern ER in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask);
    269 extern ER in4_add_route (int_t index, T_IN4_ADDR target,
    270                                       T_IN4_ADDR mask, T_IN4_ADDR gateway);
    271 extern char *ip2str (char *buf, const T_IN4_ADDR *p_ipaddr);
    272 extern const T_IN4_ADDR *in4_get_ifaddr (int_t index);
    273 
    274 #endif  /* of #if defined(SUPPORT_INET4) */
    275 
    276178#endif  /* of #ifndef _IN_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h

    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 *
     
    6666#define tcp_drop                _tinet_tcp_drop
    6767#define tcp_respond             _tinet_tcp_respond
    68 #define tcp_set_header          _tinet_tcp_set_header
    6968#define tcp_get_segment         _tinet_tcp_get_segment
    7069#define tcp_rexmt_val           _tinet_tcp_rexmt_val
    7170#define tcp_init_cep            _tinet_tcp_init_cep
    7271#define tcp_notify              _tinet_tcp_notify
    73 #define tcp_find_cep            _tinet_tcp_find_cep
    7472#define tcp_alloc_auto_port     _tinet_tcp_alloc_auto_port
    7573#define tcp_alloc_port          _tinet_tcp_alloc_port
     
    8381#define tcp_output_trace        _tinet_tcp_output_trace
    8482#define tcp_input_trace         _tinet_tcp_input_trace
     83#define tcp_find_cep            _tinet_tcp_find_cep
     84#define tcp_find_twcep          _tinet_tcp_find_twcep
     85#define tcp_is_addr_accept      _tinet_tcp_is_addr_accept
     86#define tcp_move_twcep          _tinet_tcp_move_twcep
     87#define tcpn_get_segment        _tinet_tcpn_get_segment
    8588
    8689/* netinet/tcp_subr_cs.c */
     
    136139/* tcp_cfg.c */
    137140
    138 #define tcp_rep                 _tinet_tcp_rep
     141#define tcp6_rep                _tinet_tcp6_rep
     142#define tcp4_rep                _tinet_tcp4_rep
    139143#define tcp_cep                 _tinet_tcp_cep
    140144#define tcp_twcep               _tinet_tcp_twcep
     
    146150/* netinet/udp_input.c */
    147151
    148 #define udp_input               _tinet_udp_input
     152#define udp6_reply_no_port      _tinet_udp6_reply_no_port
     153#define udp6_input_select       _tinet_udp6_input_select
     154#define udp6_input              _tinet_udp6_input
     155#define udp4_reply_no_port      _tinet_udp4_reply_no_port
     156#define udp4_input_select       _tinet_udp4_input_select
     157#define udp4_input              _tinet_udp4_input
    149158
    150159/* netinet/udp_subr.c */
    151160
    152 #define udp_alloc_port          _tinet_udp_alloc_port
    153 #define udp_alloc_auto_port     _tinet_udp_alloc_auto_port
     161#define udp6_alloc_port         _tinet_udp6_alloc_port
     162#define udp6_alloc_auto_port    _tinet_udp6_alloc_auto_port
     163#define udp6_notify             _tinet_udp6_notify
     164#define udp6_find_cep           _tinet_udp6_find_cep
     165#define udp4_alloc_port         _tinet_udp4_alloc_port
     166#define udp4_alloc_auto_port    _tinet_udp4_alloc_auto_port
     167#define udp4_notify             _tinet_udp4_notify
     168#define udp4_find_cep           _tinet_udp4_find_cep
    154169
    155170/* netinet/udp_usrreq.c */
     
    164179/* udp_cfg.c */
    165180
    166 #define udp_cep                 _tinet_udp_cep
     181#define udp6_cep                _tinet_udp6_cep
     182#define udp4_cep                _tinet_udp4_cep
    167183#define tmax_udp_cepid          _tinet_tmax_udp_cepid
    168184#define tmax_udp_ccepid         _tinet_tmax_udp_cepid   /* TINET 1.3 との互換性のための定義 */
     
    188204/* netinet/in_subr.c */
    189205
     206#define inn_addrwithifp         _tinet_inn_addrwithifp
     207#define in_cksum_carry          _tinet_in_cksum_carry
     208#define inn_is_addr_multicast   _tinet_inn_is_addr_multicast
     209#define inn_get_datagram        _tinet_inn_get_datagram
     210#define inn_is_dstaddr_accept   _tinet_inn_is_dstaddr_accept
     211#define ip_exchg_addr           _tinet_ip_exchg_addr
     212#define inn_copy_to_host        _tinet_inn_copy_to_host
     213#define in_cksum_sum            _tinet_in_cksum_sum
     214#define inn_are_net_srcaddr_equal       \
     215                                _tinet_inn_are_net_srcaddr_equal
     216
     217/* netinet/in4_subr.c */
     218
     219#define in4_add_ifaddr          _tinet_in4_add_ifaddr
    190220#define in4_set_header          _tinet_in4_set_header
     221#define inn4_is_dstaddr_accept  _tinet_inn4_is_dstaddr_accept
     222#define in4_rtredirect          _tinet_in4_rtredirect
     223#define in_rtnewentry           _tinet_in_rtnewentry
     224#define in_cksum                _tinet_in_cksum
     225#define in4_addrwithifp         _tinet_in4_addrwithifp
     226#define in4_rtalloc             _tinet_in4_rtalloc
     227#define in4_init                _tinet_in4_init
     228#define in_rttimer              _tinet_in_rttimer
     229#define in4_get_ifaddr          _tinet_in4_get_ifaddr
    191230#define in4_get_datagram        _tinet_in4_get_datagram
     231#define in4_is_dstaddr_accept   _tinet_in4_is_dstaddr_accept
    192232#define in4_cksum               _tinet_in4_cksum
    193 #define in4_rtalloc             _tinet_in4_rtalloc
    194 #define in4_rtredirect          _tinet_in4_rtredirect
    195 #define in4_init                _tinet_in4_init
    196 #define in4_is_dstaddr_accept   _tinet_in4_is_dstaddr_accept
     233#define in_rtinit               _tinet_in_rtinit
    197234#define in4_ifawithifp          _tinet_in4_ifawithifp
    198 #define in_cksum                _tinet_in_cksum
    199 #define in_cksum_carry          _tinet_in_cksum_carry
    200 #define in_cksum_sum            _tinet_in_cksum_sum
    201 #define in_rtnewentry           _tinet_in_rtnewentry
    202 #define in_rtinit               _tinet_in_rtinit
    203 #define in_rttimer              _tinet_in_rttimer
    204235
    205236/* netinet/if_ether.c */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_subr.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 *
     
    7171#include <kernel.h>
    7272#include <sil.h>
    73 #include <t_syslog.h>
    7473#include "kernel_cfg.h"
    7574
     
    9190#include <net/if_ppp.h>
    9291#include <net/ethernet.h>
    93 #include <net/ppp_ipcp.h>
    9492#include <net/net.h>
     93#include <net/net_endian.h>
    9594#include <net/net_var.h>
    9695#include <net/net_buf.h>
     
    9897
    9998#include <netinet/in.h>
    100 #include <netinet6/in6.h>
    10199#include <netinet/in_var.h>
    102 #include <netinet/in_itron.h>
    103100#include <netinet/ip.h>
    104101#include <netinet/ip_var.h>
    105 #include <netinet/tcp_timer.h>
     102#include <netinet/in_itron.h>
    106103
    107104#include <net/if_var.h>
    108105
    109 #if defined(SUPPORT_INET4)
    110 
    111 /*
    112  *  in4_get_ifaddr -- インタフェースに設定されているアドレスを返す。
    113  */
    114 
    115 const T_IN4_ADDR *
    116 in4_get_ifaddr (int_t index)
    117 {
    118         T_IFNET         *ifp = IF_GET_IFNET();
    119 
    120         return &ifp->in_ifaddr.addr;
    121         }
    122 
    123 /*
    124  *  ip2str -- IPv4 アドレスを文字列に変換する。
     106/*
     107 *  in_cksum_sum -- チェックサムの合計計算関数
     108 *
     109 *  注意: data は 4 オクテット単位でパディングすること。
     110 *        data が 2 オクテット単位にアラインされていないと
     111 *        例外が発生する可能性がある。
     112 *        len  は 4 オクテット単位にアラインされていること。
     113 *
     114 *        戻り値はホストバイトオーダ
     115 */
     116
     117uint32_t
     118in_cksum_sum (void *data, uint_t len /*オクテット単位*/)
     119{
     120        uint32_t sum = 0;
     121
     122        for ( ; len > 0; len -= 2) {
     123                sum += *((uint16_t*)data);
     124                data = (uint8_t*)data + 2;
     125                }
     126
     127#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     128        return sum;
     129#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
     130        return ((sum >> 8) & 0xffff) + ((sum & 0xff) << 8) + ((sum >> 24) & 0xff);
     131#endif  /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
     132
     133        }
     134
     135/*
     136 *  in_cksum_carry -- チェックサムの桁上げ計算関数
     137 *
     138 *  注意: data は 4 オクテット単位でパディングすること。
     139 *        data が 2 オクテット単位にアラインされていないと
     140 *        例外が発生する可能性がある。
     141 *        len  は 4 オクテット単位にアラインされていること。
     142 */
     143
     144uint32_t
     145in_cksum_carry (uint32_t sum)
     146{
     147        uint32_t        carry;
     148
     149        while (sum >= 0x00010000) {
     150                carry = sum >> 16;
     151                sum   = (sum & 0xffff) + carry;
     152                }
     153
     154        return sum;
     155        }
     156
     157/*
     158 *  in_strtfn -- API 機能コードの文字表現を返す。
     159 */
     160
     161typedef struct t_strtfn {
     162        FN              fncd;   /* API 機能コード    */
     163        const char      *str;   /* 文字表現         */
     164        } T_STRTFN;
     165
     166const T_STRTFN strtfn[] = {
     167        { TEV_TCP_RCV_OOB,      "TEV_TCP_RCV_OOB" },
     168        { TFN_TCP_DEL_REP,      "TFN_TCP_DEL_REP" },
     169        { TFN_TCP_CRE_CEP,      "TFN_TCP_CRE_CEP" },
     170        { TFN_TCP_DEL_CEP,      "TFN_TCP_DEL_CEP" },
     171        { TFN_TCP_ACP_CEP,      "TFN_TCP_ACP_CEP" },
     172        { TFN_TCP_CON_CEP,      "TFN_TCP_CON_CEP" },
     173        { TFN_TCP_SHT_CEP,      "TFN_TCP_SHT_CEP" },
     174        { TFN_TCP_CLS_CEP,      "TFN_TCP_CLS_CEP" },
     175        { TFN_TCP_SND_DAT,      "TFN_TCP_SND_DAT" },
     176        { TFN_TCP_RCV_DAT,      "TFN_TCP_RCV_DAT" },
     177        { TFN_TCP_GET_BUF,      "TFN_TCP_GET_BUF" },
     178        { TFN_TCP_SND_BUF,      "TFN_TCP_SND_BUF" },
     179        { TFN_TCP_RCV_BUF,      "TFN_TCP_RCV_BUF" },
     180        { TFN_TCP_REL_BUF,      "TFN_TCP_REL_BUF" },
     181        { TFN_TCP_SND_OOB,      "TFN_TCP_SND_OOB" },
     182        { TFN_TCP_RCV_OOB,      "TFN_TCP_RCV_OOB" },
     183        { TFN_TCP_CAN_CEP,      "TFN_TCP_CAN_CEP" },
     184        { TFN_TCP_SET_OPT,      "TFN_TCP_SET_OPT" },
     185        { TFN_TCP_GET_OPT,      "TFN_TCP_GET_OPT" },
     186        { TFN_TCP_ALL,          "TFN_TCP_ALL"     },
     187
     188        { TEV_UDP_RCV_DAT,      "TEV_UDP_RCV_DAT" },
     189        { TFN_UDP_DEL_CEP,      "TFN_UDP_DEL_CEP" },
     190        { TFN_UDP_SND_DAT,      "TFN_UDP_SND_DAT" },
     191        { TFN_UDP_RCV_DAT,      "TFN_UDP_RCV_DAT" },
     192        { TFN_UDP_CAN_CEP,      "TFN_UDP_CAN_CEP" },
     193        { TFN_UDP_SET_OPT,      "TFN_UDP_SET_OPT" },
     194        { TFN_UDP_GET_OPT,      "TFN_UDP_GET_OPT" },
     195        };
     196
     197const char *
     198in_strtfn (FN fncd)
     199{
     200        int_t   ix;
     201
     202        for (ix = sizeof(strtfn) / sizeof(T_STRTFN); ix -- > 0; )
     203                if (strtfn[ix].fncd == fncd)
     204                        return strtfn[ix].str;
     205
     206        return "unknown TFN";
     207        }
     208
     209#if defined(_IP4_CFG)
     210
     211/*
     212 *  ipv42str -- IPv4 アドレスを文字列に変換する。
    125213 */
    126214
    127215char *
    128 ip2str (char *buf, const T_IN4_ADDR *ipaddr)
     216ipv42str (char *buf, const T_IN4_ADDR *ipaddr)
    129217{
    130218        static char     addr_sbuf[NUM_IPV4ADDR_STR_BUFF][sizeof("123.123.123.123")];
     
    153241        }
    154242
    155 /*
    156  *  in4_set_header -- IPv4 ヘッダを設定する。
     243#endif  /* of #if defined(_IP4_CFG) */
     244
     245/*
     246 *  in6_is_addr_ipv4mapped -- IPv4 射影アドレスである事を検査する。
     247 */
     248
     249bool_t
     250in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr)
     251{
     252        return IN6_IS_ADDR_V4MAPPED(addr);
     253        }
     254
     255#if defined(_IP6_CFG) && defined(_IP4_CFG)
     256
     257/*
     258 *  ip_exchg_addr -- IP アドレスを交換する。
     259 */
     260
     261static void
     262ip6_exchg_addr (T_NET_BUF *nbuf)
     263{
     264        T_IP6_HDR       *iph;
     265        T_IN6_ADDR      ipaddr;
     266
     267        iph  = GET_IP6_HDR(nbuf);
     268
     269        /* IPv6 アドレスを交換する。*/
     270        ipaddr = iph->src;
     271        iph->src = iph->dst;
     272        iph->dst = ipaddr;
     273        }
     274
     275static void
     276ip4_exchg_addr (T_NET_BUF *nbuf)
     277{
     278        T_IP4_HDR       *iph;
     279        T_IN4_ADDR      ipaddr;
     280
     281        iph  = GET_IP4_HDR(nbuf);
     282
     283        /* IPv4 アドレスを交換する。*/
     284        ipaddr = iph->src;
     285        iph->src = iph->dst;
     286        iph->dst = ipaddr;
     287        }
     288
     289void
     290ip_exchg_addr (T_NET_BUF *nbuf)
     291{
     292        if (GET_IP_VER(nbuf) == 6)
     293                ip6_exchg_addr(nbuf);
     294        else
     295                ip4_exchg_addr(nbuf);
     296        }
     297
     298#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     299
     300/*
     301 *  ip_exchg_addr -- IP アドレスを交換する。
     302 */
     303
     304void
     305ip_exchg_addr (T_NET_BUF *nbuf)
     306{
     307        T_IP_HDR        *iph;
     308        T_IN_ADDR       ipaddr;
     309
     310        iph  = GET_IP_HDR(nbuf);
     311
     312        /* IP アドレスを交換する。*/
     313        ipaddr = iph->src;
     314        iph->src = iph->dst;
     315        iph->dst = ipaddr;
     316        }
     317
     318#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     319
     320#if defined(_IP6_CFG) && defined(_IP4_CFG)
     321
     322/*
     323 *  inn_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
     324 */
     325
     326bool_t
     327inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf)
     328{
     329        if        (GET_IP_VER(nbuf)==IPV6_VERSION)
     330                return INN6_IS_DSTADDR_ACCEPT(myaddr, nbuf);
     331        else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
     332                T_IP4_HDR       *ip4h;
     333
     334                ip4h  = GET_IP4_HDR(nbuf);
     335                if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
     336                        return ntohl(ip4h->dst) == IF_GET_IFNET()->in4_ifaddr.addr;
     337                else {
     338                        T_IN6_ADDR      dstaddr;
     339
     340                        return IN6_ARE_ADDR_EQUAL(myaddr, in6_make_ipv4mapped(&dstaddr, ntohl(ip4h->dst)));
     341                        }
     342                }
     343        }
     344
     345/*
     346 *  inn_are_net_srcaddr_equal -- アドレスが同一かチェックする。
     347 */
     348
     349bool_t
     350inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf)
     351{
     352        if        (GET_IP_VER(nbuf)==IPV6_VERSION)
     353                return IN6_ARE_ADDR_EQUAL(ipaddr, &GET_IP6_HDR(nbuf)->src);
     354        else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
     355
     356
     357                T_IN6_ADDR      srcaddr;
     358
     359                return IN6_ARE_ADDR_EQUAL(ipaddr, in6_make_ipv4mapped(&srcaddr, ntohl(GET_IP4_HDR(nbuf)->src)));
     360                }
     361        }
     362
     363/*
     364 *  inn_copy_to_host -- IP ヘッダからホスト表現変換して、IP アドレスをコピーする。
     365 */
     366
     367void
     368inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf)
     369{
     370        if        (GET_IP_VER(nbuf)==IPV6_VERSION)
     371                memcpy(dst, &GET_IP6_HDR(nbuf)->src, sizeof(T_IN6_ADDR));
     372        else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/
     373                in6_make_ipv4mapped(dst, ntohl(GET_IP4_HDR(nbuf)->src));
     374
     375        }
     376
     377/*
     378 *  inn_get_datagram -- IPv6/IPv4 データグラムを獲得し、ヘッダを設定する。
    157379 */
    158380
    159381ER
    160 in4_set_header (T_NET_BUF *nbuf, uint_t len,
    161                 T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl)
    162 {
    163         T_IP4_HDR       *ip4h = GET_IP4_HDR(nbuf);
    164         T_IFNET         *ifp = IF_GET_IFNET();
    165 
    166         /* IP ヘッダを設定する。*/
    167         ip4h->vhl       = IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
    168         ip4h->len       = htons(IP4_HDR_SIZE + len);
    169         ip4h->proto     = proto;
    170         ip4h->ttl       = ttl;
    171         ip4h->type      = 0;
    172         ip4h->id        = ip4h->flg_off = ip4h->sum = 0;
    173 
    174         /* IP アドレスを設定する。*/
    175         ip4h->dst       = htonl(*dstaddr);
    176 
    177         if (srcaddr == NULL || *srcaddr == IPV4_ADDRANY)
    178                 ip4h->src = htonl(ifp->in_ifaddr.addr);
     382inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
     383                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     384                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
     385{
     386        if (IN6_IS_ADDR_V4MAPPED(dstaddr)) {
     387                T_IN4_ADDR ip4dstaddr, ip4srcaddr;
     388
     389                ip4dstaddr = ntohl(dstaddr->s6_addr32[3]);
     390                if (IN6_IS_ADDR_UNSPECIFIED(srcaddr))
     391                        ip4srcaddr = IF_GET_IFNET()->in4_ifaddr.addr;
     392                else
     393                        ip4srcaddr = ntohl(srcaddr->s6_addr32[3]);
     394
     395                return in4_get_datagram(nbuf, len, maxlen, &ip4dstaddr, &ip4srcaddr, next, hlim, nbatr, tmout);
     396                }
    179397        else
    180                 ip4h->src = htonl(*srcaddr);
    181 
    182         return E_OK;
    183         }
    184 
    185 /*
    186  *  in4_get_datagram -- IPv4 データグラムを獲得し、ヘッダを設定する。
    187  */
    188 
    189 ER
    190 in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
    191                   T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
    192                   uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout)
    193 {
    194         ER      error;
    195         uint_t  align;
    196 
    197         /* データ長を 4 オクテット境界に調整する。*/
    198         align = (len + 3) >> 2 << 2;
    199 
    200         /* ネットワークバッファを獲得する。*/
    201         if ((error = tget_net_buf_ex(nbuf, (uint_t)(IF_IP4_HDR_SIZE + align),
    202                                            (uint_t)(IF_IP4_HDR_SIZE + maxlen), nbatr, tmout)) != E_OK)
    203                 return error;
    204 
    205         /*
    206          *  より大きなサイズのネットワークバッファを獲得する場合のみ長さを調整する。
    207          *  より小さなサイズのネットワークバッファの獲得は、送信ウィンドバッファの
    208          *  省コピー機能で使用され、実際に送信するまで、データサイズは決定できない。
    209          */
    210         if ((nbatr & NBA_SEARCH_ASCENT) != 0)
    211                 (*nbuf)->len = (uint16_t)(IF_IP4_HDR_SIZE + len);
    212 
    213         /* IP ヘッダを設定する。*/
    214         if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
    215                 return error;
    216 
    217         /* 4 オクテット境界までパディングで埋める。*/
    218         if (align > len)
    219                 memset((GET_IP4_SDU(*nbuf) + len), 0, (size_t)(align - len));
    220 
    221         return E_OK;
    222         }
    223 
    224 /*
    225  *  in4_cksum -- IPv4 のトランスポート層ヘッダのチェックサムを計算する。
    226  *
    227  *  注意: 戻り値はネットワークバイトオーダ
    228  */
     398                return in6_get_datagram(nbuf, len, maxlen, dstaddr, srcaddr, next, hlim, nbatr, tmout);
     399        }
     400
     401/*
     402 * inn_addrwithifp -- 宛先アドレスにふさわしい送信元アドレスを、
     403 *                   ネットワークインタフェースから探索する。
     404 */
     405
     406T_IN6_ADDR *
     407inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst)
     408{
     409        T_IN6_IFADDR *ifaddr;
     410
     411        if (IN6_IS_ADDR_V4MAPPED(dst))
     412                return in6_make_ipv4mapped (src, ifp->in4_ifaddr.addr);
     413        else if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
     414                return NULL;
     415        else {
     416                *src = ifaddr->addr;
     417                return src;
     418                }
     419        }
     420
     421/*
     422 *  inn_is_addr_multicast -- アドレスがマルチキャストアドレスかチェックする。
     423 */
     424
     425bool_t
     426inn_is_addr_multicast (T_IN6_ADDR *addr)
     427{
     428
     429        if (IN6_IS_ADDR_V4MAPPED(addr))
     430                return IN4_IS_ADDR_MULTICAST(ntohl(addr->s6_addr32[3]));
     431        else
     432                return IN6_IS_ADDR_MULTICAST(addr);
     433        }
     434
     435#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     436
     437/*
     438 *  バイトオーダ関数の定義
     439 *
     440 *    tinet/net/net.h でもバイトオーダの定義を行っているが、
     441 *    tinet/net/net.h をインクルードしない
     442 *    アプリケーションプログラム用に
     443 *    ターゲット依存しないバイトオーダ関数を定義する。
     444 */
     445
     446#if defined(_NET_CFG_BYTE_ORDER)
     447
     448#undef ntohs
     449#undef htons
     450#undef ntohl
     451#undef htonl
     452
     453#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
    229454
    230455uint16_t
    231 in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len)
    232 {
    233         uint32_t        sum;
    234         uint_t          align;
    235 
    236         /* 4 オクテット境界のデータ長 */
    237         align = (len + 3) >> 2 << 2;
    238 
    239         /* 4 オクテット境界までパディングで埋める。*/
    240         if (align > len)
    241                 memset((uint8_t*)nbuf->buf + off + len, 0, (size_t)(align - len));
    242 
    243         sum = in_cksum_sum(nbuf->buf + off, align)
    244             + in_cksum_sum(&GET_IP4_HDR(nbuf)->src, sizeof(T_IN4_ADDR) * 2)
    245             + len + proto;
    246         sum = in_cksum_carry(sum);
    247 
    248         return (uint16_t)(~htons((uint16_t)sum));
    249         }
    250 
    251 /*
    252  *  in_cksum -- チェックサム計算関数、IPv4、ICMPv4 用
    253  *
    254  *  注意: data は 4 オクテット単位でパディングすること。
    255  *        data が 2 オクテット単位にアラインされていないと
    256  *        例外が発生する可能性がある。
    257  *        len  は 4 オクテット単位にアラインされていること。
    258  *
    259  *        戻り値はネットワークバイトオーダ
    260  */
     456ntohs (uint16_t net)
     457{
     458        return net;
     459        }
    261460
    262461uint16_t
    263 in_cksum (void *data, uint_t len /*オクテット単位*/)
    264 {
    265         uint16_t        sum;
    266 
    267         sum = (uint16_t)in_cksum_carry(in_cksum_sum(data, len));
    268         return (uint16_t)(~htons(sum));
    269         }
    270 
    271 /*
    272  *  in4_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
    273  *
    274  *    注意: dstaddr は、
    275  *          TINET-1.2 からネットワークバイトオーダ、
    276  *          TINET-1.1 までは、ホストバイトオーダ
    277  */
    278 
    279 bool_t
    280 in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
    281 {
    282         if (*myaddr == IPV4_ADDRANY)
    283                 return ntohl(*dstaddr) == IF_GET_IFNET()->in_ifaddr.addr;
    284         else
    285                 return ntohl(*dstaddr) == *myaddr;
    286         }
    287 
    288 /*
    289  * in4_ifawithifp -- 宛先アドレスにふさわしい送信元アドレスを、
    290  *                   ネットワークインタフェースから探索する。
    291  *                   in6_ifawithifp をシミュレートするだけで、
    292  *                   エラーを返すことはない。
    293  */
    294 
    295 T_IN4_IFADDR *
    296 in4_ifawithifp (T_IFNET *ifp, T_IN4_ADDR *dst)
    297 {
    298         return &ifp->in_ifaddr;
    299         }
    300 
    301 /*
    302  *  in4_add_ifaddr -- インタフェースに IPv4 アドレスを設定する。
    303  */
    304 
    305 ER
    306 in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask)
    307 {
    308         T_IFNET *ifp = IF_GET_IFNET();
    309 
    310         ifp->in_ifaddr.addr = addr;
    311         ifp->in_ifaddr.mask = mask;
    312         return E_OK;
    313         }
    314 
    315 #if NUM_ROUTE_ENTRY > 0
    316 
    317 /*
    318  *  in4_add_route -- 経路表にエントリを設定する。
    319  */
    320 
    321 ER
    322 in4_add_route (int_t index, T_IN4_ADDR target, T_IN4_ADDR mask, T_IN4_ADDR gateway)
    323 {
    324 
    325         if (0 <= index && index < NUM_STATIC_ROUTE_ENTRY) {
    326                 routing_tbl[index].target  = target;
    327                 routing_tbl[index].mask    = mask;
    328                 routing_tbl[index].gateway = gateway;
    329                 return E_OK;
    330                 }
    331         else
    332                 return E_PAR;
    333         }
    334 
    335 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
    336 
    337 /*
    338  *  in4_rtalloc -- ルーティング表を探索する。
    339  */
    340 
    341 T_IN4_ADDR
    342 in4_rtalloc (T_IN4_ADDR dst)
    343 {
    344         int_t ix;
    345 
    346         for (ix = NUM_ROUTE_ENTRY; ix --; )
    347                 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
    348                     (dst & routing_tbl[ix].mask) == routing_tbl[ix].target) {
    349                         if (routing_tbl[ix].gateway == 0)
    350                                 return dst;
    351                         else {
    352                                 return routing_tbl[ix].gateway;
    353                                 }
    354                         }
    355         return dst;
    356         }
    357 
    358 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    359 
    360 /*
    361  *  in4_rtredirect -- ルーティング表にエントリを登録する。
    362  *
    363  *    注意: 引数 tmo の単位は [ms]。
    364  */
    365 
    366 void
    367 in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo)
    368 {
    369         T_IN_RTENTRY    *frt;
    370 
    371         frt = in_rtnewentry(flags, tmo);
    372         frt->gateway    = gateway;
    373         frt->target     = target;
    374         frt->mask       = 0xffffffff;
    375         }
    376 
    377 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
    378 
    379 /*
    380  *  in4_timer -- IPv4 共通タイマー
    381  *
    382  *    1秒周期で起動される。
    383  */
    384 
    385 static void
    386 in4_timer (void *ignore)
    387 {
    388 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    389 
    390         in_rttimer();
    391 
    392 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
    393 
    394 #ifdef IP4_CFG_FRAGMENT
    395 
    396         ip_frag_timer();
    397 
    398 #endif  /* of #ifdef IP4_CFG_FRAGMENT */
    399 
    400         timeout(in4_timer, NULL, IN_TIMER_TMO);
    401         }
    402 
    403 /*
    404  *  in4_init -- IPv4 共通機能を初期化する。
    405  */
    406 
    407 void
    408 in4_init (void)
    409 {
    410 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    411 
    412         in_rtinit();
    413 
    414 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
    415 
    416         timeout(in4_timer, NULL, IN_TIMER_TMO);
    417         }
    418 
    419 #endif  /* of #if defined(SUPPORT_INET4) */
    420 
    421 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    422 
    423 /*
    424  *  in_rtinit -- ルーティング表を初期化する。
    425  */
    426 
    427 void
    428 in_rtinit (void)
    429 {
    430         int_t ix;
    431 
    432         for (ix = 0; ix < NUM_STATIC_ROUTE_ENTRY; ix ++)
    433                 routing_tbl[ix].flags = IN_RTF_DEFINED;
    434 
    435         for ( ; ix < NUM_ROUTE_ENTRY; ix ++)
    436                 routing_tbl[ix].flags = 0;
    437         }
    438 
    439 /*
    440  *  in_rtnewentry -- 新しいエントリを獲得する。
    441  */
    442 
    443 T_IN_RTENTRY *
    444 in_rtnewentry (uint8_t flags, uint32_t tmo)
    445 {
    446         SYSTIM          now;
    447         T_IN_RTENTRY    *rt, *frt = NULL;
    448         int_t           ix;
    449 
    450         /* 空きエントリを探す。*/
    451         for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++) {
    452                 rt = &routing_tbl[ix];
    453                 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
    454                         frt = rt;
    455                         break;
    456                         }
    457                 }
    458 
    459         /* expire の単位は [s]。*/
    460         syscall(get_tim(&now));
    461         now /= SYSTIM_HZ;
    462 
    463         if (frt == NULL) {
    464                 /* 空きがなければ、有効時間がもっとも短いエントリを空きにする。*/
    465                 T_IN_RTENTRY    *srt = NULL;
    466                 int_t           diff, sdiff = INT_MAX;
    467 
    468                 syscall(wai_sem(SEM_IN_ROUTING_TBL));
    469                 for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++) {
    470                         rt = &routing_tbl[ix];
    471                         diff = (int_t)(rt->expire - now);
    472                         if (diff <= 0) {        /* rt->expire <= now */
    473                                 /* 既に、有効時間が過ぎている。*/
    474                                 frt = rt;
    475                                 break;
    476                                 }
    477                         else if (diff < sdiff) {
    478                                 srt = rt;
    479                                 sdiff = diff;
    480                                 }
    481                         }
    482                 if (frt == NULL)
    483                         frt = srt;
    484                 frt->flags = 0;
    485                 syscall(sig_sem(SEM_IN_ROUTING_TBL));
    486                 }
    487 
    488         frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
    489         frt->expire = now + tmo / SYSTIM_HZ;
    490         return frt;
    491         }
    492 
    493 /*
    494  *  in_rttimer -- ルーティング表の管理タイマー
    495  */
    496 
    497 void
    498 in_rttimer (void)
    499 {
    500         SYSTIM  now;
    501         int_t   ix;
    502 
    503         /* expire の単位は [s]。*/
    504         syscall(get_tim(&now));
    505         now /= SYSTIM_HZ;
    506 
    507         syscall(wai_sem(SEM_IN_ROUTING_TBL));
    508         for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++)
    509                 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
    510                     (int_t)(routing_tbl[ix].expire - now) <= 0)
    511                         routing_tbl[ix].flags = 0;
    512         syscall(sig_sem(SEM_IN_ROUTING_TBL));
    513         }
    514 
    515 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
    516 
    517 /*
    518  *  in_cksum_sum -- チェックサムの合計計算関数
    519  *
    520  *  注意: data は 4 オクテット単位でパディングすること。
    521  *        data が 2 オクテット単位にアラインされていないと
    522  *        例外が発生する可能性がある。
    523  *        len  は 4 オクテット単位にアラインされていること。
    524  *
    525  *        戻り値はホストバイトオーダ
    526  */
     462htons (uint16_t host)
     463{
     464        return host;
     465        }
    527466
    528467uint32_t
    529 in_cksum_sum (void *data, uint_t len /*オクテット単位*/)
    530 {
    531         uint32_t sum = 0;
    532 
    533         for ( ; len > 0; len -= 2) {
    534                 sum += *((uint16_t*)data);
    535                 data = (uint8_t*)data + 2;
    536                 }
    537 
    538 #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
    539         return sum;
    540 #elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
    541         return ((sum >> 8) & 0xffff) + ((sum & 0xff) << 8) + ((sum >> 24) & 0xff);
     468ntohl (uint32_t net)
     469{
     470        return net;
     471        }
     472
     473uint32_t
     474htonl (uint32_t host)
     475{
     476        return host;
     477        }
     478
     479#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN     /* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
     480
     481uint16_t
     482ntohs (uint16_t net)
     483{
     484        return NET_REV_ENDIAN_HWORD(net);
     485        }
     486
     487uint16_t
     488htons (uint16_t host)
     489{
     490        return NET_REV_ENDIAN_HWORD(host);
     491        }
     492
     493uint32_t
     494ntohl (uint32_t net)
     495{
     496        return NET_REV_ENDIAN_WORD(net);
     497        }
     498
     499uint32_t
     500htonl (uint32_t host)
     501{
     502        return NET_REV_ENDIAN_WORD(host);
     503        }
     504
     505#else   /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
     506
     507#error "_NET_CFG_BYTE_ORDER expected."
     508
    542509#endif  /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
    543510
    544         }
    545 
    546 /*
    547  *  in_cksum_carry -- チェックサムの桁上げ計算関数
    548  *
    549  *  注意: data は 4 オクテット単位でパディングすること。
    550  *        data が 2 オクテット単位にアラインされていないと
    551  *        例外が発生する可能性がある。
    552  *        len  は 4 オクテット単位にアラインされていること。
    553  */
    554 
    555 uint32_t
    556 in_cksum_carry (uint32_t sum)
    557 {
    558         uint32_t        carry;
    559 
    560         while (sum >= 0x00010000) {
    561                 carry = sum >> 16;
    562                 sum   = (sum & 0xffff) + carry;
    563                 }
    564 
    565         return sum;
    566         }
    567 
    568 /*
    569  *  in_strtfn -- API 機能コードの文字表現を返す。
    570  */
    571 
    572 const char *
    573 in_strtfn (FN fncd)
    574 {
    575         switch (fncd) {
    576 
    577         /* TCP 関係 */
    578 
    579         case TFN_TCP_CRE_REP:
    580                 return "TFN_TCP_CRE_REP";
    581                 break;
    582         case TFN_TCP_DEL_REP:
    583                 return "TFN_TCP_DEL_REP";
    584                 break;
    585         case TFN_TCP_CRE_CEP:
    586                 return "TFN_TCP_CRE_CEP";
    587                 break;
    588         case TFN_TCP_DEL_CEP:
    589                 return "TFN_TCP_DEL_CEP";
    590                 break;
    591         case TFN_TCP_ACP_CEP:
    592                 return "TFN_TCP_ACP_CEP";
    593                 break;
    594         case TFN_TCP_CON_CEP:
    595                 return "TFN_TCP_CON_CEP";
    596                 break;
    597         case TFN_TCP_SHT_CEP:
    598                 return "TFN_TCP_SHT_CEP";
    599                 break;
    600         case TFN_TCP_CLS_CEP:
    601                 return "TFN_TCP_CLS_CEP";
    602                 break;
    603         case TFN_TCP_SND_DAT:
    604                 return "TFN_TCP_SND_DAT";
    605                 break;
    606         case TFN_TCP_RCV_DAT:
    607                 return "TFN_TCP_RCV_DAT";
    608                 break;
    609         case TFN_TCP_GET_BUF:
    610                 return "TFN_TCP_GET_BUF";
    611                 break;
    612         case TFN_TCP_SND_BUF:
    613                 return "TFN_TCP_SND_BUF";
    614                 break;
    615         case TFN_TCP_RCV_BUF:
    616                 return "TFN_TCP_RCV_BUF";
    617                 break;
    618         case TFN_TCP_REL_BUF:
    619                 return "TFN_TCP_REL_BUF";
    620                 break;
    621         case TFN_TCP_SND_OOB:
    622                 return "TFN_TCP_SND_OOB";
    623                 break;
    624         case TFN_TCP_RCV_OOB:
    625                 return "TFN_TCP_RCV_OOB";
    626                 break;
    627         case TFN_TCP_CAN_CEP:
    628                 return "TFN_TCP_CAN_CEP";
    629                 break;
    630         case TFN_TCP_SET_OPT:
    631                 return "TFN_TCP_SET_OPT";
    632                 break;
    633         case TFN_TCP_GET_OPT:
    634                 return "TFN_TCP_GET_OPT";
    635                 break;
    636         case TFN_TCP_ALL:
    637                 return "ALL";
    638                 break;
    639 
    640         /* UDP 関係 */
    641 
    642         case TFN_UDP_CRE_CEP:
    643                 return "TFN_UDP_CRE_CEP";
    644                 break;
    645         case TFN_UDP_DEL_CEP:
    646                 return "TFN_UDP_DEL_CEP";
    647                 break;
    648         case TFN_UDP_SND_DAT:
    649                 return "TFN_UDP_SND_DAT";
    650                 break;
    651         case TFN_UDP_RCV_DAT:
    652                 return "TFN_UDP_RCV_DAT";
    653                 break;
    654         case TFN_UDP_CAN_CEP:
    655                 return "TFN_UDP_CAN_CEP";
    656                 break;
    657         case TFN_UDP_SET_OPT:
    658                 return "TFN_UDP_SET_OPT";
    659                 break;
    660         case TFN_UDP_GET_OPT:
    661                 return "TFN_UDP_GET_OPT";
    662                 break;
    663 
    664         default:
    665                 return "unknown TFN";
    666                 }
    667         }
     511#endif  /* of #if defined(_NET_CFG_BYTE_ORDER) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h

    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 *
     
    7171#define _IN_VAR_H_
    7272
    73 #if defined(SUPPORT_INET6)
    74 
     73#include <netinet/in4_var.h>
    7574#include <netinet6/in6_var.h>
    76 
    77 #endif  /* of #if defined(SUPPORT_INET6) */
    7875
    7976/*
     
    10299
    103100/*
    104  *  インタフェースアドレス構造体
    105  */
    106 
    107 typedef struct t_in4_ifaddr {
    108         T_IN4_ADDR              addr;           /* IPv4 アドレス    */
    109         T_IN4_ADDR              mask;           /* サブネットマスク     */
    110         } T_IN4_IFADDR;
    111 
    112 /*
    113  *  ルーティング表エントリ構造体
    114  */
    115 
    116 typedef struct t_in4_rtentry {
    117         T_IN4_ADDR      target;         /* 目標ネットワークアドレス                 */
    118         T_IN4_ADDR      mask;           /* 目標ネットワークアドレスのサブネットマスク        */
    119         T_IN4_ADDR      gateway;        /* ゲートウェイの IP アドレス                      */
    120         uint32_t        expire;         /* 有効時間が切れる時刻 [s]                       */
    121         uint8_t         flags;          /* フラグ                                  */
    122         } T_IN4_RTENTRY;
    123 
    124 /*
    125  *  TINET 1.1 との互換性のための定義
    126  */
    127 
    128 #ifdef NUM_ROUTE_ENTRY
    129 
    130 #define NUM_STATIC_ROUTE_ENTRY          NUM_ROUTE_ENTRY
    131 #define NUM_REDIRECT_ROUTE_ENTRY        0
    132 #define T_RT_ENTRY                      T_IN_RTENTRY
    133 
    134 #else   /* of #ifdef NUM_ROUTE_ENTRY */
    135 
    136 #define NUM_ROUTE_ENTRY                 \
    137         (NUM_STATIC_ROUTE_ENTRY + NUM_REDIRECT_ROUTE_ENTRY)
    138                                         /* ルーティング表のエントリ数        */
    139 
    140 #endif  /* of #ifdef NUM_ROUTE_ENTRY */
    141 
    142 /*
    143101 *  ルーティングエントリ状態フラグ
    144102 */
     
    151109 */
    152110
    153 #if defined(SUPPORT_INET4)
    154 
    155 #define IN_SET_HEADER(nbuf,len,dst,src,proto,ttl)       \
    156                                         in4_set_header(nbuf,len,dst,src,proto,ttl)
     111#if defined(_IP6_CFG)
     112
     113#define T_IN_ADDR                       T_IN6_ADDR
     114#define T_IPEP                          T_IPV6EP
     115#define IP_ADDRANY                      IPV6_ADDRANY
     116
     117#elif defined(_IP4_CFG) /* of #if defined(_IP6_CFG) */
     118
     119#define T_IN_ADDR                       T_IN4_ADDR
     120#define T_IPEP                          T_IPV4EP
     121#define IP_ADDRANY                      IPV4_ADDRANY
     122
     123#endif  /* of #if defined(_IP6_CFG) */
     124
     125#if defined(_IP6_CFG)
     126
     127#if defined(_IP4_CFG)
     128
     129#define IN_CKSUM(nbuf,proto,off,len)    (GET_IP_VER(nbuf)==IPV6_VERSION \
     130                                        ?in6_cksum(nbuf,proto,off,len)  \
     131                                        :in4_cksum(nbuf,proto,off,len))
     132#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)       \
     133                                        inn_is_dstaddr_accept(myaddr,nbuf)
     134#define IN_ARE_HDR_ADDR_EQUAL(nbuf)     (GET_IP_VER(nbuf)==IPV6_VERSION \
     135                                        ?IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)    \
     136                                        :IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src))
     137#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)   \
     138                                        inn_are_net_srcaddr_equal(ipaddr,nbuf)
     139#define IN_COPY_TO_HOST(dst,nbuf)       inn_copy_to_host(dst,nbuf)
     140#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)  \
     141                                        inn_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
     142#define IN_IS_ADDR_MULTICAST(addr)      inn_is_addr_multicast(addr)
     143#define IN_IS_NET_ADDR_MULTICAST(nbuf)  IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
     144#define IN_ADDRWITHIFP(ifp,src,dst)     inn_addrwithifp(ifp,src,dst)
     145#define IN_IS_ADDR_ANY(addr)            IN6_IS_ADDR_UNSPECIFIED(addr)
     146
     147#else   /* of #if defined(_IP4_CFG) */
     148
     149#define IN_CKSUM(nbuf,proto,off,len)    in6_cksum(nbuf,proto,off,len)
     150#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)       \
     151                                        INN6_IS_DSTADDR_ACCEPT(myaddr,nbuf)
     152#define IN_ARE_HDR_ADDR_EQUAL(nbuf)     IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)
     153#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)   \
     154                                        IN6_ARE_ADDR_EQUAL(ipaddr,&GET_IP6_HDR(nbuf)->src)
     155#define IN_COPY_TO_HOST(dst,nbuf)       IN6_COPY_TO_HOST(dst, nbuf)
     156#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)  \
     157                                        in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
     158#define IN_IS_ADDR_MULTICAST(addr)      IN6_IS_ADDR_MULTICAST(addr)
     159#define IN_IS_NET_ADDR_MULTICAST(nbuf)  IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
     160#define IN_ADDRWITHIFP(ifp,src,dst)     in6_addrwithifp(ifp,src,dst)
     161#define IN_IS_ADDR_ANY(addr)            IN6_IS_ADDR_UNSPECIFIED(addr)
     162
     163#endif  /* of #if defined(_IP4_CFG) */
     164
     165#else   /* of #if defined(_IP6_CFG) */
     166
     167#if defined(_IP4_CFG)
     168
     169#define IN_CKSUM(nbuf,proto,off,len)    in4_cksum(nbuf,proto,off,len)
     170#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)       \
     171                                        inn4_is_dstaddr_accept(myaddr,nbuf)
     172#define IN_ARE_HDR_ADDR_EQUAL(nbuf)     IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src)
     173#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)   \
     174                                        (*(ipaddr)==ntohl(GET_IP4_HDR(nbuf)->src))
     175#define IN_COPY_TO_HOST(dst,nbuf)       IN4_COPY_TO_HOST(dst, nbuf)
    157176#define IN_GET_DATAGRAM(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout) \
    158177                                        in4_get_datagram(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)
    159 #define IN_CKSUM(nbuf,proto,off,len)    in4_cksum(nbuf,proto,off,len)
    160 #define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr)                    \
    161                                         in4_is_dstaddr_accept(myaddr,dstaddr)
    162 #define IN_IFAWITHIFP(ifp,dst)          in4_ifawithifp(ifp,dst)
    163 #define T_IN_IFADDR                     T_IN4_IFADDR
    164 #define T_IN_RTENTRY                    T_IN4_RTENTRY
    165 
    166 #endif  /* of #if defined(SUPPORT_INET4) */
    167 
    168 /*
    169  *  ルーティング表
    170  */
    171 
    172 extern T_IN_RTENTRY routing_tbl[];
    173 
    174 /*
    175  *  前方参照
    176  */
    177 
    178 #ifndef T_NET_BUF_DEFINED
    179 typedef struct t_net_buf T_NET_BUF;
    180 #define T_NET_BUF_DEFINED
    181 #endif
    182 
    183 #ifndef T_IFNET_DEFINED
    184 typedef struct t_ifnet T_IFNET;
    185 #define T_IFNET_DEFINED
    186 #endif
     178#define IN_IS_ADDR_MULTICAST(addr)      IN4_IS_ADDR_MULTICAST(*(addr))
     179#define IN_IS_NET_ADDR_MULTICAST(nbuf)  IN4_IS_ADDR_MULTICAST(ntohl(GET_IP4_HDR(nbuf)->dst))
     180#define IN_ADDRWITHIFP(ifp,src,dst)     in4_addrwithifp(ifp,src,dst)
     181#define IN_IS_ADDR_ANY(addr)            IN4_IS_ADDR_ANY(addr)
     182
     183#else   /* of #if defined(_IP4_CFG) */
     184
     185#error "not implemented."
     186
     187#endif  /* of #if defined(_IP4_CFG) */
     188
     189#endif  /* of #if defined(_IP6_CFG) */
     190
     191#ifndef _MACRO_ONLY
    187192
    188193/*
    189194 *  関数
    190195 */
    191 
    192 extern void ip_input (T_NET_BUF *data);
    193 extern ER in4_set_header (T_NET_BUF *nbuf, uint_t len,
    194                           T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl);
    195 extern ER in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
    196                             T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
    197                             uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout);
    198 extern uint16_t in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
    199 extern T_IN4_ADDR in4_rtalloc (T_IN4_ADDR dst);
    200 extern void in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo);
    201 extern void in4_init (void);
    202 extern T_IN4_IFADDR *in4_ifawithifp (T_IFNET *ifp, T_IN4_ADDR *dst);
    203 extern T_IN_RTENTRY *in_rtnewentry (uint8_t flags, uint32_t tmo);
    204 extern void in_rttimer (void);
    205 extern void in_rtinit (void);
    206 extern const T_NET_BUF**ip_get_frag_queue (void);
    207 
    208 /*
    209  *  in4_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
    210  *
    211  *    注意: dstaddr は、
    212  *          TINET-1.2 からネットワークバイトオーダ、
    213  *          TINET-1.1 までは、ホストバイトオーダ
    214  */
    215 extern bool_t in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr);
    216 
    217 /*
    218  *  in_cksum -- チェックサム計算関数、IPv4、ICMPv4 用
    219  *
    220  *  注意: data は 4 オクテット単位でパディングすること。
    221  *        data が 2 オクテット単位にアラインされていないと
    222  *        例外が発生する可能性がある。
    223  *        len  は 4 オクテット単位にアラインされていること。
    224  */
    225 extern uint16_t in_cksum(void *data, uint_t len /*オクテット単位*/);
    226 
    227 /*
    228  *  in_cksum_sum -- チェックサムの合計計算関数
    229  *
    230  *  注意: data は 4 オクテット単位でパディングすること。
    231  *        data が 2 オクテット単位にアラインされていないと
    232  *        例外が発生する可能性がある。
    233  *        len  は 4 オクテット単位にアラインされていること。
    234  */
    235 extern uint32_t in_cksum_sum (void *data, uint_t len /*オクテット単位*/);
    236 
    237 /*
    238  *  in_cksum_carry -- チェックサムの桁上げ計算関数
    239  *
    240  *  注意: data は 4 オクテット単位でパディングすること。
    241  *        data が 2 オクテット単位にアラインされていないと
    242  *        例外が発生する可能性がある。
    243  *        len  は 4 オクテット単位にアラインされていること。
    244  */
    245 extern uint32_t in_cksum_carry (uint32_t sum);
     196extern bool_t   inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf);
     197extern bool_t   inn_is_addr_multicast (T_IN6_ADDR *addr);
     198extern bool_t   inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf);
     199extern void     inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf);
     200extern ER       inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
     201                                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     202                                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
     203extern T_IN6_ADDR *inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst);
     204
     205#endif  /* of #ifndef _MACRO_ONLY */
    246206
    247207#endif  /* of #ifndef _IN_VAR_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.cfg

    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 *
     
    3636 */
    3737
    38 #if defined(SUPPORT_INET4)
     38#if defined(_IP4_CFG)
    3939
    4040#ifdef IP4_CFG_FRAGMENT
     
    4646#endif  /* of #ifdef IP4_CFG_FRAGMENT */
    4747
    48 #if NUM_REDIRECT_ROUTE_ENTRY > 0
     48#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
    4949
    5050/* ルーティング表(向け直し)*/
    5151
    52 CRE_SEM(SEM_IN_ROUTING_TBL, { TA_TPRI, 1, 1 });
     52CRE_SEM(SEM_IN4_ROUTING_TBL, { TA_TPRI, 1, 1 });
    5353
    54 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     54#endif  /* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
    5555
    56 #endif  /* of #if defined(SUPPORT_INET4) */
     56#endif  /* of #if defined(_IP4_CFG) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.h

    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 *
     
    7171#define _IP4_H_
    7272
     73#include <netinet/ip6.h>
     74
    7375/*
    7476 *  IPv4 の定義、RFC791 参照
     
    134136/* IPv4 と IPv6 をコンパイル時に選択するためのマクロ */
    135137
    136 #if defined(SUPPORT_INET4)
     138#if !defined(_IP6_CFG) && defined(_IP4_CFG)
    137139
    138140#define IP_HDR_SIZE     IP4_HDR_SIZE
     
    140142#define IP_DEFTTL       IP4_DEFTTL
    141143
    142 #endif  /* of #if defined(SUPPORT_INET4) */
     144#endif  /* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
    143145
    144146#endif  /* of #ifndef _IP4_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip6.h

    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 *
     
    102102#define _IP6_H_
    103103
    104 #ifdef SUPPORT_INET6
    105 
    106104/*
    107105 *  IPv6 の定義、RFC2460 参照
     
    262260
    263261/*
    264  *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
     262 *  IPv6 と IPv4 をコンパイル時に選択するためのマクロ
    265263 */
    266264
     
    273271/* ルータ通知を受信する場合は、通知された値 */
    274272
    275 #define IP_DEFTTL       ip6_defhlim
     273#define IP6_DEFTTL      ip6_defhlim
    276274
    277275#else   /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
     
    279277/* ルータ通知を受信しない場合の値は既定値 */
    280278
    281 #define IP_DEFTTL       IPV6_DEFHLIM
     279#define IP6_DEFTTL      IPV6_DEFHLIM
    282280
    283281#endif  /* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
     282
     283/* IPv4 と IPv6 をコンパイル時に選択するためのマクロ */
     284
     285#ifdef _IP6_CFG
    284286
    285287#define IP_HDR_SIZE     IP6_HDR_SIZE
    286288#define T_IP_HDR        T_IP6_HDR
    287 
    288 #endif  /* of #ifdef SUPPORT_INET6 */
     289#define IP_DEFTTL       IP6_DEFTTL
     290
     291#endif  /* of #ifdef _IP6_CFG */
    289292
    290293#endif  /* of #ifndef _IP6_H_ */
  • 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) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.h

    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 *
     
    7171#define _IP_ICMP_H_
    7272
     73#include <netinet/icmp6.h>
     74
    7375/*
    7476 *  ICMP ヘッダの定義、RFC 792
     
    9698#define GET_ICMP4_SDU(nbuf,ihoff)       ((uint8_t*)((nbuf)->buf) + ihoff + ICMP4_HDR_SIZE)
    9799
    98 #define GET_ICMP4_HDR_OFFSET(nbuf)      (GET_IF_IP_HDR_SIZE(nbuf))
     100#define GET_ICMP4_HDR_OFFSET(nbuf)      (GET_IF_IP4_HDR_SIZE(nbuf))
    99101
    100 #define GET_IP4_ICMP4_HDR_SIZE(nbuf)    (GET_IP4_HDR_SIZE(GET_IP4_HDR(nbuf)) + ICMP4_HDR_SIZE)
     102#define GET_IP4_ICMP4_HDR_SIZE(nbuf)    (GET_IP4_HDR_SIZE(nbuf) + ICMP4_HDR_SIZE)
    101103#define GET_IF_IP4_ICMP4_HDR_SIZE(nbuf) (IF_HDR_SIZE + GET_IP4_ICMP4_HDR_SIZE(nbuf))
    102104
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_input.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 *
     
    7777#include <t_syslog.h>
    7878#include "kernel_cfg.h"
     79#include "tinet_cfg.h"
    7980
    8081#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8586#include <t_services.h>
    8687#include "kernel_id.h"
     88#include "tinet_id.h"
    8789
    8890#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9799#include <net/ppp_ipcp.h>
    98100#include <net/net.h>
     101#include <net/net_endian.h>
    99102#include <net/net_buf.h>
    100103#include <net/net_count.h>
     
    107110#include <netinet/ip_icmp.h>
    108111#include <netinet/tcp.h>
    109 #include <netinet/tcp_timer.h>
    110112#include <netinet/tcp_var.h>
    111113#include <netinet/udp.h>
    112114#include <netinet/udp_var.h>
     115#include <netinet/ip_igmp.h>
    113116
    114117#if defined(SUPPORT_IPSEC)
     
    122125
    123126#include <net/if_var.h>
     127
     128#if defined(_IP4_CFG)
    124129
    125130/*
     
    345350ip_remove_options (T_NET_BUF *nbuf)
    346351{
    347         T_IP_HDR        *iph;
    348 
    349         iph  = GET_IP_HDR(nbuf);
    350 
    351         if (GET_IP_HDR_SIZE(iph) > IP4_HDR_SIZE) {
    352                 memmove((char *)iph + IP4_HDR_SIZE, GET_IP_SDU(nbuf),
    353                         (size_t)(iph->len - GET_IP_HDR_SIZE(iph)));
     352        T_IP4_HDR       *iph;
     353        uint_t          hdr_size;
     354
     355        iph  = GET_IP4_HDR(nbuf);
     356        hdr_size = GET_IP4_HDR_SIZE(nbuf);
     357
     358        if (hdr_size > IP4_HDR_SIZE) {
     359                memmove((char *)iph + IP4_HDR_SIZE, GET_IP4_SDU(nbuf),
     360                        (size_t)(iph->len - hdr_size));
    354361                iph->vhl   = IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
    355                 iph->len  -= (uint16_t)(GET_IP_HDR_SIZE(iph) - IP4_HDR_SIZE);
    356                 nbuf->len -= (uint16_t)(GET_IP_HDR_SIZE(iph) - IP4_HDR_SIZE);
     362                iph->len  -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
     363                nbuf->len -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
    357364                }
    358365
     
    389396                }
    390397
    391         ip4h  = GET_IP4_HDR(input);
    392         hlen = GET_IP4_HDR_SIZE(ip4h);
     398        ip4h = GET_IP4_HDR(input);
     399        hlen = GET_IP4_HDR_SIZE(input);
    393400
    394401        /* バージョンをチェックする。*/
     
    429436        /* 送信元アドレスをチェックする。*/
    430437        src = ntohl(ip4h->src);
    431         bc  = (ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask;
     438        bc  = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
    432439
    433440#ifdef SUPPORT_LOOP
     
    441448#else   /* of #ifdef SUPPORT_LOOP */
    442449
    443         if (src == ifp->in_ifaddr.addr || src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
     450        if (src == ifp->in4_ifaddr.addr || src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
    444451                NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
    445452                NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
     
    459466         */
    460467
    461         if ((ifp->in_ifaddr.addr != IPV4_ADDRANY) &&
    462             (!(dst == ifp->in_ifaddr.addr || dst == bc ||
    463                dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY))) {
     468#if defined(ETHER_CFG_MULTICAST)
     469        if ((ifp->in4_ifaddr.addr != IPV4_ADDRANY) &&
     470                (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
     471                   dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY ||
     472                  IN4_IS_ADDR_MULTICAST(dst)))) {
    464473                NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
    465474                NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
    466475                goto buf_rel;
    467476                }
     477#else
     478        if ((ifp->in4_ifaddr.addr != IPV4_ADDRANY) &&
     479            (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
     480               dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY))) {
     481                NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
     482                NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
     483                goto buf_rel;
     484                }
     485#endif
    468486
    469487#else   /* of #ifdef DHCP_CFG */
    470488
    471489#if defined(ETHER_CFG_MULTICAST)
    472         if (!(dst == ifp->in_ifaddr.addr || dst == bc ||
     490        if (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
    473491                  dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY ||
    474492                  IN4_IS_ADDR_MULTICAST(dst))) {
     
    478496                }
    479497#else
    480         if (!(dst == ifp->in_ifaddr.addr || dst == bc ||
    481               dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY)) {
     498        if (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
     499              dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY)) {
    482500                NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
    483501                NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
     
    525543        switch (ip4h->proto) {
    526544
    527 #ifdef SUPPORT_UDP
    528         case IPPROTO_UDP:
    529                 NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
    530                 udp_input(&input, &off, NULL);
    531                 return;
    532                 break;
    533 #endif  /* of #ifdef SUPPORT_UDP */
    534 
    535 #ifdef SUPPORT_TCP
     545#if defined(SUPPORT_TCP)
    536546        case IPPROTO_TCP:
    537547                NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
     
    539549                return;
    540550                break;
    541 #endif  /* of #ifdef SUPPORT_UDP */
     551#endif  /* of #if defined(SUPPORT_TCP) */
     552
     553#if defined(SUPPORT_UDP) && ( (TNUM_UDP4_CEPID > 0) || \
     554                             ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
     555        case IPPROTO_UDP:
     556                NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
     557                udp4_input(&input, &off, NULL);
     558                return;
     559                break;
     560#endif  /* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
    542561
    543562        case IPPROTO_ICMP:
     
    546565                return;
    547566                break;
     567
     568#if defined(SUPPORT_IGMP)
     569        case IPPROTO_IGMP:
     570                NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
     571                igmp_input(&input, &off, NULL);
     572                return;
     573                break;
     574#endif /* of #ifdef UDP_CFG_EXTENTIONS */
    548575
    549576#if defined(SUPPORT_IPSEC)
     
    560587
    561588                /* ローカル IP アドレスに届いたデータグラムのみ ICMP エラーを通知する。*/
    562                 if (dst == ifp->in_ifaddr.addr) {
     589                if (dst == ifp->in4_ifaddr.addr) {
    563590                        T_IN4_ADDR      src;
    564591
     
    578605        syscall(rel_net_buf(input));
    579606        }
     607
     608#endif  /* of #if defined(_IP4_CFG) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_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 *
     
    9393#include <net/ppp.h>
    9494#include <net/net.h>
     95#include <net/net_endian.h>
    9596#include <net/net_buf.h>
    9697#include <net/net_count.h>
     
    104105#include <netinet6/ipsec.h>
    105106#endif
     107
     108#if defined(_IP4_CFG)
    106109
    107110static uint16_t frag_id = 0;
     
    221224
    222225                len  = ntohs(ip4h->len);
    223                 off  = hlen = GET_IP4_HDR_SIZE(ip4h);
     226                off  = hlen = GET_IP4_HDR_SIZE(output);
    224227                while (off < len) {
    225228                        if (off + (IF_MTU - IP4_HDR_SIZE) < len)
     
    245248                                fip4h->id       = htons(frag_id);
    246249                                fip4h->sum      = 0;
    247                                 fip4h->sum      = in_cksum(fip4h, GET_IP4_HDR_SIZE(fip4h));
     250                                fip4h->sum      = in_cksum(fip4h, GET_IP4_HDR_SIZE(frag));
    248251
    249252                                NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(fip4h->len));
     
    279282                frag_id ++;
    280283                ip4h->sum = 0;
    281                 ip4h->sum = in_cksum(ip4h, GET_IP4_HDR_SIZE(ip4h));
     284                ip4h->sum = in_cksum(ip4h, GET_IP4_HDR_SIZE(output));
    282285
    283286                NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
     
    301304        frag_id ++;
    302305        ip4h->sum = 0;
    303         ip4h->sum = in_cksum(ip4h, (uint_t)GET_IP4_HDR_SIZE(ip4h));
     306        ip4h->sum = in_cksum(ip4h, (uint_t)GET_IP4_HDR_SIZE(output));
    304307
    305308        NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
     
    327330        return error;
    328331        }
     332
     333#endif  /* of #if defined(_IP4_CFG) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_var.h

    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 *
     
    7171#define _IP_VAR_H_
    7272
    73 /*
    74  *  IPv4 ヘッダ・ペイロードアクセスマクロ
    75  */
    76 
    77 #define IF_IP4_HDR_SIZE                 (IF_HDR_SIZE + IP4_HDR_SIZE)
    78 
    79 #define GET_IP4_HDR(nbuf)               ((T_IP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
    80 #define GET_IP4_SDU(nbuf)               ((uint8_t*)((nbuf)->buf) + GET_IF_IP4_HDR_SIZE(nbuf))
    81 
    82 #define GET_IP4_HDR_SIZE(iph)           ((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
    83 #define GET_IP4_SDU_SIZE(iph)           (ntohs((iph)->len) - GET_IP4_HDR_SIZE(iph))
    84 #define GET_IF_IP4_HDR_SIZE(nbuf)       (IF_HDR_SIZE + (GET_IP4_HDR_SIZE(GET_IP4_HDR(nbuf))))
    85 
    86 #define SET_IP4_SDU_SIZE(iph,slen)      ((iph)->len=(uint16_t)htons((slen) + IP4_HDR_SIZE))
     73#include <netinet/ip4_var.h>
     74#include <netinet6/ip6_var.h>
    8775
    8876/*
     
    9078 */
    9179
    92 #if defined(SUPPORT_INET4)
     80#define GET_IP_VER(nbuf)                (*(uint8_t*)((nbuf)->buf+IF_HDR_SIZE)>>4)
    9381
    94 #define T_TCP_IP_Q_HDR                  T_TCP_IP4_Q_HDR
     82#if defined(_IP6_CFG)
    9583
    96 #define IF_IP_HDR_SIZE                  IF_IP4_HDR_SIZE
     84#if defined(_IP4_CFG)
     85
     86#define IF_IP_HDR_SIZE(nbuf)            (GET_IP_VER(nbuf)==IPV6_VERSION?IF_IP6_HDR_SIZE:IF_IP4_HDR_SIZE)
     87#define IF_IP_NET_HDR_SIZE(addr)        (IN6_IS_ADDR_V4MAPPED(addr)?IF_IP4_HDR_SIZE:IF_IP6_HDR_SIZE)
     88
     89#define IP_OUTPUT(nbuf,tmout)           (GET_IP_VER(nbuf)==IPV6_VERSION?ip6_output(nbuf,0,tmout):ip_output(nbuf,tmout))
     90#define IP_REMOVE_OPTIONS(nbuf)         (GET_IP_VER(nbuf)==IPV6_VERSION?ip6_remove_exthdrs(nbuf):ip_remove_options(nbuf))
     91
     92#define GET_IP_HDR(nbuf)                (GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR(nbuf):GET_IP4_HDR(nbuf))
     93#define GET_IP_HDR_SIZE(nbuf)           (GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR_SIZE(nbuf):GET_IP4_HDR_SIZE(nbuf))
     94#define GET_IP_SDU_SIZE(nbuf)           (GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_SDU_SIZE(nbuf):GET_IP4_SDU_SIZE(nbuf))
     95#define GET_IF_IP_HDR_SIZE(nbuf)        (GET_IP_VER(nbuf)==IPV6_VERSION?GET_IF_IP6_HDR_SIZE(nbuf):GET_IF_IP4_HDR_SIZE(nbuf))
     96#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)   (GET_IP_VER(nbuf)==IPV6_VERSION?\
     97                                        ((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff:((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
     98
     99#define SET_IP_CF(nbuf,cf)              (GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_CF(nbuf,cf):(0))
     100#define SET_IP_SDU_SIZE(nbuf,len)       (GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_SDU_SIZE(nbuf,len):SET_IP4_SDU_SIZE(nbuf,len))
     101#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)     \
     102                                        (GET_IP_VER(nbuf)==IPV6_VERSION\
     103                                                ?(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)\
     104                                                :(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff))
     105
     106#else   /* of #if defined(_IP4_CFG) */
     107
     108#define IF_IP_HDR_SIZE(nbuf)            IF_IP6_HDR_SIZE
     109#define IF_IP_NET_HDR_SIZE(addr)        IF_IP6_HDR_SIZE
     110
     111#define IP_OUTPUT(nbuf,tmout)           ip6_output(nbuf,0,tmout)
     112#define IP_REMOVE_OPTIONS(nbuf)         ip6_remove_exthdrs(nbuf)
     113
     114#define GET_IP_HDR(nbuf)                GET_IP6_HDR(nbuf)
     115#define GET_IP_HDR_SIZE(nbuf)           GET_IP6_HDR_SIZE(nbuf)
     116#define GET_IP_SDU_SIZE(nbuf)           GET_IP6_SDU_SIZE(nbuf)
     117#define GET_IF_IP_HDR_SIZE(nbuf)        GET_IF_IP6_HDR_SIZE(nbuf)
     118#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)   (((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff)
     119
     120#define SET_IP_CF(nbuf,cf)              SET_IP6_CF(nbuf,cf)
     121#define SET_IP_SDU_SIZE(nbuf,len)       SET_IP6_SDU_SIZE(nbuf,len)
     122#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)     \
     123                                        (((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)
     124
     125#endif  /* of #if defined(_IP4_CFG) */
     126
     127#else   /* of #if defined(_IP6_CFG) */
     128
     129#if defined(_IP4_CFG)
     130
     131#define IF_IP_HDR_SIZE(nbuf)            IF_IP4_HDR_SIZE
     132#define IF_IP_NET_HDR_SIZE(addr)        IF_IP4_HDR_SIZE
     133
     134#define IP_OUTPUT(nbuf,tmout)           ip_output(nbuf,tmout)
     135#define IP_REMOVE_OPTIONS(nbuf)         ip_remove_options(nbuf)
    97136
    98137#define GET_IP_HDR(nbuf)                GET_IP4_HDR(nbuf)
    99 #define GET_IP_SDU(nbuf)                GET_IP4_SDU(nbuf)
     138#define GET_IP_HDR_SIZE(nbuf)           GET_IP4_HDR_SIZE(nbuf)
     139#define GET_IP_SDU_SIZE(nbuf)           GET_IP4_SDU_SIZE(nbuf)
     140#define GET_IF_IP_HDR_SIZE(nbuf)        GET_IF_IP4_HDR_SIZE(nbuf)
     141#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)   (((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
    100142
    101 #define GET_IP_HDR_SIZE(iph)            GET_IP4_HDR_SIZE(iph)
    102 #define GET_IP_SDU_SIZE(iph)            GET_IP4_SDU_SIZE(iph)
    103 #define GET_IF_IP_HDR_SIZE(nbuf)        GET_IF_IP4_HDR_SIZE(nbuf)
     143#define SET_IP_SDU_SIZE(nbuf,len)       SET_IP4_SDU_SIZE(nbuf,len)
     144#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)     \
     145                                        (((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff)
    104146
    105 #define SET_IP_SDU_SIZE(iph,len)        SET_IP4_SDU_SIZE(iph,len)
     147#else   /* of #if defined(_IP4_CFG) */
    106148
    107 #define IP_OUTPUT(nbuf,tmout)           ip_output(nbuf,tmout)
    108 #define IP_INIT()                       ip_init()
    109 #define IP_REMOVE_OPTIONS(nbuf)         ip_remove_options(nbuf)
     149#error "not implemented."
    110150
    111 #endif  /* of #if defined(SUPPORT_INET4) */
     151#endif  /* of #if defined(_IP4_CFG) */
    112152
    113 /*
    114  *  IP の MSS サイズのネットワークバッファ
    115  */
    116 
    117 typedef struct t_net_buf_ip_mss {
    118         uint16_t        len;    /* データの長さ               */
    119         uint8_t         idix;   /* mpfid のインデックス        */
    120         uint8_t         flags;  /* フラグ          */
    121 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
    122         uint8_t         nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
    123 #endif
    124 #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
    125         uint8_t         halign[4 - IF_HDR_ALIGN];
    126 #endif
    127         uint8_t         buf[IF_HDR_SIZE + IP4_MSS];
    128                                 /* バッファ本体               */
    129         } T_NET_BUF_IP_MSS;
    130 
    131 /*
    132  *  65536 オクテットサイズのネットワークバッファ
    133  */
    134 
    135 typedef struct t_net_buf4_65536 {
    136         uint16_t        len;    /* データの長さ               */
    137         uint8_t         idix;   /* mpfid のインデックス        */
    138         uint8_t         flags;  /* フラグ          */
    139 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
    140         uint8_t         nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
    141 #endif
    142 #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
    143         uint8_t         halign[4 - IF_HDR_ALIGN];
    144 #endif
    145         uint8_t         buf[IF_IP4_HDR_SIZE + 65536];
    146                                 /* バッファ本体               */
    147 #if defined(IF_PDU_HDR_PADDING)
    148         uint8_t         padding[IF_PDU_HDR_PADDING];
    149 #endif                          /* ヘッダの余分               */
    150         } T_NET_BUF4_65536;
    151 
    152 #ifdef IP4_CFG_FRAGMENT
    153 
    154 /*
    155  *  再構成キュー用 IPv4 ヘッダの定義
    156  */
    157 
    158 typedef struct t_qip4_hdr {
    159         uint8_t         vhl;            /* version << 4 | header length >> 2    */
    160                                         /* length は 4 octets 単位         */
    161         uint8_t         type;           /* type of services                     */
    162         uint16_t        len;            /* total length                         */
    163 
    164         uint16_t        id;             /* identification                       */
    165         uint16_t        flg_off;        /* fragment flag & offset               */
    166 
    167         uint8_t         ttl;            /* time to live                         */
    168         uint8_t         proto;          /* protocol                             */
    169         uint16_t        sum;            /* checksum                             */
    170 
    171         uint32_t        src;            /* source address                       */
    172 
    173         T_NET_BUF       *next;          /* 次の IPv4 フラグメント                       */
    174         } __attribute__((packed, aligned(2)))T_QIP4_HDR;
    175 
    176 #define QIP4_HDR_SIZE                   (sizeof(T_QIP4_HDR))
    177 #define IF_QIP4_HDR_SIZE                (IF_HDR_SIZE + QIP4_HDR_SIZE)
    178 
    179 #define GET_QIP4_HDR(nbuf)              ((T_QIP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
    180 #define GET_QIP4_SDU(nbuf)              ((uint8_t*)(nbuf)->buf + GET_IF_QIP4_HDR_SIZE(nbuf))
    181 
    182 #define GET_QIP4_HDR_SIZE(iph)          ((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
    183 #define GET_IF_QIP4_HDR_SIZE(nbuf)      (IF_HDR_SIZE + (GET_QIP4_HDR_SIZE(GET_QIP4_HDR(nbuf))))
    184 
    185 /*
    186  *  データグラム再構成用ネットワークバッファ
    187  */
    188 
    189 typedef struct t_net_buf4_reassm {
    190         uint16_t        len;    /* データの長さ               */
    191         uint8_t         idix;   /* mpfid のインデックス        */
    192         uint8_t         flags;  /* フラグ          */
    193 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
    194         uint8_t         nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
    195 #endif
    196 #if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
    197         uint8_t         align[4 - IF_HDR_ALIGN];
    198 #endif
    199         uint8_t         buf[IP4_CFG_FRAG_REASSM_SIZE];
    200                                 /* バッファ本体               */
    201         } T_NET_BUF4_REASSM;
    202 
    203 #endif  /* of #ifdef IP4_CFG_FRAGMENT */
    204 
    205 /*
    206  *  TCP の再構成キューにおける IPv4 ヘッダの定義
    207  */
    208 
    209 typedef struct t_tcp_ip4_q_hdr {
    210         uint8_t         vhl;            /* version << 4 | header length >> 2    */
    211                                         /* length は 4 octets 単位         */
    212         uint8_t         type;           /* type of services                     */
    213         uint16_t        len;            /* total length                         */
    214 
    215         uint16_t        id;             /* identification                       */
    216         uint16_t        flg_off;        /* fragment flag & offset               */
    217 
    218         uint8_t         ttl;            /* time to live                         */
    219         uint8_t         proto;          /* protocol                             */
    220         uint16_t        thoff;          /* TCP ヘッダのオフセット                */
    221 
    222         T_IN4_ADDR      src;            /* source address                       */
    223         T_IN4_ADDR      dst;            /* destination address                  */
    224         } __attribute__((packed, aligned(2)))T_TCP_IP4_Q_HDR;
    225 
    226 #ifdef SUPPORT_MIB
    227 
    228 /*
    229  *  SNMP の 管理情報ベース (MIB)
    230  */
    231 
    232 typedef struct t_ip_stats {
    233         uint32_t        ipInReceives;
    234         uint32_t        ipInHdrErrors;
    235         uint32_t        ipInAddrErrors;
    236 /*      uint32_t        ipForwDatagrams;*/
    237         uint32_t        ipInUnknownProtos;
    238 /*      uint32_t        ipInDiscards;*/
    239         uint32_t        ipInDelivers;
    240         uint32_t        ipOutRequests;
    241         uint32_t        ipOutDiscards;
    242 /*      uint32_t        ipOutNoRoutes;*/
    243 
    244 #ifdef IP4_CFG_FRAGMENT
    245 
    246         uint32_t        ipReasmReqds;
    247         uint32_t        ipReasmOKs;
    248         uint32_t        ipReasmFails;
    249         uint32_t        ipFragOKs;
    250         uint32_t        ipFragFails;
    251         uint32_t        ipFragCreates;
    252 
    253 #else   /* of #ifdef IP4_CFG_FRAGMENT */
    254 
    255         uint32_t        ipReasmReqds;
    256 /*      uint32_t        ipReasmOKs;*/
    257         uint32_t        ipReasmFails;
    258 /*      uint32_t        ipFragOKs;*/
    259 /*      uint32_t        ipFragFails;*/
    260 /*      uint32_t        ipFragCreates;*/
    261 
    262 #endif  /* of #ifdef IP4_CFG_FRAGMENT */
    263 
    264 } T_IP_STATS;
    265 
    266 extern T_IP_STATS ip_stats;
    267 
    268 #endif  /* of #ifdef SUPPORT_MIB */
    269 
    270 /*
    271  *  関数
    272  */
    273 
    274 extern void ip_frag_timer (void);
    275 extern void ip_init (void);
    276 extern ER ip_remove_options (T_NET_BUF *nbuf);
    277 extern ER ip_output (T_NET_BUF *nbuf, TMO tmout);
     153#endif  /* of #if defined(_IP6_CFG) */
    278154
    279155#endif  /* of #ifndef _IP_VAR_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_fsm.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.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 *
     
    9595#include <net/ethernet.h>
    9696#include <net/net.h>
     97#include <net/net_endian.h>
    9798#include <net/net_var.h>
    9899#include <net/net_buf.h>
     
    102103#include <netinet/in.h>
    103104#include <netinet/in_var.h>
    104 #include <netinet6/in6.h>
    105 #include <netinet6/in6_var.h>
    106 #include <netinet6/nd6.h>
    107105#include <netinet/in_itron.h>
    108106#include <netinet/ip.h>
    109107#include <netinet/ip_var.h>
    110 #include <netinet/ip6.h>
    111 #include <netinet6/ip6_var.h>
    112108#include <netinet/ip_icmp.h>
    113109#include <netinet/tcp.h>
    114 #include <netinet/tcp_timer.h>
    115110#include <netinet/tcp_var.h>
    116111#include <netinet/tcp_fsm.h>
    117112#include <netinet/tcp_seq.h>
     113#include <netinet/tcp_timer.h>
    118114
    119115#ifdef SUPPORT_TCP
     
    139135static void close_connection    (T_TCP_CEP *cep, bool_t *needoutput);
    140136static void set_rexmt_timer     (T_TCP_CEP *cep,  T_TCP_TIME rtt);
    141 static uint8_t reassemble               (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
     137static uint8_t reassemble       (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
    142138static ER drop_after_ack        (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff);
    143139static ER listening             (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss);
     
    147143static void trim_length         (T_TCP_HDR *tcph,  T_TCP_CEP *cep);
    148144static void parse_option        (T_TCP_HDR *tcph,  T_TCP_CEP *cep);
    149 static bool_t update_wnd                (T_TCP_HDR *tcph,  T_TCP_CEP *cep);
     145static bool_t update_wnd        (T_TCP_HDR *tcph,  T_TCP_CEP *cep);
    150146static void proc_urg            (T_TCP_HDR *tcph,  T_TCP_CEP *cep);
    151 
    152 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
    153 
    154 /*
    155  *  タスクからの Time Wait 状態 CEP 分離機能
    156  */
    157 
    158 /*
    159  *  関数
    160  */
    161 
    162 static T_TCP_TWCEP*tcp_find_twcep (T_IN_ADDR *dstaddr,  uint16_t dstport,
    163                                    T_IN_ADDR *peeraddr, uint16_t peerport);
    164 
    165 /*
    166  *  変数
    167  */
    168 
    169 T_TCP_TWCEP tcp_twcep[NUM_TCP_TW_CEP_ENTRY];
    170 
    171 /*
    172  *  tcp_find_twcep -- ポート番号から Time Wait 用 TCP 通信端点を得る。
    173  *
    174  *    注意: dstaddr は、ネットワークバイトオーダ
    175  */
    176 
    177 static T_TCP_TWCEP*
    178 tcp_find_twcep (T_IN_ADDR *dstaddr, uint16_t dstport, T_IN_ADDR *peeraddr, uint16_t peerport)
    179 {
    180         T_TCP_TWCEP*    twcep;
    181        
    182         /*
    183          *  状態が TIME WAIT で、
    184          *  IP アドレスとポート番号が一致する通信端点を探索する。
    185          */
    186         for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
    187                 if (twcep->fsm_state == TCP_FSM_TIME_WAIT                   &&
    188                     IN_IS_DSTADDR_ACCEPT (&twcep->myaddr.ipaddr,  dstaddr)  &&
    189                     IN_ARE_NET_ADDR_EQUAL(&twcep->dstaddr.ipaddr, peeraddr) &&
    190                     dstport  == twcep->myaddr.portno                        &&
    191                     peerport == twcep->dstaddr.portno)
    192                         return twcep;
    193                 }
    194 
    195         return NULL;
    196         }
    197 
    198 /*
    199  *  必要な情報を Time Wait 用 TCP 通信端点に移して、
    200  *  標準の TCP 通信端点を開放する。
    201  */
    202 
    203 void
    204 tcp_move_twcep (T_TCP_CEP *cep)
    205 {
    206         T_TCP_TWCEP*    twcep;
    207 
    208         /* 空きの Time Wait 用 TCP 通信端点を探索する。*/
    209         for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
    210                 if (twcep->fsm_state != TCP_FSM_TIME_WAIT) {
    211 
    212                         /*
    213                          *  通信端点をロックし、
    214                          *  必要な情報を Time Wait 用 TCP 通信端点に移す。
    215                          */
    216                         syscall(wai_sem(cep->semid_lock));
    217                         twcep->rbufsz           = cep->rbufsz;
    218                         twcep->dstaddr          = cep->dstaddr;
    219                         twcep->myaddr           = cep->myaddr;
    220                         twcep->snd_una          = cep->snd_una;
    221                         twcep->rcv_nxt          = cep->rcv_nxt;
    222                         twcep->rwbuf_count      = cep->rwbuf_count;
    223                         twcep->fsm_state        = cep->fsm_state;
    224                         twcep->timer_2msl       = cep->timer[TCP_TIM_2MSL];
    225 
    226                         /* 通信端点をロックを解除する。*/
    227                         syscall(sig_sem(cep->semid_lock));
    228 
    229                         /* 標準 TCP 通信端点を開放する。*/
    230                         tcp_close(cep);
    231 
    232                         break;
    233                         }
    234                 }
    235         }
    236 
    237 #endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    238147
    239148/*
     
    421330
    422331                /*  TCP ヘッダの位置を保存する。*/
    423                 GET_TCP_IP_Q_HDR(input)->thoff = thoff;
     332                SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
    424333
    425334                /* SDU のオフセット(元はウィンドサイズ)をリセットする。*/
     
    448357listening (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss)
    449358{
    450         T_IP_HDR        *iph;
    451359        T_TCP_HDR       *tcph;
    452360
    453         iph  = GET_IP_HDR(input);
    454361        tcph = GET_TCP_HDR(input, thoff);
    455362
     
    473380                return RET_DROP;
    474381
    475 #if defined(SUPPORT_INET4)
    476 
    477 #ifdef SUPPORT_LOOP
    478 
    479382        /*
    480          *  次のときは破棄する。
    481          *    ・ポート番号が同一で、送受信 IP アドレス が同一。
    482          *      ただし、ローカルループバック (127.0.0.1) なら良い。
    483          *    ・マルチキャストアドレス
    484          */
    485 
    486         if (tcph->dport == tcph->sport &&
    487             (iph->dst == iph->src && ntohl(iph->src) != IPV4_ADDR_LOOPBACK))
     383         *  受信可能な IP アドレスとポート番号であることを確認する。
     384         */
     385        if (!tcp_is_addr_accept(input, thoff))
    488386                return RET_DROP;
    489387
    490 #else   /* of #ifdef SUPPORT_LOOP */
    491 
    492         /*
    493          *  次のときは破棄する。
    494          *    ・ポート番号が同一で、送受信 IP アドレス が同一。
    495          *    ・マルチキャストアドレス
    496          */
    497 
    498         if (tcph->dport == tcph->sport && iph->dst == iph->src)
    499                 return RET_DROP;
    500 
    501 #endif  /* of #ifdef SUPPORT_LOOP */
    502 
    503 #endif  /* of #if defined(SUPPORT_INET4) */
    504 
    505 #if defined(SUPPORT_INET6)
    506 
    507         /*
    508          *  次のときは破棄する。
    509          *    ・ポート番号が同一で、送受信 IP アドレス が同一。
    510          *    ・マルチキャストアドレス
    511          */
    512 
    513         if (tcph->dport == tcph->sport && IN_ARE_ADDR_EQUAL(&iph->dst, &iph->src))
    514                 return RET_DROP;
    515 
    516 #endif  /* of #if defined(SUPPORT_INET6) */
    517 
    518         if (IN_IS_NET_ADDR_MULTICAST(&iph->dst))
    519                 return RET_DROP;
    520 
    521388        /* 相手のアドレスを記録する。*/
    522         IN_COPY_TO_HOST(&cep->dstaddr.ipaddr, &iph->src);
     389        IN_COPY_TO_HOST(&cep->dstaddr.ipaddr, input);
    523390        cep->dstaddr.portno = tcph->sport;
    524391
     
    919786                        cep->rep = NULL;
    920787
     788#if defined(_IP6_CFG) && defined(_IP4_CFG)
     789                        cep->rep4 = NULL;
     790#endif
     791
    921792                        syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_ESTABLISHED));
    922793
     
    926797
    927798                                /* 相手のアドレスをコピーする。*/
     799
     800#if defined(_IP6_CFG) && defined(_IP4_CFG)
     801
     802                                if (cep->flags & TCP_CEP_FLG_IPV4) {
     803                                        (*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     804                                        (*cep->p_dstaddr4).portno = cep->dstaddr.portno;
     805                                        }
     806                                else
     807                                        *cep->p_dstaddr = cep->dstaddr;
     808
     809#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     810
    928811                                *cep->p_dstaddr = cep->dstaddr;
     812
     813#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
    929814
    930815                                if (IS_PTR_DEFINED(cep->callback)) {
     
    13691254        case TCP_FSM_ESTABLISHED:       /* コネクション開設完了           */
    13701255                cep->fsm_state = TCP_FSM_CLOSE_WAIT;
     1256                syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_RWBUF_READY));
    13711257                break;
    13721258
     
    14211307{
    14221308        T_NET_BUF       *input = *inputp;
    1423         T_IP_HDR        *iph;
    14241309        T_TCP_HDR       *tcph;
    14251310        T_TCP_CEP       *cep = NULL;
     
    14421327
    14431328        /* ヘッダ長をチェックする。*/
    1444         if (input->len < IF_IP_TCP_HDR_SIZE) {
     1329        if (input->len < IF_IP_TCP_HDR_SIZE(input)) {
    14451330                NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_BAD_HEADERS], 1);
    14461331                goto drop;
    14471332                }
    14481333
    1449         iph  = GET_IP_HDR(input);
    14501334        tcph = GET_TCP_HDR(input, *offp);
    14511335
     
    14871371         *  状態が Time Wait 中の CEP を探索する。
    14881372         */
    1489         twcep = tcp_find_twcep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
     1373        twcep = tcp_find_twcep(input, *offp);
    14901374        if (twcep != NULL) {
    14911375
     
    15101394        else
    15111395                /* 標準の TCP 通信端点を得る。*/
    1512                 cep = tcp_find_cep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
     1396                cep = tcp_find_cep(input, *offp);
    15131397
    15141398#else   /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
    15151399
    15161400        /* TCP 通信端点を得る。*/
    1517         cep = tcp_find_cep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
     1401        cep = tcp_find_cep(input, *offp);
    15181402
    15191403#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
     
    18941778         */
    18951779
    1896         if ((tcph->flags & TCP_FLG_RST) || IN_IS_NET_ADDR_MULTICAST(&iph->dst))
     1780        if ((tcph->flags & TCP_FLG_RST) || IN_IS_NET_ADDR_MULTICAST(input))
    18971781                goto drop;
    18981782
     
    19071791                rbfree = cep->rbufsz - cep->rwbuf_count;
    19081792
    1909         if (tcph->flags & TCP_FLG_ACK) {
     1793        if (tcph->flags & TCP_FLG_ACK)
    19101794                tcp_respond(input, cep, 0, tcph->ack, rbfree, TCP_FLG_RST);
    1911                 }
    19121795        else {
    19131796                if (tcph->flags & TCP_FLG_SYN)
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_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 *
     
    9393#include <net/ethernet.h>
    9494#include <net/net.h>
     95#include <net/net_endian.h>
     96#include <net/net_var.h>
    9597#include <net/net_buf.h>
    9698#include <net/net_timer.h>
     
    98100
    99101#include <netinet/in.h>
    100 #include <netinet6/in6.h>
    101102#include <netinet/in_var.h>
    102103#include <netinet/in_itron.h>
    103104#include <netinet/ip.h>
    104105#include <netinet/ip_var.h>
    105 #include <netinet6/in6_var.h>
    106 #include <netinet/ip6.h>
    107 #include <netinet6/ip6_var.h>
    108106#include <netinet/tcp.h>
    109 #include <netinet/tcp_timer.h>
    110107#include <netinet/tcp_var.h>
    111108#include <netinet/tcp_fsm.h>
    112109#include <netinet/tcp_seq.h>
     110#include <netinet/tcp_timer.h>
    113111
    114112#ifdef SUPPORT_TCP
     
    150148        T_NET_BUF       *output;
    151149        T_TCP_HDR       *tcph;
    152         uint_t          optlen;
     150        uint_t          optlen, hdr_offset;
    153151        ER              error;
    154152
     
    210208                 */
    211209                len = 0;
    212                 if ((error = tcp_get_segment(&output, cep, optlen,
    213                                             len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
     210                if ((error = tcpn_get_segment(&output, cep, optlen,
     211                                            len, (uint_t)net_buf_max_siz(),
    214212                                            NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
    215213                        if (cep->timer[TCP_TIM_REXMT] == 0)
     
    222220
    223221        if (IS_PTR_DEFINED(cep->sbuf)) {
    224                 if ((error = tcp_get_segment(&output, cep, optlen,
    225                                              len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
     222                if ((error = tcpn_get_segment(&output, cep, optlen,
     223                                             len, (uint_t)net_buf_max_siz(),
    226224                                             NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
    227225                        if (cep->timer[TCP_TIM_REXMT] == 0)
     
    247245                 */
    248246                len = 0;
    249                 if ((error = tcp_get_segment(&output, cep, optlen,
    250                                             len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
     247                if ((error = tcpn_get_segment(&output, cep, optlen,
     248                                            len, (uint_t)net_buf_max_siz(),
    251249                                            NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
    252250                        if (cep->timer[TCP_TIM_REXMT] == 0)
     
    258256#else   /* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
    259257
    260         if ((error = tcp_get_segment(&output, cep, optlen,
    261                                      len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
     258        if ((error = tcpn_get_segment(&output, cep, optlen,
     259                                     len, (uint_t)net_buf_max_siz(),
    262260                                     NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
    263261                if (cep->timer[TCP_TIM_REXMT] == 0)
     
    272270         *  本実装では、最大セグメントサイズのみ設定する。
    273271         */
     272        hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
    274273        if (flags & TCP_FLG_SYN) {
    275274                cep->snd_nxt = cep->iss;
     
    277276#ifdef TCP_CFG_OPT_MSS
    278277
    279                 optp = GET_TCP_OPT(output, IF_IP_TCP_HDR_OFFSET);
     278                optp = GET_TCP_OPT(output, hdr_offset);
    280279                *optp ++ = TCP_OPT_MAXSEG;
    281280                *optp ++ = TCP_OPT_LEN_MAXSEG;
     
    324323                }
    325324
    326         tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
     325        tcph = GET_TCP_HDR(output, hdr_offset);
    327326
    328327        /*
     
    379378         */
    380379        tcph->sum = 0;
    381         tcph->sum = IN_CKSUM(output, IPPROTO_TCP, (uint_t)GET_TCP_HDR_OFFSET(output),
    382                              GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len);
     380        tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, GET_TCP_HDR_SIZE(output, hdr_offset) + len);
    383381
    384382        /* ネットワークバッファ長を調整する。*/
    385         output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len);
     383        output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset) + len);
    386384
    387385        /*
     
    490488         * ・動的な通信端点の生成・削除機能
    491489         */
    492         cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK |
    493                        TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
     490        cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
    494491
    495492        return error;
     
    864861#endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    865862
    866                 if ((error = tcp_get_segment(&cep->swbufq, cep, 0,
    867                                              (uint_t) TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
    868                                              (uint_t)(TCP_CFG_SWBUF_CSAVE_MAX_SIZE - IF_IP_TCP_HDR_SIZE),
     863                if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
     864                                             (uint_t)TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
     865                                             (uint_t)TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
    869866                                             (ATR)(NBA_SEARCH_DESCENT |
    870867                                                   NBA_RESERVE_TCP    |
     
    888885                                len = TCP_GET_SWBUF_ADDR(cep, cep->snd_p_buf);
    889886
     887                                /* コールバック関数を呼び出す。*/
    890888#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    891 
    892                                 /* コールバック関数を呼び出す。*/
    893889                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
    894 
    895 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    896 
    897                                 /* コールバック関数を呼び出す。*/
     890#else
    898891                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
    899 
    900 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
     892#endif
    901893
    902894
     
    924916                                /* フラグを、送信可能に設定し、強制的に送信する。*/
    925917                                cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT;
     918
     919                                /* コールバック関数を呼び出す。*/
    926920#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    927 
    928                                 /* コールバック関数を呼び出す。*/
    929921                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
    930 
    931 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    932 
    933                                 /* コールバック関数を呼び出す。*/
     922#else
    934923                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
    935 
    936 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
     924#endif
    937925
    938926
     
    999987        tcp_init();
    1000988
    1001 #ifdef SUPPORT_INET6
     989#ifdef _IP6_CFG
    1002990
    1003991        /* IPv6 のステートレス・アドレス自動設定を実行する。*/
    1004992        in6_if_up(IF_GET_IFNET());
    1005993
    1006 #endif  /* of #ifdef SUPPORT_INET6 */
     994#endif  /* of #ifdef _IP6_CFG */
    1007995
    1008996        while (true) {
     
    10831071
    10841072                                                if (IS_PTR_DEFINED(cep->callback))
    1085 
    10861073#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1087 
    10881074                                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
    1089 
    1090 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1091 
     1075#else
    10921076                                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
    1093 
    1094 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1095 
     1077#endif
    10961078                                                else
    10971079                                                        syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_seq.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.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 *
     
    9696#include <net/if_loop.h>
    9797#include <net/ethernet.h>
    98 #include <net/if_arp.h>
    99 #include <net/ppp_ipcp.h>
    10098#include <net/net.h>
     99#include <net/net_endian.h>
    101100#include <net/net_var.h>
    102101#include <net/net_buf.h>
     
    105104
    106105#include <netinet/in.h>
    107 #include <netinet6/in6.h>
    108 #include <netinet6/in6_var.h>
    109106#include <netinet/in_var.h>
     107#include <netinet/in_itron.h>
    110108#include <netinet/ip.h>
    111109#include <netinet/ip_var.h>
    112 #include <netinet/ip6.h>
    113 #include <netinet6/ip6_var.h>
    114 #include <netinet6/nd6.h>
    115110#include <netinet/tcp.h>
    116 #include <netinet/tcp_timer.h>
    117111#include <netinet/tcp_var.h>
    118112#include <netinet/tcp_fsm.h>
    119113#include <netinet/tcp_seq.h>
    120 #include <netinet/in_itron.h>
     114#include <netinet/tcp_timer.h>
    121115
    122116#ifdef SUPPORT_TCP
     
    147141
    148142static uint16_t tcp_port_auto = TCP_PORT_FIRST_AUTO;    /* 自動割り当て番号     */
     143
     144#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
     145
     146/*
     147 *  タスクからの Time Wait 状態 CEP 分離機能
     148 */
     149
     150/*
     151 *  変数
     152 */
     153
     154T_TCP_TWCEP tcp_twcep[NUM_TCP_TW_CEP_ENTRY];
     155
     156/*
     157 *  tcp_move_twcep -- 必要な情報を Time Wait 用 TCP 通信端点に移して、
     158 *                    標準の TCP 通信端点を開放する。
     159 */
     160
     161void
     162tcp_move_twcep (T_TCP_CEP *cep)
     163{
     164        T_TCP_TWCEP*    twcep;
     165
     166        /* 空きの Time Wait 用 TCP 通信端点を探索する。*/
     167        for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
     168                if (twcep->fsm_state != TCP_FSM_TIME_WAIT) {
     169
     170                        /*
     171                         *  通信端点をロックし、
     172                         *  必要な情報を Time Wait 用 TCP 通信端点に移す。
     173                         */
     174                        syscall(wai_sem(cep->semid_lock));
     175                        twcep->flags            = (uint8_t)cep->flags;
     176                        twcep->rbufsz           = cep->rbufsz;
     177                        twcep->dstaddr          = cep->dstaddr;
     178                        twcep->myaddr           = cep->myaddr;
     179                        twcep->snd_una          = cep->snd_una;
     180                        twcep->rcv_nxt          = cep->rcv_nxt;
     181                        twcep->rwbuf_count      = cep->rwbuf_count;
     182                        twcep->fsm_state        = cep->fsm_state;
     183                        twcep->timer_2msl       = cep->timer[TCP_TIM_2MSL];
     184
     185                        /* 通信端点をロックを解除する。*/
     186                        syscall(sig_sem(cep->semid_lock));
     187
     188                        /* 標準 TCP 通信端点を開放する。*/
     189                        tcp_close(cep);
     190
     191                        break;
     192                        }
     193                }
     194        }
     195
     196/*
     197 *  tcp_find_twcep -- ポート番号から Time Wait 用 TCP 通信端点を得る。
     198 */
     199
     200T_TCP_TWCEP*
     201tcp_find_twcep (T_NET_BUF *input, uint_t off)
     202{
     203        T_TCP_TWCEP*    twcep;
     204        T_TCP_HDR       *tcph;
     205
     206        tcph = GET_TCP_HDR(input, off);
     207       
     208        /*
     209         *  状態が TIME WAIT で、
     210         *  IP アドレスとポート番号が一致する通信端点を探索する。
     211         */
     212        for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
     213                if (twcep->fsm_state == TCP_FSM_TIME_WAIT                   &&
     214                    IN_IS_DSTADDR_ACCEPT    (&twcep->myaddr.ipaddr,  input) &&
     215                    IN_ARE_NET_SRCADDR_EQUAL(&twcep->dstaddr.ipaddr, input) &&
     216                    tcph->dport == twcep->myaddr.portno                     &&
     217                    tcph->sport == twcep->dstaddr.portno)
     218                        return twcep;
     219                }
     220
     221        return NULL;
     222        }
     223
     224#endif  /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
     225
     226/*
     227 *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
     228 */
     229
     230T_TCP_CEP*
     231tcp_find_cep (T_NET_BUF *input, uint_t off)
     232{
     233        T_TCP_CEP*      cep;
     234        T_TCP_HDR       *tcph;
     235
     236        tcph = GET_TCP_HDR(input, off);
     237       
     238        /*
     239         *  状態が SYN 送信済み以後は、
     240         *  IP アドレスとポート番号が一致する TCP 通信端点を探索する。
     241         */
     242        for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
     243                if (cep->fsm_state >= TCP_FSM_SYN_SENT                    &&
     244                    IN_IS_DSTADDR_ACCEPT    (&cep->myaddr.ipaddr,  input) &&
     245                    IN_ARE_NET_SRCADDR_EQUAL(&cep->dstaddr.ipaddr, input) &&
     246                    tcph->dport == cep->myaddr.portno                     &&
     247                    tcph->sport == cep->dstaddr.portno)
     248                        return cep;
     249                }
     250
     251        /* IPv4 で受動オープン中の TCP 通信端点を先に探索する。*/   
     252        for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
     253                if ((cep->flags & TCP_CEP_FLG_IPV4)                   &&
     254                     cep->fsm_state == TCP_FSM_LISTEN                 &&
     255                     GET_IP_VER(input) == IPV4_VERSION                &&
     256                     IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
     257                     tcph->dport == cep->myaddr.portno)
     258                        return cep;
     259                }
     260
     261        /* 受動オープン中の TCP 通信端点を探索する。*/   
     262        for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
     263
     264#if defined(_IP6_CFG) && defined(_IP4_CFG)
     265
     266                if (cep->flags & TCP_CEP_FLG_IPV4) {
     267                        if (cep->fsm_state == TCP_FSM_LISTEN                 &&
     268                            GET_IP_VER(input) == IPV4_VERSION                &&
     269                            IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
     270                            tcph->dport == cep->myaddr.portno)
     271                                return cep;
     272                        }
     273                else {
     274
     275#if defined(API_CFG_IP4MAPPED_ADDR)
     276
     277                        if (cep->fsm_state == TCP_FSM_LISTEN                 &&
     278                            IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
     279                            tcph->dport == cep->myaddr.portno)
     280                                return cep;
     281
     282#else   /* of #if defined(API_CFG_IP4MAPPED_ADDR) */
     283
     284                        if (cep->fsm_state == TCP_FSM_LISTEN                   &&
     285                            INN6_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
     286                            tcph->dport == cep->myaddr.portno)
     287                                return cep;
     288
     289#endif  /* of #if defined(API_CFG_IP4MAPPED_ADDR) */
     290
     291                        }
     292
     293#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     294
     295                if (cep->fsm_state == TCP_FSM_LISTEN                 &&
     296                    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
     297                    tcph->dport == cep->myaddr.portno)
     298                        return cep;
     299
     300#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     301                }
     302
     303        return NULL;
     304        }
     305
     306/*
     307 *  tcp_is_addr_accept -- 受信可能な IP アドレスとポート番号であることを確認する。
     308 */
     309
     310bool_t
     311tcp_is_addr_accept (T_NET_BUF *input, uint_t off)
     312{
     313        T_TCP_HDR       *tcph;
     314
     315        tcph = GET_TCP_HDR(input, off);
     316
     317#if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP)
     318
     319        /*
     320         *  次のときは破棄する。
     321         *    ・ポート番号が同一で、送受信 IP アドレス が同一。
     322         *      ただし、送信元 IP アドレスがローカルループバックなら良い。
     323         *    ・マルチキャストアドレス
     324         */
     325
     326        if (tcph->dport == tcph->sport &&
     327            (IN4_ARE_HDR_ADDR_EQUAL(input) && !IN4_ARE_NET_ADDR_EQUAL(&GET_IP4_HDR(input)->dst, &IPV4_ADDR_LOOPBACK)))
     328                return RET_DROP;
     329
     330#else   /* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
     331
     332        /*
     333         *  次のときは、受信可能ではない。
     334         *    ・ポート番号が同一で、送受信 IP アドレス が同一。
     335         *    ・マルチキャストアドレス
     336         */
     337        if (tcph->dport == tcph->sport && IN_ARE_HDR_ADDR_EQUAL(input))
     338                return false;
     339
     340#endif  /* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
     341
     342        if (IN_IS_NET_ADDR_MULTICAST(input))
     343                return false;
     344        else
     345                return true;
     346        }
    149347
    150348/*
     
    162360
    163361        for (q = cep->reassq; q != NULL; q = nq) {
    164                 nq = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff)->next;
     362                nq = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q))->next;
    165363                syscall(rel_net_buf(q));
    166364                }
     
    184382                        tcp_port_auto = TCP_PORT_FIRST_AUTO;
    185383
    186 #ifdef TCP_CFG_PASSIVE_OPEN
    187 
    188                 for (ix = tmax_tcp_repid; ix -- > 0; ) {
     384#if defined(TNUM_TCP6_REPID)
     385#if TNUM_TCP6_REPID > 0
     386
     387                for (ix = tmax_tcp6_repid; ix -- > 0; ) {
    189388
    190389#ifdef TCP_CFG_EXTENTIONS
    191390
    192                         if (VALID_TCP_REP(&tcp_rep[ix]) && tcp_rep[ix].myaddr.portno == portno) {
     391                        if (VALID_TCP_REP(&tcp6_rep[ix]) && tcp6_rep[ix].myaddr.portno == portno) {
    193392                                portno = TCP_PORTANY;
    194393                                break;
     
    197396#else   /* of #ifdef TCP_CFG_EXTENTIONS */
    198397
    199                         if (tcp_rep[ix].myaddr.portno == portno) {
     398                        if (tcp6_rep[ix].myaddr.portno == portno) {
    200399                                portno = TCP_PORTANY;
    201400                                break;
     
    206405                        }
    207406
    208 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
     407#endif  /* of #if TNUM_TCP6_REPID > 0 */
     408#endif  /* of #if defined(TNUM_TCP6_REPID) */
     409
     410#if defined(TNUM_TCP4_REPID)
     411#if TNUM_TCP4_REPID > 0
     412
     413                for (ix = tmax_tcp4_repid; ix -- > 0; ) {
     414
     415#ifdef TCP_CFG_EXTENTIONS
     416
     417                        if (VALID_TCP_REP(&tcp4_rep[ix]) && tcp4_rep[ix].myaddr.portno == portno) {
     418                                portno = TCP_PORTANY;
     419                                break;
     420                                }
     421
     422#else   /* of #ifdef TCP_CFG_EXTENTIONS */
     423
     424                        if (tcp4_rep[ix].myaddr.portno == portno) {
     425                                portno = TCP_PORTANY;
     426                                break;
     427                                }
     428
     429#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
     430
     431                        }
     432
     433#endif  /* of #if TNUM_TCP4_REPID > 0 */
     434#endif  /* of #if defined(TNUM_TCP4_REPID) */
    209435
    210436                if (portno != TCP_PORTANY) {
     
    273499        SYSTIM now;
    274500
    275 #ifdef SUPPORT_ETHER
    276 
    277         T_IF_SOFTC      *ic;
    278 
    279         ic = IF_ETHER_NIC_GET_SOFTC();
    280         syscall(get_tim(&now));
    281         net_srand(now + (ic->ifaddr.lladdr[2] << 24)
    282                       + (ic->ifaddr.lladdr[3] << 16)
    283                       + (ic->ifaddr.lladdr[4] <<  8)
    284                       + (ic->ifaddr.lladdr[5]      ));
    285 
    286 #else   /* of #ifdef SUPPORT_ETHER */
    287 
    288501        syscall(get_tim(&now));
    289502        net_srand(now);
    290 
    291 #endif  /* of #ifdef SUPPORT_ETHER */
    292 
    293503        tcp_iss = net_rand();
    294504        }
     
    319529         * ・送受信ウィンドバッファの省コピー機能
    320530         * ・動的な通信端点の生成・削除機能
     531         * ・通信端点のネットワーク層プロトコル
    321532         */
    322         cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK |
    323                        TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
     533        cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
    324534
    325535#ifdef TCP_CFG_NON_BLOCKING
     
    341551                                        /* TCP 通信端点からTCP 受付口を解放する。*/
    342552                                        cep->rep = NULL;
     553
     554#if defined(_IP6_CFG) && defined(_IP4_CFG)
     555                                        cep->rep4 = NULL;
     556#endif
     557
    343558                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_CLS);
    344559                                        break;
     
    397612                                        /* TCP 通信端点から TCP 受付口を解放する。*/
    398613                                        cep->rep = NULL;
     614
     615#if defined(_IP6_CFG) && defined(_IP4_CFG)
     616                                        cep->rep4 = NULL;
     617#endif
     618
    399619                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_CLS);
    400620                                        break;
     
    431651
    432652                                case TFN_TCP_ACP_CEP:
     653
    433654                                        /* TCP 通信端点からTCP 受付口を解放する。*/
    434655                                        cep->rep = NULL;
     656
     657#if defined(_IP6_CFG) && defined(_IP4_CFG)
     658                                        cep->rep4 = NULL;
     659#endif
     660
     661                                        /* 接続エラーを設定する。*/
    435662                                        len      = E_CLS;
    436663                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
     
    489716
    490717                                case TFN_TCP_CON_CEP:
    491                                         /* TCP 通信端点から TCP 受付口を解放する。*/
     718
     719                                        /* TCP 通信端点からTCP 受付口を解放する。*/
    492720                                        cep->rep = NULL;
     721
     722#if defined(_IP6_CFG) && defined(_IP4_CFG)
     723                                        cep->rep4 = NULL;
     724#endif
     725
     726                                        /* 接続エラーを設定する。*/
    493727                                        len      = E_CLS;
    494728                                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
     
    589823                sig_sem(SEM_TCP_POST_OUTPUT);
    590824                }
    591         else
     825        else {
    592826                cep = tcp_close(cep);
     827                }
    593828        return cep;
    594829        }
     
    602837             T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags)
    603838{
    604         T_IP_HDR        *iph;
    605839        T_TCP_HDR       *tcph;
    606840        uint_t          win = 0;
     841        uint_t          hdr_offset;
    607842
    608843        if ((flags & TCP_FLG_RST) == 0)
     
    614849         */
    615850        if (output != NULL) {
    616                 T_IN_ADDR       ipaddr;
    617                 uint16_t                portno;
     851                uint16_t        portno;
    618852
    619853                /*
     
    626860                        }
    627861
    628                 iph  = GET_IP_HDR(output);
    629 
    630                 /* IP アドレスを交換する。*/
    631                 ipaddr = iph->src;
    632                 iph->src = iph->dst;
    633                 iph->dst = ipaddr;
    634 
    635 #if defined(SUPPORT_INET6)
     862                ip_exchg_addr(output);
     863
     864#if defined(_IP6_CFG)
    636865
    637866                /* トラヒッククラスとフローラベルをクリアする。*/
    638                 iph->vcf = htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(iph->vcf)), 0));
    639 
    640 #endif  /* of #if defined(SUPPORT_INET6) */
     867                SET_IP_CF(output, 0);
     868
     869#endif  /* of #if defined(_IP6_CFG) */
    641870
    642871                /* TCP SDU 長を 0 にする。*/
    643                 SET_IP_SDU_SIZE(iph, TCP_HDR_SIZE);
    644 
    645                 tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
     872                SET_IP_SDU_SIZE(output, TCP_HDR_SIZE);
     873
     874                tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
    646875
    647876                /* ポート番号を交換する。*/
     
    658887                return;
    659888        else {
    660                 if (tcp_get_segment(&output, cep, 0,
    661                                     0, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
     889                if (tcpn_get_segment(&output, cep, 0,
     890                                    0, (uint_t)net_buf_max_siz(),
    662891                                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF) != E_OK)
    663892                        return;
    664                 tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
     893                tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
    665894                flags |= TCP_FLG_ACK;
    666895                }
     
    675904         *  チェックサムを設定する。
    676905         */
    677         tcph->sum = IN_CKSUM(output, IPPROTO_TCP, IF_IP_TCP_HDR_OFFSET,
    678                              (uint_t)GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET));
     906        hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
     907        tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset,
     908                             (uint_t)GET_TCP_HDR_SIZE(output, hdr_offset));
    679909
    680910        /* ネットワークバッファ長を調整する。*/
    681         output->len = (uint16_t)GET_IF_IP_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET);
     911        output->len = (uint16_t)GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset);
    682912
    683913#ifdef TCP_CFG_TRACE
     
    690920        IP_OUTPUT(output, TMO_TCP_OUTPUT);
    691921        }
    692 
    693 /*
    694  *  tcp_set_header -- TCP ヘッダを設定する。
    695  */
    696 
    697 void
    698 tcp_set_header (T_NET_BUF *nbuf, T_TCP_CEP *cep, uint_t thoff, uint_t optlen)
    699 {
    700         T_TCP_HDR       *tcph = GET_TCP_HDR(nbuf, thoff);
    701 
    702         /* TCP ヘッダに情報を設定する。*/
    703         tcph->sport     = htons(cep->myaddr.portno);
    704         tcph->dport     = htons(cep->dstaddr.portno);
    705         tcph->doff      = TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
    706         tcph->sum       = tcph->flags = 0;
    707         }
    708 
     922#if 0
    709923/*
    710924 *  tcp_get_segment -- TCP セグメントを獲得し、ヘッダを設定する。
     
    712926 *    戻り値       エラーコード
    713927 *    optlen    オプションサイズ、4 オクテット単位
     928 *    maxlen    最大セグメントサイズ(IF/IP/TCP ヘッダサイズを含まない)
    714929 *    len       TCP SDU サイズ
    715930 */
     
    719934                 uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
    720935{
     936        T_TCP_HDR       *tcph;
    721937        ER              error;
    722938
     
    728944                                     &cep->myaddr.ipaddr,
    729945                                     IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
     946                syslog(LOG_WARNING, "[TCP] NET BUF busy, len: %d, CEP: %d.",
     947                                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
     948                return error;
     949                }
     950
     951        /* TCP ヘッダに情報を設定する。*/
     952
     953        /* TCP ヘッダに情報を設定する。*/
     954        tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
     955        tcph->sport     = htons(cep->myaddr.portno);
     956        tcph->dport     = htons(cep->dstaddr.portno);
     957        tcph->doff      = TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
     958        tcph->sum       = tcph->flags = 0;
     959
     960        return E_OK;
     961        }
     962#endif
     963/*
     964 *  tcpn_get_segment -- TCP セグメントを獲得し、ヘッダを設定する。
     965 *
     966 *    戻り値       エラーコード
     967 *    optlen    オプションサイズ、4 オクテット単位
     968 *    maxlen    最大セグメントサイズ(IF/IP/TCP ヘッダサイズを含む)
     969 *    len       TCP SDU サイズ
     970 */
     971
     972ER
     973tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
     974                 uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
     975{
     976        T_TCP_HDR       *tcph;
     977        ER              error;
     978
     979        /* IP データグラムを獲得する。*/
     980        if ((error = IN_GET_DATAGRAM(nbuf,
     981                                     (uint_t)(TCP_HDR_SIZE + optlen + len),
     982                                     (uint_t)(maxlen - IF_IP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)),
     983                                     &cep->dstaddr.ipaddr,
     984                                     &cep->myaddr.ipaddr,
     985                                     IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
    730986                syslog(LOG_WARNING, "[TCP] NET BUF busy,  len:%4d, CEP: %d.",
    731987                                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
     
    734990
    735991        /* TCP ヘッダに情報を設定する。*/
    736         tcp_set_header(*nbuf, cep, IF_IP_TCP_HDR_OFFSET, optlen);
     992
     993        /* TCP ヘッダに情報を設定する。*/
     994        tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
     995        tcph->sport     = htons(cep->myaddr.portno);
     996        tcph->dport     = htons(cep->dstaddr.portno);
     997        tcph->doff      = TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
     998        tcph->sum       = tcph->flags = 0;
    737999
    7381000        return E_OK;
     
    7611023                                error = E_OBJ;
    7621024                        else {
    763 
     1025                                /* コールバック関数を呼び出す。*/
    7641026#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    765 
    766                                 /* コールバック関数を呼び出す。*/
    7671027                                (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
    768 
    769 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    770 
    771                                 /* コールバック関数を呼び出す。*/
     1028#else
    7721029                                (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
    773 
    774 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    775 
     1030#endif
    7761031                                error = E_WBLK;
    7771032                                }
     
    7981053                                        error = E_OBJ;
    7991054                                else {
    800 
     1055                                        error = E_OBJ;
     1056
     1057                                        /* コールバック関数を呼び出す。*/
    8011058#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    802 
    803                                         /* コールバック関数を呼び出す。*/
    804                                         (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)E_OBJ);
    805 
    806 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    807 
    808                                         /* コールバック関数を呼び出す。*/
    809                                         error = E_OBJ;
     1059                                        (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
     1060#else
    8101061                                        (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
    811 
    812 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    813 
     1062#endif
    8141063                                        error = E_WBLK;
    8151064                                        }
     
    8591108                                *error = E_OBJ;
    8601109                        else {
     1110                                /* コールバック関数を呼び出す。*/
    8611111#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    862 
    863                                 /* コールバック関数を呼び出す。*/
    8641112                                (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
    865 
    866 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    867 
    868                                 /* コールバック関数を呼び出す。*/
     1113#else
    8691114                                (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
    870 
    871 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    872 
     1115#endif
    8731116                                *error = E_WBLK;
    8741117                                }
     
    9001143                                        *error = E_OBJ;
    9011144                                else {
    902 
     1145                                        *error = E_OBJ;
     1146
     1147                                        /* コールバック関数を呼び出す。*/
    9031148#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    904 
    905                                         /* コールバック関数を呼び出す。*/
    906                                         (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)E_OBJ);
    907 
    908 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    909 
    910                                         /* コールバック関数を呼び出す。*/
    911                                         *error = E_OBJ;
     1149                                        (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
     1150#else
    9121151                                        (*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
    913 
    914 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    915 
     1152#endif
    9161153                                        *error = E_WBLK;
    9171154                                        }
     
    9611198                                 *  受信ウィンドバッファキューのネットワークバッファを解放する。
    9621199                                 */
    963 #ifdef TCP_CFG_RWBUF_CSAVE
    964 #endif
    9651200                                syscall(wai_sem(cep->semid_lock));
    9661201                                TCP_FREE_RWBUFQ(cep);
     
    9711206                        }
    9721207                }
    973         else
     1208        else {
    9741209                syscall(clr_flg(cep->rcv_flgid, (FLGPTN)(~TCP_CEP_EVT_RWBUF_READY)));
     1210                }
    9751211
    9761212        return E_OK;
     
    9941230                while (cep->reassq != NULL) {
    9951231                        q = cep->reassq;
    996                         qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
     1232                        qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
    9971233                        if (qhdr->seq != cep->rcv_nxt)
    9981234                                break;
     
    10051241
    10061242                        /* データを受信ウィンドバッファに書き込む。*/
    1007                         TCP_WRITE_RWBUF(cep, q, (uint_t)(GET_TCP_IP_Q_HDR(q)->thoff));
     1243                        TCP_WRITE_RWBUF(cep, q, (uint_t)(GET_IP_TCP_Q_HDR_OFFSET(q)));
    10081244                        }
    10091245                }
     
    10281264
    10291265        /*  TCP ヘッダの位置を保存する。*/
    1030         GET_TCP_IP_Q_HDR(input)->thoff = thoff;
     1266        SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
    10311267
    10321268        /*
     
    10351271         *  このとき、IP のオプション(拡張ヘッダ)と TCP のオプションは削除する。
    10361272         */
    1037         len  = IF_IP_TCP_HDR_SIZE + inqhdr->slen;
     1273        len  = IF_IP_TCP_HDR_SIZE(input) + inqhdr->slen;
    10381274
    10391275        if (len <= MAX_TCP_REALLOC_SIZE) {
     
    10801316         */
    10811317        for (q = cep->reassq, p = NULL; q != NULL; ) {
    1082                 qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
     1318                qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
    10831319                if (SEQ_GT(qhdr->seq, inqhdr->seq))
    10841320                        break;
     
    11061342         */
    11071343        if (p != NULL) {
    1108                 qhdr = GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff);
     1344                qhdr = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p));
    11091345                len = qhdr->seq + qhdr->slen - inqhdr->seq;
    11101346                if (len > 0) {
     
    11691405         */
    11701406        while (q != NULL) {
    1171                 qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
     1407                qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
    11721408                len = inqhdr->seq + inqhdr->slen - qhdr->seq;
    11731409                if (len <= 0)
     
    12011437                nq = qhdr->next;
    12021438                if (p)
    1203                         GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next = nq;
     1439                        GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = nq;
    12041440                else
    12051441                        cep->reassq = nq;
     
    12131449                }
    12141450        else {
    1215                 inqhdr->next = GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next;
    1216                 GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next = input;
     1451                inqhdr->next = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next;
     1452                GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = input;
    12171453                }
    12181454
     
    12431479tcp_init_cep (T_TCP_CEP *cep)
    12441480{
     1481
    12451482#ifdef TCP_CFG_RWBUF_CSAVE
    12461483        /*
     
    12551492#endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE */
    12561493
     1494
    12571495        memset((uint8_t*)cep + offsetof(T_TCP_CEP, timer), 0,
    12581496               sizeof(T_TCP_CEP) - offsetof(T_TCP_CEP, timer));
     
    12731511         * ・送受信ウィンドバッファの省コピー機能
    12741512         * ・動的な通信端点の生成・削除機能
     1513         * ・通信端点のネットワーク層プロトコル
    12751514         */
    1276         cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK |
    1277                        TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
     1515        cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
    12781516
    12791517        /* セマフォを初期化する。*/
    1280         sig_sem (cep->semid_lock);
     1518        sig_sem(cep->semid_lock);
    12811519
    12821520        /* フラグを初期化する。*/
     
    12921530tcp_notify (T_NET_BUF *input, ER error)
    12931531{
    1294         T_IP_HDR        *iph;
    1295         T_TCP_HDR       *tcph;
    12961532        T_TCP_CEP       *cep;
    12971533
    1298         iph  = GET_IP_HDR(input);
    1299         tcph = GET_TCP_HDR(input, GET_TCP_HDR_OFFSET(input));
    1300 
    1301         if ((cep = tcp_find_cep(&iph->src, tcph->sport, &iph->dst, tcph->dport)) != NULL) {
     1534        if ((cep = tcp_find_cep(input, GET_TCP_HDR_OFFSET(input))) != NULL) {
    13021535
    13031536                /*
     
    13281561
    13291562/*
    1330  *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
    1331  *
    1332  *    注意: dstaddr は、
    1333  *          TINET-1.2 からネットワークバイトオーダ、
    1334  *          TINET-1.1 までは、ホストバイトオーダ
    1335  */
    1336 
    1337 T_TCP_CEP*
    1338 tcp_find_cep (T_IN_ADDR *dstaddr, uint16_t dstport, T_IN_ADDR *peeraddr, uint16_t peerport)
    1339 {
    1340         T_TCP_CEP*      cep;
    1341        
    1342         /*
    1343          *  状態が SYN 送信済み以後は、
    1344          *  IP アドレスとポート番号が一致する通信端点を探索する。
    1345          */
    1346         for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
    1347                 if (cep->fsm_state >= TCP_FSM_SYN_SENT                    &&
    1348                     IN_IS_DSTADDR_ACCEPT (&cep->myaddr.ipaddr,  dstaddr)  &&
    1349                     IN_ARE_NET_ADDR_EQUAL(&cep->dstaddr.ipaddr, peeraddr) &&
    1350                     dstport  == cep->myaddr.portno                        &&
    1351                     peerport == cep->dstaddr.portno)
    1352                         return cep;
    1353                 }
    1354 
    1355         /* 受動オープン中の通信端点を探索する。*/
    1356         for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
    1357                 if (cep->fsm_state == TCP_FSM_LISTEN &&
    1358                     IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, dstaddr) &&
    1359                     dstport == cep->myaddr.portno)
    1360                         return cep;
    1361                 }
    1362 
    1363         return NULL;
    1364         }
    1365 
    1366 /*
    13671563 *  tcp_lock_cep -- TCP 通信端点をロックする。
    13681564 */
     
    13771573
    13781574        /* TCP 通信端点 ID をチェックする。*/
    1379         if (!VAID_TCP_CEPID(cepid))
     1575        if (!VALID_TCP_CEPID(cepid))
    13801576                return E_ID;
    13811577
     
    14241620
    14251621#ifdef TCP_CFG_TRACE
     1622
     1623/*
     1624 *  トレース出力に用いるシリアルポート番号
     1625 */
    14261626
    14271627#ifndef CONSOLE_PORTID
     
    16241824{
    16251825        SYSTIM          time;
    1626         T_IP_HDR        *iph;
    16271826        T_TCP_HDR       *tcph;
    16281827        char            buf[9];
     
    16321831                return;
    16331832
    1634 #if defined(SUPPORT_INET4)
     1833#if defined(_IP4_CFG)
     1834
     1835#if defined(_IP6_CFG)
     1836
     1837        if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
     1838             ((cep->flags & TCP_CEP_FLG_IPV4) &&
     1839              IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
     1840              (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
     1841                return;
     1842
     1843#else   /* of #if defined(_IP6_CFG) */
    16351844
    16361845        if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
    16371846                return;
    16381847
    1639 #endif  /* of #if defined(SUPPORT_INET4) */
     1848#endif  /* of #if defined(_IP6_CFG) */
     1849
     1850#endif  /* of #if defined(_IP4_CFG) */
    16401851
    16411852        syscall(wai_sem(SEM_TCP_TRACE));
    16421853        syscall(get_tim(&time));
    1643         iph  = GET_IP_HDR(output);
    16441854        tcph = GET_TCP_HDR(output, GET_TCP_HDR_OFFSET(output));
    16451855        if (time > 99999999)
     
    16481858                trace_printf(CONSOLE_PORTID, "=O%6d.%03d", time / 1000, time % 1000);
    16491859        if (cep == NULL)
    1650                 trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:-----");
     1860                trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
    16511861        else
    1652                 trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%05x",
     1862                trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
    16531863                                             GET_TCP_CEPID(cep),
    16541864                                             tcp_strfsm[cep->fsm_state], cep->flags);
     
    16631873        trace_printf(CONSOLE_PORTID, " w:%5d l:%4d>\n",
    16641874                                     ntohs(tcph->win),
    1665                                      GET_IP_SDU_SIZE(iph) - TCP_HDR_LEN(tcph->doff));
     1875                                     GET_IP_SDU_SIZE(output) - TCP_HDR_LEN(tcph->doff));
    16661876        syscall(sig_sem(SEM_TCP_TRACE));
    16671877        }
     
    16771887{
    16781888        SYSTIM          time;
    1679         T_IP_HDR        *iph;
    16801889        T_TCP_HDR       *tcph;
    16811890        char            buf[9];
     
    16851894                return;
    16861895
    1687 #if defined(SUPPORT_INET4)
     1896#if defined(_IP4_CFG)
     1897
     1898#if defined(_IP6_CFG)
     1899
     1900        if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
     1901             ((cep->flags & TCP_CEP_FLG_IPV4) &&
     1902              IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
     1903              (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
     1904                return;
     1905
     1906#else   /* of #if defined(_IP6_CFG) */
    16881907
    16891908        if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
    16901909                return;
    16911910
    1692 #endif  /* of #if defined(SUPPORT_INET4) */
     1911#endif  /* of #if defined(_IP6_CFG) */
     1912
     1913#endif  /* of #if defined(_IP4_CFG) */
    16931914
    16941915        syscall(wai_sem(SEM_TCP_TRACE));
    16951916        syscall(get_tim(&time));
    1696         iph  = GET_IP_HDR(input);
    16971917        tcph = GET_TCP_HDR(input, GET_TCP_HDR_OFFSET(input));
    16981918        if (time > 99999999)
     
    17011921                trace_printf(CONSOLE_PORTID, "<I%6d.%03d", time / 1000, time % 1000);
    17021922        if (cep == NULL)
    1703                 trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:-----");
     1923                trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
    17041924        else
    1705                 trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%05x",
     1925                trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
    17061926                                             GET_TCP_CEPID(cep),
    17071927                                             tcp_strfsm[cep->fsm_state], cep->flags);
     
    17121932                trace_printf(CONSOLE_PORTID, " a:%10u s:%10u", tcph->ack, tcph->seq);
    17131933        trace_printf(CONSOLE_PORTID, " w:%5d l:%4d=\n",
    1714                                      tcph->win, GET_IP_SDU_SIZE(iph) - TCP_HDR_LEN(tcph->doff));
     1934                                     tcph->win, GET_IP_SDU_SIZE(input) - TCP_HDR_LEN(tcph->doff));
    17151935        syscall(sig_sem(SEM_TCP_TRACE));
    17161936        }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_cs.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 *
     
    9595#include <net/ethernet.h>
    9696#include <net/if_arp.h>
    97 #include <net/ppp_ipcp.h>
    9897#include <net/net.h>
     98#include <net/net_endian.h>
    9999#include <net/net_var.h>
    100100#include <net/net_buf.h>
     
    103103
    104104#include <netinet/in.h>
    105 #include <netinet6/in6.h>
    106 #include <netinet6/in6_var.h>
    107105#include <netinet/in_var.h>
     106#include <netinet/in_itron.h>
    108107#include <netinet/ip.h>
    109108#include <netinet/ip_var.h>
    110 #include <netinet/ip6.h>
    111 #include <netinet6/ip6_var.h>
    112 #include <netinet6/nd6.h>
    113109#include <netinet/tcp.h>
    114 #include <netinet/tcp_timer.h>
    115110#include <netinet/tcp_var.h>
    116111#include <netinet/tcp_fsm.h>
    117112#include <netinet/tcp_seq.h>
    118 #include <netinet/in_itron.h>
     113#include <netinet/tcp_timer.h>
    119114
    120115#ifdef SUPPORT_TCP
     
    122117#ifdef TCP_CFG_SWBUF_CSAVE
    123118
    124 #ifndef TCP_CFG_SWBUF_CSAVE_ONLY
     119#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
     120
     121#else   /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
    125122
    126123/*
     
    242239        }
    243240
    244 #endif  /* of #ifndef TCP_CFG_SWBUF_CSAVE_ONLY */
     241#endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
    245242
    246243/*
     
    270267{
    271268        ER_UINT error;
     269        uint_t  hdr_size = IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
    272270
    273271        /* 通信端点をロックする。*/
    274272        syscall(wai_sem(cep->semid_lock));
    275273
    276         if ((error = net_buf_siz(cep->swbufq)) > 0 && error >= IF_IP_TCP_HDR_SIZE) {
    277 
     274        if ((error = net_buf_siz(cep->swbufq)) > 0 && error >= hdr_size) {
    278275
    279276                /*
     
    291288                 *  空きサイズを 4 オクテット境界に調整する。
    292289                 */
    293                 error = (uint_t)(((error - IF_IP_TCP_HDR_SIZE) >> 2 << 2) + IF_IP_TCP_HDR_SIZE);
     290                error = (uint_t)(((error - hdr_size) >> 2 << 2) + hdr_size);
    294291
    295292                if (len > cep->sbufsz - cep->swbuf_count)
    296293                        len = (uint_t)(cep->sbufsz - cep->swbuf_count);
    297                 if (len > (error - IF_IP_TCP_HDR_SIZE))
    298                         len = (uint_t)(error - IF_IP_TCP_HDR_SIZE);
     294                if (len > (error - hdr_size))
     295                        len = (uint_t)(error - hdr_size);
    299296
    300297                /* 送信ウインドサイズによりサイズを調整する。*/
     
    315312
    316313                /* ネットワークバッファ長と IP データグラム長を設定する。*/
    317                 cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_HDR_SIZE);
    318                 SET_IP_SDU_SIZE(GET_IP_HDR(cep->swbufq), cep->swbuf_count + TCP_HDR_SIZE);
     314                cep->swbufq->len = (uint16_t)(cep->swbuf_count + hdr_size);
     315                SET_IP_SDU_SIZE(cep->swbufq, cep->swbuf_count + TCP_HDR_SIZE);
    319316
    320317                /* フラグを、送信可能に設定する。*/
     
    324321        else {  /* 送信ウインドバッファが不正 */
    325322                syslog(LOG_WARNING, "[TCP] illegal window buff for send, CEP: %d, %4d < %4d.",
    326                                     GET_TCP_CEPID(cep), error, IF_IP_TCP_HDR_SIZE);
     323                                    GET_TCP_CEPID(cep), error, hdr_size);
    327324
    328325                /* 送信ウィンドバッファキューのネットワークバッファを解放する。*/
     
    348345        int_t   win;
    349346
    350 
    351347        /* 送信ウィンドバッファが割当て済みで、空きがあれば終了する。*/
    352348        if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_READY &&
    353             (cep->swbuf_count + IF_IP_TCP_HDR_SIZE) < net_buf_siz(cep->swbufq))
     349            (cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) < net_buf_siz(cep->swbufq))
    354350                return E_OK;
    355351
     
    423419
    424420        /* ネットワークバッファを獲得する。*/
    425         if ((error = tcp_get_segment(&cep->swbufq, cep, 0,
     421        if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
    426422                                     TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
    427                                      TCP_CFG_SWBUF_CSAVE_MAX_SIZE - IF_IP_TCP_HDR_SIZE,
     423                                     TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
    428424                                     NBA_SEARCH_DESCENT, tmout)) != E_OK)
    429425                return error;
     
    463459                 *  空きサイズを 4 オクテット境界に調整する。
    464460                 */
    465                 error = (uint_t)(((error - IF_IP_TCP_HDR_SIZE) >> 2 << 2) - cep->swbuf_count);
     461                error = (uint_t)(((error - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) >> 2 << 2) - cep->swbuf_count);
    466462
    467463                /* 送信ウインドサイズによりサイズを調整する。*/
     
    508504
    509505        /* ネットワークバッファ長と IP データグラム長を設定する。*/
    510         cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_HDR_SIZE);
    511         SET_IP_SDU_SIZE(GET_IP_HDR(cep->swbufq), len + TCP_HDR_SIZE);
     506        cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr));
     507        SET_IP_SDU_SIZE(cep->swbufq, len + TCP_HDR_SIZE);
    512508
    513509        /* tcp_get_buf の割当て長をリセットする。*/
     
    573569{
    574570        return (cep->flags & TCP_CEP_FLG_WBCS_MASK) != TCP_CEP_FLG_WBCS_NBUF_READY ||
    575                 cep->swbuf_count >= cep->swbufq->len - IF_IP_TCP_HDR_SIZE;
     571                cep->swbuf_count >= cep->swbufq->len - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
    576572        }
    577573
     
    590586
    591587        /* 送信ウインドバッファのアドレスを設定する。*/
    592         cep->sbuf_wptr = cep->sbuf_rptr = GET_TCP_SDU(cep->swbufq, IF_IP_TCP_HDR_OFFSET);
     588        cep->sbuf_wptr = cep->sbuf_rptr = GET_TCP_SDU(cep->swbufq, IF_IP_TCP_NET_HDR_OFFSET(&cep->dstaddr.ipaddr));
    593589
    594590        /* フラグを、ネットワークバッファ割当て済みに設定する。*/
     
    664660#ifdef TCP_CFG_RWBUF_CSAVE
    665661
    666 #ifndef TCP_CFG_RWBUF_CSAVE_ONLY
     662#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
     663
     664#else   /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
    667665
    668666/*
     
    736734        }
    737735
    738 #endif  /* of #ifndef TCP_CFG_RWBUF_CSAVE_ONLY */
     736#endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
    739737
    740738/*
     
    753751        if (cep->rwbufq != NULL) {
    754752
    755                 qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
     753                qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
    756754                cep->rwbuf_count -= len;
    757755
     
    796794         */
    797795        while (cep->rwbufq != NULL && len > 0) {
    798                 qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
     796                qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
    799797
    800798                /*
     
    808806
    809807                memcpy(buf,
    810                        GET_TCP_SDU(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff,
     808                       GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff,
    811809                       (size_t)blen);
    812810
     
    850848
    851849                /* 受信ウィンドバッファのデータのアドレスの先頭を設定する。*/
    852                 qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
    853                 *p_buf = GET_TCP_SDU(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff;
     850                qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
     851                *p_buf = GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
    854852
    855853                /* 受信ウィンドバッファのデータ長を計算する。*/
     
    880878        if (cep->rwbuf_count == 0 && cep->reassq == NULL) {
    881879                while (cep->rwbufq != NULL) {
    882                         next = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff)->next;
     880                        next = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq))->next;
    883881
    884882#ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES
     
    961959        nextp = &cep->rwbufq;
    962960        while (*nextp)
    963                 nextp = &GET_TCP_Q_HDR(*nextp, GET_TCP_IP_Q_HDR(*nextp)->thoff)->next;
     961                nextp = &GET_TCP_Q_HDR(*nextp, GET_IP_TCP_Q_HDR_OFFSET(*nextp))->next;
    964962        *nextp = input;
    965963
     
    984982                int_t   len;
    985983
    986                 qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
     984                qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
    987985                len = qhdr->slen;
    988986
     
    999997                        /* 受信ウィンドバッファのアドレスを返す。*/
    1000998                        *cep->rcv_p_buf = GET_TCP_SDU(cep->rwbufq,
    1001                                           GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff;
     999                                          GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
    10021000
    10031001                        if (IS_PTR_DEFINED(cep->callback))
    10041002
    10051003#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1006 
    10071004                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
    1008 
    1009 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1010 
     1005#else
    10111006                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
    1012 
    1013 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1014 
     1007#endif
    10151008                        else
    10161009                                syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
     
    10531046
    10541047#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1055 
    10561048                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
    1057 
    1058 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1059 
     1049#else
    10601050                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
    1061 
    1062 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1063 
     1051#endif
    10641052                        else
    10651053                                syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_ncs.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 *
     
    9595#include <net/ethernet.h>
    9696#include <net/if_arp.h>
    97 #include <net/ppp_ipcp.h>
    9897#include <net/net.h>
     98#include <net/net_endian.h>
    9999#include <net/net_var.h>
    100100#include <net/net_buf.h>
     
    103103
    104104#include <netinet/in.h>
    105 #include <netinet6/in6.h>
    106 #include <netinet6/in6_var.h>
    107105#include <netinet/in_var.h>
     106#include <netinet/in_itron.h>
    108107#include <netinet/ip.h>
    109108#include <netinet/ip_var.h>
    110 #include <netinet/ip6.h>
    111 #include <netinet6/ip6_var.h>
    112 #include <netinet6/nd6.h>
    113109#include <netinet/tcp.h>
    114 #include <netinet/tcp_timer.h>
    115110#include <netinet/tcp_var.h>
    116111#include <netinet/tcp_fsm.h>
    117112#include <netinet/tcp_seq.h>
    118 #include <netinet/in_itron.h>
     113#include <netinet/tcp_timer.h>
    119114
    120115#ifdef SUPPORT_TCP
     
    134129{
    135130        uint8_t *wptr, *rptr;
     131        uint_t  sdu_size   = GET_IP_SDU_SIZE(output);
     132        uint_t  hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
    136133
    137134        /* SDU の大きさをチェックする。*/
    138         if (GET_IP_SDU_SIZE(GET_IP_HDR(output)) < GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len) {
     135        if (sdu_size < GET_TCP_HDR_SIZE(output, hdr_offset) + len) {
    139136                syslog(LOG_INFO, "[TCP] shrink SUD len: %d -> %d",
    140                        (uint16_t)len, (uint16_t)(GET_IP_SDU_SIZE(GET_IP_HDR(output)) - GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET)));
    141                 len = GET_IP_SDU_SIZE(GET_IP_HDR(output)) - GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET);
    142                 }
    143 
    144         wptr = GET_TCP_SDU(output, IF_IP_TCP_HDR_OFFSET);
     137                       (uint16_t)len, (uint16_t)(sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset)));
     138                len = sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset);
     139                }
     140
     141        wptr = GET_TCP_SDU(output, hdr_offset);
    145142
    146143        /* 通信端点をロックする。*/
     
    222219
    223220                        if (IS_PTR_DEFINED(cep->callback))
     221
    224222#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    225 
    226223                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
    227 
    228 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    229 
     224#else
    230225                                (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
    231 
    232 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    233 
     226#endif
    234227                        else
    235228                                syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
     
    268261
    269262#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    270 
    271263                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
    272 
    273 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    274 
     264#else
    275265                        (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
    276 
    277 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    278 
     266#endif
    279267                else
    280268                        syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
     
    628616
    629617#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    630 
    631618                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
    632 
    633 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    634 
     619#else
    635620                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
    636 
    637 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    638 
     621#endif
    639622                        else
    640623                                syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
     
    680663
    681664#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    682 
    683665                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
    684 
    685 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    686 
     666#else
    687667                                (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
    688 
    689 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    690 
     668#endif
    691669                        else
    692670                                syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.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 *
     
    9191#include <net/if_loop.h>
    9292#include <net/ethernet.h>
    93 #include <net/net.h>
     93#include <net/net_endian.h>
    9494#include <net/net_var.h>
    95 #include <net/net_buf.h>
    9695#include <net/net_timer.h>
    9796
    9897#include <netinet/in.h>
    9998#include <netinet/in_var.h>
    100 #include <netinet6/in6.h>
    101 #include <netinet6/in6_var.h>
    10299#include <netinet/ip.h>
    103 #include <netinet/ip6.h>
    104100#include <netinet/tcp.h>
    105 #include <netinet/tcp_timer.h>
    106101#include <netinet/tcp_var.h>
    107102#include <netinet/tcp_fsm.h>
    108103#include <netinet/tcp_seq.h>
     104#include <netinet/tcp_timer.h>
    109105
    110106#ifdef SUPPORT_TCP
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h

    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/* TCP タイマ変数 */
    7474
    75 #define NUM_TCP_TIMERS          4       /* TCP のタイマ数    */
     75//#define NUM_TCP_TIMERS                4       /* TCP のタイマ数    */
    7676
    7777#define TCP_TIM_REXMT           0       /* 再送タイマ                */
     
    135135#define TCP_MAX_REXMT_SHIFT     12      /* 最大再送回数               */
    136136
    137 /* TCP タイマ値の型 */
    138 
    139 typedef int16_t T_TCP_TIME;
    140 
    141137/*
    142138 *  関数
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.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 *
     
    7575#include <sil.h>
    7676#include "kernel_cfg.h"
     77#include "tinet_cfg.h"
    7778
    7879#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8384#include <t_services.h>
    8485#include "kernel_id.h"
     86#include "tinet_id.h"
    8587
    8688#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9395#include <net/if_loop.h>
    9496#include <net/ethernet.h>
    95 #include <net/ppp_ipcp.h>
    9697#include <net/net.h>
     98#include <net/net_endian.h>
    9799#include <net/net_var.h>
    98100#include <net/net_buf.h>
     
    102104#include <netinet/in.h>
    103105#include <netinet/in_var.h>
    104 #include <netinet6/in6.h>
    105 #include <netinet6/in6_var.h>
    106106#include <netinet/in_itron.h>
    107107#include <netinet/ip.h>
    108108#include <netinet/ip_var.h>
    109 #include <netinet/ip6.h>
    110 #include <netinet6/ip6_var.h>
    111109#include <netinet/tcp.h>
    112 #include <netinet/tcp_timer.h>
    113110#include <netinet/tcp_var.h>
    114111#include <netinet/tcp_fsm.h>
    115112#include <netinet/tcp_seq.h>
     113#include <netinet/tcp_timer.h>
    116114
    117115#include <net/if_var.h>
    118116
    119117#ifdef SUPPORT_TCP
    120 
    121 /*
    122  *  IPv4 と IPv6 の切り替えマクロ
    123  */
    124 
    125 #if defined(SUPPORT_INET4)
    126 
    127 #define TCP_CRE_REP     tcp_cre_rep
    128 #define TCP_ACP_CEP     tcp_acp_cep
    129 #define TCP_CON_CEP     tcp_con_cep
    130 
    131 #endif  /* of #if defined(SUPPORT_INET4) */
    132 
    133 #if defined(SUPPORT_INET6)
    134 
    135 #define TCP_CRE_REP     tcp6_cre_rep
    136 #define TCP_ACP_CEP     tcp6_acp_cep
    137 #define TCP_CON_CEP     tcp6_con_cep
    138 
    139 #endif  /* of #if defined(SUPPORT_INET6) */
    140118
    141119/*
     
    169147
    170148/*
    171  *  tcp_cre_rep -- TCP 受付口の生成【拡張機能】
    172  */
    173 
    174 #ifdef __tcp_cre_rep
    175 
    176 #ifdef TCP_CFG_EXTENTIONS
    177 
    178 ER
    179 TCP_CRE_REP (ID repid, T_TCP_CREP *pk_crep)
    180 {
    181         T_TCP_REP       *rep;
    182         ER              error;
    183 
    184         /* TCP 受付口 ID をチェックする。*/
    185         if (!VAID_TCP_REPID(repid))
    186                 return E_ID;
    187 
    188         /* pk_crep が NULL ならエラー */
    189         if (pk_crep == NULL)
    190                 return E_PAR;
    191 
    192         /* TCP 受付口を得る。*/
    193         rep = GET_TCP_REP(repid);
    194 
    195         /* TCP 受付口が、動的生成用でなければエラー */
    196         if (!DYNAMIC_TCP_REP(rep))
    197                 return E_ID;
    198 
    199         /* 受付口をロックする。*/
    200         syscall(wai_sem(rep->semid_lock));
    201 
    202         /*
    203          * TCP 受付口をチェックする。生成済みであればエラー
    204          */
    205         if (VALID_TCP_REP(rep))
    206                 error = E_OBJ;
    207         else {
    208 
    209                 /* TCP 受付口生成情報をコピーする。*/
    210                 rep->repatr = pk_crep->repatr;          /* 受付口属性                */
    211                 rep->myaddr = pk_crep->myaddr;          /* 自分のアドレス      */
    212 
    213                 /* TCP 受付口を生成済みにする。*/
    214                 rep->flags |= TCP_REP_FLG_VALID;
    215                 error = E_OK;
    216                 }
    217 
    218         /* 受付口のロックを解除する。*/
    219         syscall(sig_sem(rep->semid_lock));
    220 
    221         return error;
    222         }
    223 
    224 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    225 
    226 #endif  /* of #ifdef __tcp_cre_cep */
    227 
    228 #ifdef __tcp_del_rep
    229 
    230 #ifdef TCP_CFG_EXTENTIONS
    231 
    232 /*
    233  *  tcp_find_cep_rep -- TCP 受付口をリンクしている TCP 通信端点を得る。
    234  */
    235 
    236 static T_TCP_CEP*
    237 tcp_find_cep_rep (T_TCP_REP* rep)
    238 {
    239         T_TCP_CEP*      cep;
    240 
    241         for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
    242                 if (cep->rep == rep)
    243                         return cep;
    244                 }
    245 
    246         return NULL;
    247         }
    248 
    249 /*
    250  *  tcp_del_rep -- TCP 受付口の削除【拡張機能】
    251  */
    252 
    253 
    254 ER
    255 tcp_del_rep (ID repid)
    256 {
    257         T_TCP_CEP       *cep;
    258         T_TCP_REP       *rep;
    259         ER              error = E_OK;
    260 
    261         /* TCP 受付口 ID をチェックする。*/
    262         if (!VAID_TCP_REPID(repid))
    263                 return E_ID;
    264 
    265         /* TCP 受付口を得る。*/
    266         rep = GET_TCP_REP(repid);
    267 
    268         /* TCP 受付口が、動的生成用でなければエラー */
    269         if (!DYNAMIC_TCP_REP(rep))
    270                 return E_ID;
    271 
    272         /* 受付口をロックする。*/
    273         syscall(wai_sem(rep->semid_lock));
    274 
    275         /* TCP 受付口をチェックする。未生成の場合はエラー */
    276         if (!VALID_TCP_REP(rep))
    277                 error = E_NOEXS;
    278         else {
    279                 if ((cep = tcp_find_cep_rep(rep)) != NULL) {
    280                         /*
    281                          * すでに受動オープンしているとき
    282                          *(tcp_acp_cep が呼ばれているとき)は、
    283                          * tcp_acp_cep を終了させる。
    284                          */
    285 
    286                         /* 通信端点をロックする。*/
    287                         syscall(wai_sem(cep->semid_lock));
    288 
    289                         /*
    290                          *  通信端点から受付口を解放し、
    291                          *  イベントフラグをクローズに設定する。
    292                          */
    293                         cep->rep = NULL;
    294                         cep->fsm_state = TCP_FSM_CLOSED;
    295                         cep->error = E_DLT;
    296                         syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
    297 
    298 #ifdef TCP_CFG_NON_BLOCKING
    299 
    300                         if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
    301                                 if (IS_PTR_DEFINED(cep->callback)) {
    302 
    303 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    304 
    305                                         (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_DLT);
    306 
    307 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    308 
    309                                         ER      error = E_DLT;
    310 
    311                                         (*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
    312 
    313 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    314 
    315                                         }
    316                                 else
    317                                         error = E_OBJ;
    318                                 cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
    319                                 }
    320 
    321 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    322 
    323                         cep->rcv_tskid = TA_NULL;
    324                         cep->rcv_tfn   = TFN_TCP_UNDEF;
    325 
    326                         /* 通信端点のロックを解除する。*/
    327                         syscall(sig_sem(cep->semid_lock));
    328 
    329                         }
    330                 else
    331                         error = E_OK;
    332 
    333                 /* TCP 受付口を未生成にする。*/
    334                 rep->flags &= ~TCP_REP_FLG_VALID;
    335                 }
    336 
    337         /* 受付口のロックを解除する。*/
    338         syscall(sig_sem(rep->semid_lock));
    339 
    340         return error;
    341         }
    342 
    343 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    344 
    345 #endif  /* of #ifdef __tcp_del_rep */
    346 
    347 /*
    348  *  tcp_cre_cep -- TCP 通信端点の生成【拡張機能】
    349  */
    350 
    351 #ifdef __tcp_cre_cep
    352 
    353 #ifdef TCP_CFG_EXTENTIONS
    354 
    355 ER
    356 tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
    357 {
    358         T_TCP_CEP       *cep;
    359         ER              error;
    360 
    361         /* TCP 通信端点 ID をチェックする。*/
    362         if (!VAID_TCP_CEPID(cepid))
    363                 return E_ID;
    364 
    365         /* pk_ccep が NULL ならエラー */
    366         if (pk_ccep == NULL)
    367                 return E_PAR;
    368 
    369         /* TCP 通信端点を得る。*/
    370         cep = GET_TCP_CEP(cepid);
    371 
    372         /* TCP 通信端点が、動的生成用でなければエラー */
    373         if (!DYNAMIC_TCP_CEP(cep))
    374                 return E_ID;
    375 
    376         /* 通信端点をロックする。*/
    377         syscall(wai_sem(cep->semid_lock));
    378 
    379         /*
    380          * TCP 通信端点をチェックする。生成済みであればエラー
    381          */
    382         if (VALID_TCP_CEP(cep))
    383                 error = E_OBJ;
    384         else {
    385 
    386                 /* TCP 通信端点生成情報をコピーする。*/
    387                 cep->cepatr   = pk_ccep->cepatr;                /* 通信端点属性                       */
    388                 cep->sbuf     = pk_ccep->sbuf;                  /* 送信用ウィンドバッファ  */
    389                 cep->sbufsz   = pk_ccep->sbufsz;                /* 送信用ウィンドバッファサイズ       */
    390                 cep->rbuf     = pk_ccep->rbuf;                  /* 受信用ウィンドバッファ  */
    391                 cep->rbufsz   = pk_ccep->rbufsz;                /* 受信用ウィンドバッファサイズ       */
    392                 cep->callback = (void*)pk_ccep->callback;       /* コールバック                       */
    393 
    394                 /* TCP 通信端点を生成済みにする。*/
    395                 cep->flags |= TCP_CEP_FLG_VALID;
    396                 error = E_OK;
    397                 }
    398 
    399         /* 通信端点のロックを解除する。*/
    400         syscall(sig_sem(cep->semid_lock));
    401 
    402         return error;
    403         }
    404 
    405 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    406 
    407 #endif  /* of #ifdef __tcp_cre_cep */
    408 
    409 /*
    410  *  tcp_del_cep -- TCP 通信端点の削除【拡張機能】
    411  */
    412 
    413 #ifdef __tcp_del_cep
    414 
    415 #ifdef TCP_CFG_EXTENTIONS
    416 
    417 ER
    418 tcp_del_cep (ID cepid)
    419 {
    420         T_TCP_CEP       *cep;
    421         ER              error;
    422 
    423         /* TCP 通信端点 ID をチェックする。*/
    424         if (!VAID_TCP_CEPID(cepid))
    425                 return E_ID;
    426 
    427         /* TCP 通信端点を得る。*/
    428         cep = GET_TCP_CEP(cepid);
    429 
    430         /* TCP 通信端点が、動的生成用でなければエラー */
    431         if (!DYNAMIC_TCP_CEP(cep))
    432                 return E_ID;
    433 
    434         /* 通信端点をロックする。*/
    435         syscall(wai_sem(cep->semid_lock));
    436 
    437         /*
    438          * TCP 通信端点をチェックする。以下の場合はエラー
    439          * ・未生成。
    440          * ・使用中。
    441          */
    442         if (!VALID_TCP_CEP(cep))
    443                 error = E_NOEXS;
    444         else if (cep->fsm_state != TCP_FSM_CLOSED)
    445                 error = E_OBJ;
    446         else {
    447 
    448                 /* TCP 通信端点を未生成にする。*/
    449                 cep->flags &= ~TCP_CEP_FLG_VALID;
    450                 error = E_OK;
    451                 }
    452 
    453         /* 通信端点のロックを解除する。*/
    454         syscall(sig_sem(cep->semid_lock));
    455 
    456         return error;
    457         }
    458 
    459 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    460 
    461 #endif  /* of #ifdef __tcp_del_cep */
    462 
    463 #ifdef TCP_CFG_PASSIVE_OPEN
    464 
    465 /*
    466  *  tcp_acp_cep -- 接続要求待ち (受動オープン)【標準機能】
    467  */
    468 
    469 #ifdef __tcp_acp_cep
    470 
    471 ER
    472 TCP_ACP_CEP (ID cepid, ID repid, T_IPEP *p_dstaddr, TMO tmout)
    473 {
    474         T_TCP_REP       *rep;
    475         T_TCP_CEP       *cep;
    476         ER              error;
    477         FLGPTN          flag;
    478 
    479         /* TCP 受付口をチェックする。*/
    480         if (!VAID_TCP_REPID(repid))
    481                 return E_ID;
    482 
    483 #ifdef TCP_CFG_NON_BLOCKING
    484 
    485         /* p_dstaddr が NULL ならエラー */
    486         if (p_dstaddr == NULL)
    487                 return E_PAR;
    488 
    489 #else   /* of #ifdef TCP_CFG_NON_BLOCKING */
    490 
    491         /* p_dstaddr が NULL か、tmout が TMO_NBLK ならエラー */
    492         if (p_dstaddr == NULL || tmout == TMO_NBLK)
    493                 return E_PAR;
    494 
    495 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    496 
    497         /*
    498          *  CEP をロックし、API 機能コードとタスク識別子を記録する。
    499          *  すでに記録されていれば、ペンディング中なのでエラー
    500          */
    501         if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_ACP_CEP)) != E_OK)
    502                 return error;
    503 
    504         /* CEP の FSM がクローズ状態でなければエラー。*/
    505         if (cep->fsm_state != TCP_FSM_CLOSED) {
    506                 error = E_OBJ;
    507                 goto err_ret;
    508                 }
    509         syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
    510 
    511         /* TCP 通信端点を初期化する。*/
    512         tcp_init_cep(cep);
    513 
    514         /* TCP 受付口を得る。*/
    515         rep = GET_TCP_REP(repid);
    516 
    517 #ifdef TCP_CFG_EXTENTIONS
    518 
    519         /* TCP 受付口をロックする。*/
    520         syscall(wai_sem(rep->semid_lock));
    521 
    522         /* TCP 受付口をチェックする。*/
    523         if (!VALID_TCP_REP(rep)) {
    524                 syscall(sig_sem(rep->semid_lock));
    525                 error = E_NOEXS;
    526                 goto err_ret;
    527                 }
    528 
    529 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    530 
    531         /* TCP 通信端点にTCP受付口を記録する。*/
    532         cep->rep = rep;
    533 
    534 #ifdef TCP_CFG_EXTENTIONS
    535 
    536         /* TCP 受付口のロックを解除する。*/
    537         syscall(sig_sem(rep->semid_lock));
    538 
    539 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    540 
    541         /* TCP 受付口のアドレスをコピーする。*/
    542         cep->myaddr = rep->myaddr;
    543 
    544         /* 通信端点を設定する。*/
    545         cep->fsm_state = TCP_FSM_LISTEN;
    546 
    547 #ifdef TCP_CFG_NON_BLOCKING
    548 
    549         /* タイムアウトをチェックする。*/
    550         if (tmout == TMO_NBLK) {
    551                 /* ノンブロッキングコール */
    552                 cep->p_dstaddr    = p_dstaddr;
    553                 cep->rcv_nblk_tfn = TFN_TCP_ACP_CEP;
    554                 return E_WBLK;
    555                 }
    556         else {
    557 
    558 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    559 
    560                 /*
    561                  *  FSM が ESTABLISHED になるまで待つ。
    562                  *  FSM が CLOSED になった場合は、エラーが発生したことを意味している。
    563                  */
    564                 error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
    565                                                   TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
    566                 if (error == E_OK) {
    567                         if (cep->error != E_OK)
    568                                 error = cep->error;
    569                         else if (cep->fsm_state == TCP_FSM_CLOSED)
    570                                 error = E_TMOUT;
    571                         }
    572 
    573                 syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
    574 
    575                 if (error == E_OK) {
    576                         /* 相手のアドレスをコピーする。*/
    577                         *p_dstaddr = cep->dstaddr;
    578                         }
    579                 else {
    580                         /*
    581                          *  通信端点から受付口を解放し、
    582                          *  イベントフラグをクローズに設定する。
    583                          */
    584                         cep->rep = NULL;
    585                         cep->fsm_state = TCP_FSM_CLOSED;
    586                         syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
    587                         }
    588 
    589 #ifdef TCP_CFG_NON_BLOCKING
    590 
    591                 }
    592 
    593 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    594 
    595 err_ret:
    596         cep->rcv_tskid = TA_NULL;
    597         cep->rcv_tfn   = TFN_TCP_UNDEF;
    598         return error;
    599         }
    600 
    601 #endif  /* of #ifdef __tcp_acp_cep */
    602 
    603 #endif  /* of #ifdef TCP_CFG_PASSIVE_OPEN */
    604 
    605 /*
    606  *  tcp_con_cep -- 接続要求 (能動オープン)【標準機能】
    607  */
    608 
    609 #ifdef __tcp_con_cep
    610 
    611 ER
    612 TCP_CON_CEP (ID cepid, T_IPEP *p_myaddr, T_IPEP *p_dstaddr, TMO tmout)
    613 {
    614         T_TCP_CEP       *cep;
    615         ER              error;
    616         FLGPTN          flag;
    617 
    618 #ifdef TCP_CFG_NON_BLOCKING
    619 
    620         /*
    621          *  p_dstaddr または p_myaddr が NULL か、
    622          *  あて先がマルチキャストアドレスならエラー
    623          */
    624         if (p_myaddr == NULL || p_dstaddr == NULL || IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr))
    625                 return E_PAR;
    626 
    627 #else   /* of #ifdef TCP_CFG_NON_BLOCKING */
    628 
    629         /*
    630          *  p_dstaddr または p_myaddr が NULL 、
    631          *  あて先がマルチキャストアドレスか、
    632          *  tmout が TMO_NBLK ならエラー
    633          */
    634         if (p_myaddr == NULL || p_dstaddr == NULL ||
    635             IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr) || tmout == TMO_NBLK)
    636                 return E_PAR;
    637 
    638 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    639 
    640         /*
    641          *  CEP をロックし、API 機能コードとタスク識別子を記録する。
    642          *  すでに記録されていれば、ペンディング中なのでエラー
    643          */
    644         if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CON_CEP)) != E_OK)
    645                 return error;
    646 
    647         /* CEP の FSM がクローズ状態でなければエラー。*/
    648         if (cep->fsm_state != TCP_FSM_CLOSED) {
    649                 error = E_OBJ;
    650                 goto err_ret;
    651                 }
    652         syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
    653 
    654         /* シーケンス番号を初期化する。*/
    655         if (tcp_iss == 0)
    656                 tcp_init_iss();
    657 
    658         /* 通信端点を初期化する。*/
    659         tcp_init_cep(cep);
    660 
    661         /*
    662          *  p_myaddr が NADR (-1) ではなく、自 IP アドレスが ANY でなければ、
    663          *  指定された IP アドレスを割り当てる。
    664          */
    665         if (p_myaddr != NADR && !IN_IS_ADDR_ANY(&p_myaddr->ipaddr))
    666                 cep->myaddr.ipaddr = p_myaddr->ipaddr;
    667         else {
    668                 T_IN_IFADDR     *ia;
    669 
    670                 if ((ia = IN_IFAWITHIFP(IF_GET_IFNET(), &p_dstaddr->ipaddr)) == NULL) {
    671                         error = E_PAR;
    672                         goto err_ret;
    673                         }
    674                 cep->myaddr.ipaddr = ia->addr;
    675                 }
    676 
    677         /* 通信端点を設定する。*/
    678         cep->fsm_state = TCP_FSM_SYN_SENT;
    679         cep->dstaddr   = *p_dstaddr;
    680         cep->iss       = tcp_iss;
    681         cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INIT;
    682         tcp_iss += TCP_ISS_INCR() / 2;
    683         init_send_seq(cep);
    684 
    685 #ifdef TCP_CFG_NON_BLOCKING
    686 
    687         /* タイムアウトをチェックする。*/
    688         if (tmout == TMO_NBLK) {
    689                 /* ノンブロッキングコール */
    690                 cep->p_dstaddr    = p_dstaddr;
    691                 cep->p_myaddr     = p_myaddr;
    692                 cep->snd_nblk_tfn = TFN_TCP_CON_CEP;
    693 
    694                 /* コネクションの開設をポストする。*/
    695                 cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
    696                 sig_sem(SEM_TCP_POST_OUTPUT);
    697                 return E_WBLK;
    698                 }
    699         else {
    700 
    701 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    702 
    703                 /*
    704                  *  p_myaddr が NADR (-1) か、
    705                  *  自ポート番号が TCP_PORTANY なら、自動で割り当てる。
    706                  */
    707                 if (p_myaddr == NADR || p_myaddr->portno == TCP_PORTANY)
    708                         tcp_alloc_auto_port(cep);
    709                 else if ((error = tcp_alloc_port(cep, p_myaddr->portno)) != E_OK)
    710                         goto err_ret;
    711 
    712                 /* コネクションの開設をポストする。*/
    713                 cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
    714                 sig_sem(SEM_TCP_POST_OUTPUT);
    715 
    716                 /*
    717                  *  イベントが ESTABLISHED になるまで待つ。
    718                  *  イベントが CLOSED になった場合は、何らかのエラーが発生したか、
    719                  *  接続要求が拒否されたことを意味している。
    720                  */
    721                 error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
    722                                                   TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
    723                 if (error == E_OK) {
    724                         if (cep->error != E_OK)
    725                                 error = cep->error;
    726                         else if (cep->fsm_state == TCP_FSM_CLOSED)
    727                                 error = E_CLS;
    728                         }
    729 
    730                 syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
    731 
    732                 if (error != E_OK) {
    733                         /*
    734                          *  通信端点から受付口を解放し、
    735                          *  イベントフラグをクローズに設定する。
    736                          */
    737                         cep->rep = NULL;
    738                         cep->fsm_state = TCP_FSM_CLOSED;
    739                         syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
    740                         }
    741 
    742 #ifdef TCP_CFG_NON_BLOCKING
    743 
    744                 }
    745 
    746 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    747 
    748 err_ret:
    749         cep->snd_tskid = TA_NULL;
    750         cep->snd_tfn   = TFN_TCP_UNDEF;
    751         return error;
    752         }
    753 
    754 #endif  /* of #ifdef __tcp_con_cep */
     149 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
     150 */
     151
     152#if defined(SUPPORT_INET6)
     153
     154#define T_IPEP                  T_IPV6EP
     155#define TCP_ACP_CEP             tcp6_acp_cep
     156#define TCP_CON_CEP             tcp6_con_cep
     157#define TCP_FIND_CEP_REP        tcp6_find_cep_rep
     158
     159#if defined(SUPPORT_INET4)
     160
     161#undef  T_TCP_REP
     162#define T_TCP_REP               T_TCP6_REP
     163
     164#endif  /* of #if defined(SUPPORT_INET4) */
     165
     166#define TCP_CRE_REP             tcp6_cre_rep
     167#define TCP_DEL_REP_BODY        tcp6_del_rep_body
     168#define GET_TCP_REP             GET_TCP6_REP
     169#define VALID_TCP_REPID         VALID_TCP6_REPID
     170#define T_TCPN_CREP             T_TCP6_CREP
     171#define API_PROTO               API_PROTO_IPV6
     172
     173#include <netinet/tcpn_usrreq.c>
     174
     175#undef  T_IPEP
     176#undef  TCP_ACP_CEP
     177#undef  TCP_CON_CEP
     178#undef  TCP_FIND_CEP_REP
     179
     180#undef  TCP_CRE_REP
     181#undef  TCP_DEL_REP_BODY
     182#undef  GET_TCP_REP
     183#undef  VALID_TCP_REPID
     184#undef  T_TCPN_CREP
     185#undef  API_PROTO
     186
     187#endif  /* of #if defined(SUPPORT_INET6) */
     188
     189#if defined(SUPPORT_INET4)
     190
     191#define T_IPEP                  T_IPV4EP
     192#define TCP_ACP_CEP             tcp_acp_cep
     193#define TCP_CON_CEP             tcp_con_cep
     194#define TCP_FIND_CEP_REP        tcp4_find_cep_rep
     195
     196#if defined(SUPPORT_INET6)
     197
     198#undef  T_TCP_REP
     199#define T_TCP_REP               T_TCP4_REP
     200
     201#endif  /* of #if defined(SUPPORT_INET6) */
     202
     203#define TCP_CRE_REP             tcp_cre_rep
     204#define TCP_DEL_REP_BODY        tcp4_del_rep_body
     205#define GET_TCP_REP             GET_TCP4_REP
     206#define VALID_TCP_REPID         VALID_TCP4_REPID
     207#define T_TCPN_CREP             T_TCP_CREP
     208#define API_PROTO               API_PROTO_IPV4
     209
     210#include <netinet/tcpn_usrreq.c>
     211
     212#endif  /* of #if defined(SUPPORT_INET4) */
    755213
    756214#ifdef __tcp_cls_cep
     
    904362                                 * ・動的な通信端点の生成・削除機能
    905363                                 */
    906                                 cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK |
    907                                                TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
     364                                cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
    908365
    909366                                /*
     
    1025482                        sig_sem(SEM_TCP_POST_OUTPUT);
    1026483
     484                        /* コールバック関数を呼び出す。*/
    1027485#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1028 
    1029                         /* コールバック関数を呼び出す。*/
    1030486                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)error);
    1031 
    1032 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1033 
    1034                         /* コールバック関数を呼び出す。*/
     487#else
    1035488                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)&error);
    1036 
    1037 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1038 
     489#endif
    1039490                        error = E_WBLK;
    1040491                        goto err_ret;
     
    1082533
    1083534#endif  /* of #ifdef __tcp_snd_dat */
    1084 
    1085 #ifdef __tcp_snd_oob
    1086 
    1087 #ifdef TCP_CFG_EXTENTIONS
    1088 
    1089 /*
    1090  *  tcp_snd_oob -- 緊急データの送信【拡張機能】
    1091  */
    1092 
    1093 ER_UINT
    1094 tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
    1095 {
    1096         T_TCP_CEP       *cep;
    1097         ER_UINT         error;
    1098 
    1099 #ifdef TCP_CFG_NON_BLOCKING
    1100 
    1101         /* data が NULL か、len < 0 ならエラー */
    1102         if (data == NULL || len < 0)
    1103                 return E_PAR;
    1104 
    1105 #else   /* of #ifdef TCP_CFG_NON_BLOCKING */
    1106 
    1107         /* data が NULL、len < 0 か、tmout が TMO_NBLK ならエラー */
    1108         if (data == NULL || len < 0 || tmout == TMO_NBLK)
    1109                 return E_PAR;
    1110 
    1111 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    1112 
    1113         /*
    1114          *  CEP をロックし、API 機能コードとタスク識別子を記録する。
    1115          *  すでに記録されていれば、ペンディング中なのでエラー
    1116          */
    1117         if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
    1118                 return error;
    1119 
    1120         /* 送信できるか、通信端点の状態を見る。*/
    1121         if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
    1122                 goto err_ret;
    1123 
    1124 #ifdef TCP_CFG_NON_BLOCKING
    1125 
    1126         /* タイムアウトをチェックする。*/
    1127         if (tmout == TMO_NBLK) {                /* ノンブロッキングコール */
    1128 
    1129                 /* 送信ウィンドバッファに空きがあればコールバック関数を呼び出す。*/
    1130                 if (!TCP_IS_SWBUF_FULL(cep)) {
    1131 
    1132                         /* 送信ウィンドバッファにデータを書き込む。*/
    1133                         error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
    1134 
    1135                         /* 送信緊急ポインタを設定する。*/
    1136                         cep->snd_up = cep->snd_una + cep->swbuf_count;
    1137 
    1138                         /* 出力をポストする。*/
    1139                         cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
    1140                         sig_sem(SEM_TCP_POST_OUTPUT);
    1141 
    1142 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1143 
    1144                         /* コールバック関数を呼び出す。*/
    1145                         (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
    1146 
    1147 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1148 
    1149                         /* コールバック関数を呼び出す。*/
    1150                         (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
    1151 
    1152 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1153 
    1154                         error = E_WBLK;
    1155                         goto err_ret;
    1156                         }
    1157                 else {
    1158                         cep->snd_data     = data;
    1159                         cep->snd_len      = len;
    1160                         cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
    1161                         TCP_ALLOC_SWBUF(cep);
    1162 
    1163                         return E_WBLK;
    1164                         }
    1165                 }
    1166         else {          /* 非ノンブロッキングコール */
    1167 
    1168 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    1169 
    1170                 /* 送信ウィンドバッファが空くのを待つ。*/
    1171                 if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
    1172                         goto err_ret;
    1173 
    1174                 /* 送信ウィンドバッファにデータを書き込む。*/
    1175                 if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
    1176 
    1177                         /* 送信緊急ポインタを設定する。*/
    1178                         cep->snd_up = cep->snd_una + cep->swbuf_count;
    1179 
    1180                         /* データを送信する。送信ウィンドバッファがフルのときは強制的に送信する。*/
    1181                         if (TCP_IS_SWBUF_FULL(cep))
    1182                                 cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
    1183 
    1184                         /* 出力をポストする。*/
    1185                         cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
    1186                         sig_sem(SEM_TCP_POST_OUTPUT);
    1187                         }
    1188 
    1189 #ifdef TCP_CFG_NON_BLOCKING
    1190 
    1191                 }
    1192 
    1193 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    1194 
    1195 err_ret:
    1196         cep->snd_tskid = TA_NULL;
    1197         cep->snd_tfn   = TFN_TCP_UNDEF;
    1198         return error;
    1199         }
    1200 
    1201 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    1202 
    1203 #endif  /* of #ifdef __tcp_snd_oob */
    1204535
    1205536#ifdef __tcp_get_buf
     
    1250581                        error = TCP_GET_SWBUF_ADDR(cep, p_buf);
    1251582
     583                        /* コールバック関数を呼び出す。*/
    1252584#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1253 
    1254                         /* コールバック関数を呼び出す。*/
    1255585                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)error);
    1256 
    1257 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1258 
    1259                         /* コールバック関数を呼び出す。*/
     586#else
    1260587                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)&error);
    1261 
    1262 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1263 
     588#endif
    1264589                        error = E_WBLK;
    1265590                        goto err_ret;
     
    1401726                        len = TCP_READ_RWBUF(cep, data, (uint_t)len);
    1402727
     728                        /* コールバック関数を呼び出す。*/
    1403729#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1404 
    1405730                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)(uint32_t)len);
    1406 
    1407 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1408 
     731#else
    1409732                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)&len);
    1410 
    1411 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1412 
     733#endif
    1413734                        error = E_WBLK;
    1414735                        goto err_ret;
     
    1449770
    1450771#endif  /* of #ifdef __tcp_rcv_dat */
    1451 
    1452 #ifdef __tcp_rcv_oob
    1453 
    1454 #ifdef TCP_CFG_EXTENTIONS
    1455 
    1456 /*
    1457  *  tcp_rcv_oob -- 緊急データの受信【拡張機能】
    1458  *
    1459  *    注意: 送信側が複数オクテットのデータを送信しても、
    1460  *          緊急ポインタが指す 1 オクテットのデータのみ受信する。
    1461  */
    1462 
    1463 ER_UINT
    1464 tcp_rcv_oob (ID cepid, void *data, int_t len)
    1465 {
    1466         T_TCP_CEP       *cep;
    1467         uint8_t         *urg;
    1468 
    1469         /* TCP 通信端点 ID をチェックする。*/
    1470         if (!VAID_TCP_CEPID(cepid))
    1471                 return E_ID;
    1472 
    1473         /* data が NULL か、len < 0 ならエラー */
    1474         if (data == NULL || len < 0)
    1475                 return E_PAR;
    1476 
    1477         /* TCP 通信端点を得る。*/
    1478         cep = GET_TCP_CEP(cepid);
    1479 
    1480         /* 受信できるか、通信端点の状態を見る。*/
    1481         /* 受信できるか、fsm_state を見る。*/
    1482         if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
    1483                 return E_OBJ;
    1484 
    1485         /*
    1486          *  緊急データ入りのセグメントの TCP ヘッダが
    1487          *  設定されていなければ、緊急データを受信していない。
    1488          */
    1489         if (cep->urg_tcph == NULL)
    1490                 return E_OBJ;
    1491 
    1492         /* len == 0 ならバッファオーバーフロー */
    1493         if (len == 0)
    1494                 return E_BOVR;
    1495 
    1496         /* 緊急ポインタが指す 1 オクテットのデータを読み取る。*/
    1497         urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
    1498         *(uint8_t*)data = *urg;
    1499 
    1500         /* 読み取ったデータから後ろの SDU を前に詰める。*/
    1501         memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
    1502 
    1503         /* tcp_rcv_oob() が呼出されたこと知らせるために、NULL を設定する。*/
    1504         cep->urg_tcph = NULL;
    1505 
    1506         return 1;
    1507         }
    1508 
    1509 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    1510 
    1511 #endif  /* of #ifdef __tcp_rcv_oob */
    1512772
    1513773#ifdef __tcp_rcv_buf
     
    1559819                        error = TCP_GET_RWBUF_ADDR(cep, p_buf);
    1560820
     821                        /* コールバック関数を呼び出す。*/
    1561822#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    1562 
    1563                         /* コールバック関数を呼び出す。*/
    1564823                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)error);
    1565 
    1566 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1567 
    1568                         /* コールバック関数を呼び出す。*/
     824#else
    1569825                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)&error);
    1570 
    1571 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    1572 
     826#endif
    1573827                        error = E_WBLK;
    1574828                        goto err_ret;
     
    1705959
    1706960                        case TFN_TCP_CON_CEP:
    1707                                 /*  通信端点から受付口を解放する。*/
     961                                /*
     962                                 *  通信端点から受付口を解放し、
     963                                 *  イベントフラグをクローズに設定する。
     964                                 */
    1708965                                cep->rep = NULL;
     966
     967#if defined(_IP6_CFG) && defined(_IP4_CFG)
     968                                cep->rep4 = NULL;
     969#endif
     970
    1709971                                cep->fsm_state = TCP_FSM_CLOSED;
    1710972                                syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
     
    18001062                                 */
    18011063                                cep->rep = NULL;
     1064
     1065#if defined(_IP6_CFG) && defined(_IP4_CFG)
     1066                                cep->rep4 = NULL;
     1067#endif
     1068
    18021069                                cep->fsm_state = TCP_FSM_CLOSED;
    18031070                                syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
     
    18661133
    18671134        /* TCP 通信端点 ID をチェックする。*/
    1868         if (!VAID_TCP_CEPID(cepid))
     1135        if (!VALID_TCP_CEPID(cepid))
    18691136                return E_ID;
    18701137
     
    19141181#endif  /* of #ifdef __tcp_can_cep */
    19151182
     1183#ifdef TCP_CFG_EXTENTIONS
     1184
     1185#ifdef __tcp_cre_cep
     1186
     1187/*
     1188 *  tcp_cre_cep -- TCP 通信端点の生成【拡張機能】
     1189 */
     1190
     1191ER
     1192tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
     1193{
     1194        T_TCP_CEP       *cep;
     1195        ER              error;
     1196
     1197        /* TCP 通信端点 ID をチェックする。*/
     1198        if (!VALID_TCP_CEPID(cepid))
     1199                return E_ID;
     1200
     1201        /* pk_ccep が NULL ならエラー */
     1202        if (pk_ccep == NULL)
     1203                return E_PAR;
     1204
     1205        /* TCP 通信端点を得る。*/
     1206        cep = GET_TCP_CEP(cepid);
     1207
     1208        /* TCP 通信端点が、動的生成用でなければエラー */
     1209        if (!DYNAMIC_TCP_CEP(cep))
     1210                return E_ID;
     1211
     1212        /* 通信端点をロックする。*/
     1213        syscall(wai_sem(cep->semid_lock));
     1214
     1215        /*
     1216         * TCP 通信端点をチェックする。生成済みであればエラー
     1217         */
     1218        if (VALID_TCP_CEP(cep))
     1219                error = E_OBJ;
     1220        else {
     1221
     1222                /* TCP 通信端点生成情報をコピーする。*/
     1223                cep->cepatr   = pk_ccep->cepatr;                /* 通信端点属性                       */
     1224                cep->sbuf     = pk_ccep->sbuf;                  /* 送信用ウィンドバッファ  */
     1225                cep->sbufsz   = pk_ccep->sbufsz;                /* 送信用ウィンドバッファサイズ       */
     1226                cep->rbuf     = pk_ccep->rbuf;                  /* 受信用ウィンドバッファ  */
     1227                cep->rbufsz   = pk_ccep->rbufsz;                /* 受信用ウィンドバッファサイズ       */
     1228                cep->callback = (void*)pk_ccep->callback;       /* コールバック                       */
     1229
     1230                /* TCP 通信端点を生成済みにする。*/
     1231                cep->flags |= TCP_CEP_FLG_VALID;
     1232                error = E_OK;
     1233                }
     1234
     1235        /* 通信端点のロックを解除する。*/
     1236        syscall(sig_sem(cep->semid_lock));
     1237
     1238        return error;
     1239        }
     1240
     1241#endif  /* of #ifdef __tcp_cre_cep */
     1242
     1243/*
     1244 *  tcp_del_cep -- TCP 通信端点の削除【拡張機能】
     1245 */
     1246
     1247#ifdef __tcp_del_cep
     1248
     1249ER
     1250tcp_del_cep (ID cepid)
     1251{
     1252        T_TCP_CEP       *cep;
     1253        ER              error;
     1254
     1255        /* TCP 通信端点 ID をチェックする。*/
     1256        if (!VALID_TCP_CEPID(cepid))
     1257                return E_ID;
     1258
     1259        /* TCP 通信端点を得る。*/
     1260        cep = GET_TCP_CEP(cepid);
     1261
     1262        /* TCP 通信端点が、動的生成用でなければエラー */
     1263        if (!DYNAMIC_TCP_CEP(cep))
     1264                return E_ID;
     1265
     1266        /* 通信端点をロックする。*/
     1267        syscall(wai_sem(cep->semid_lock));
     1268
     1269        /*
     1270         * TCP 通信端点をチェックする。以下の場合はエラー
     1271         * ・未生成。
     1272         * ・使用中。
     1273         */
     1274        if (!VALID_TCP_CEP(cep))
     1275                error = E_NOEXS;
     1276        else if (cep->fsm_state != TCP_FSM_CLOSED)
     1277                error = E_OBJ;
     1278        else {
     1279
     1280                /* TCP 通信端点を未生成にする。*/
     1281                cep->flags &= ~TCP_CEP_FLG_VALID;
     1282                error = E_OK;
     1283                }
     1284
     1285        /* 通信端点のロックを解除する。*/
     1286        syscall(sig_sem(cep->semid_lock));
     1287
     1288        return error;
     1289        }
     1290
     1291#endif  /* of #ifdef __tcp_del_cep */
     1292
     1293#ifdef __tcp_snd_oob
     1294
     1295/*
     1296 *  tcp_snd_oob -- 緊急データの送信【拡張機能】
     1297 */
     1298
     1299ER_UINT
     1300tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
     1301{
     1302        T_TCP_CEP       *cep;
     1303        ER_UINT         error;
     1304
     1305#ifdef TCP_CFG_NON_BLOCKING
     1306
     1307        /* data が NULL か、len < 0 ならエラー */
     1308        if (data == NULL || len < 0)
     1309                return E_PAR;
     1310
     1311#else   /* of #ifdef TCP_CFG_NON_BLOCKING */
     1312
     1313        /* data が NULL、len < 0 か、tmout が TMO_NBLK ならエラー */
     1314        if (data == NULL || len < 0 || tmout == TMO_NBLK)
     1315                return E_PAR;
     1316
     1317#endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
     1318
     1319        /*
     1320         *  CEP をロックし、API 機能コードとタスク識別子を記録する。
     1321         *  すでに記録されていれば、ペンディング中なのでエラー
     1322         */
     1323        if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
     1324                return error;
     1325
     1326        /* 送信できるか、通信端点の状態を見る。*/
     1327        if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
     1328                goto err_ret;
     1329
     1330#ifdef TCP_CFG_NON_BLOCKING
     1331
     1332        /* タイムアウトをチェックする。*/
     1333        if (tmout == TMO_NBLK) {                /* ノンブロッキングコール */
     1334
     1335                /* 送信ウィンドバッファに空きがあればコールバック関数を呼び出す。*/
     1336                if (!TCP_IS_SWBUF_FULL(cep)) {
     1337
     1338                        /* 送信ウィンドバッファにデータを書き込む。*/
     1339                        error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
     1340
     1341                        /* 送信緊急ポインタを設定する。*/
     1342                        cep->snd_up = cep->snd_una + cep->swbuf_count;
     1343
     1344                        /* 出力をポストする。*/
     1345                        cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
     1346                        sig_sem(SEM_TCP_POST_OUTPUT);
     1347
     1348                        /* コールバック関数を呼び出す。*/
     1349#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
     1350                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
     1351#else
     1352                        (*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
     1353#endif
     1354                        error = E_WBLK;
     1355                        goto err_ret;
     1356                        }
     1357                else {
     1358                        cep->snd_data     = data;
     1359                        cep->snd_len      = len;
     1360                        cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
     1361                        TCP_ALLOC_SWBUF(cep);
     1362
     1363                        return E_WBLK;
     1364                        }
     1365                }
     1366        else {          /* 非ノンブロッキングコール */
     1367
     1368#endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
     1369
     1370                /* 送信ウィンドバッファが空くのを待つ。*/
     1371                if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
     1372                        goto err_ret;
     1373
     1374                /* 送信ウィンドバッファにデータを書き込む。*/
     1375                if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
     1376
     1377                        /* 送信緊急ポインタを設定する。*/
     1378                        cep->snd_up = cep->snd_una + cep->swbuf_count;
     1379
     1380                        /* データを送信する。送信ウィンドバッファがフルのときは強制的に送信する。*/
     1381                        if (TCP_IS_SWBUF_FULL(cep))
     1382                                cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
     1383
     1384                        /* 出力をポストする。*/
     1385                        cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
     1386                        sig_sem(SEM_TCP_POST_OUTPUT);
     1387                        }
     1388
     1389#ifdef TCP_CFG_NON_BLOCKING
     1390
     1391                }
     1392
     1393#endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
     1394
     1395err_ret:
     1396        cep->snd_tskid = TA_NULL;
     1397        cep->snd_tfn   = TFN_TCP_UNDEF;
     1398        return error;
     1399        }
     1400
     1401#endif  /* of #ifdef __tcp_snd_oob */
     1402
     1403#ifdef __tcp_rcv_oob
     1404
     1405/*
     1406 *  tcp_rcv_oob -- 緊急データの受信【拡張機能】
     1407 *
     1408 *    注意: 送信側が複数オクテットのデータを送信しても、
     1409 *          緊急ポインタが指す 1 オクテットのデータのみ受信する。
     1410 */
     1411
     1412ER_UINT
     1413tcp_rcv_oob (ID cepid, void *data, int_t len)
     1414{
     1415        T_TCP_CEP       *cep;
     1416        uint8_t         *urg;
     1417
     1418        /* TCP 通信端点 ID をチェックする。*/
     1419        if (!VALID_TCP_CEPID(cepid))
     1420                return E_ID;
     1421
     1422        /* data が NULL か、len < 0 ならエラー */
     1423        if (data == NULL || len < 0)
     1424                return E_PAR;
     1425
     1426        /* TCP 通信端点を得る。*/
     1427        cep = GET_TCP_CEP(cepid);
     1428
     1429        /* 受信できるか、通信端点の状態を見る。*/
     1430        /* 受信できるか、fsm_state を見る。*/
     1431        if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
     1432                return E_OBJ;
     1433
     1434        /*
     1435         *  緊急データ入りのセグメントの TCP ヘッダが
     1436         *  設定されていなければ、緊急データを受信していない。
     1437         */
     1438        if (cep->urg_tcph == NULL)
     1439                return E_OBJ;
     1440
     1441        /* len == 0 ならバッファオーバーフロー */
     1442        if (len == 0)
     1443                return E_BOVR;
     1444
     1445        /* 緊急ポインタが指す 1 オクテットのデータを読み取る。*/
     1446        urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
     1447        *(uint8_t*)data = *urg;
     1448
     1449        /* 読み取ったデータから後ろの SDU を前に詰める。*/
     1450        memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
     1451
     1452        /* tcp_rcv_oob() が呼出されたこと知らせるために、NULL を設定する。*/
     1453        cep->urg_tcph = NULL;
     1454
     1455        return 1;
     1456        }
     1457
     1458#endif  /* of #ifdef __tcp_rcv_oob */
     1459
     1460#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
     1461
     1462#ifdef TCP_CFG_EXTENTIONS
     1463
     1464#ifdef __tcp_del_rep
     1465
     1466/*
     1467 *  tcp_del_rep -- TCP 受付口の削除【拡張機能】
     1468 */
     1469
     1470#if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0
     1471
     1472#if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0
     1473
     1474ER
     1475tcp_del_rep (ID repid)
     1476{
     1477
     1478        /*
     1479         *  TCP 受付口 ID をチェックする。
     1480         *  IPv6 用 TCP 受付口であれば、
     1481         *  IPv6 用の「TCP 受付口の削除関数(本体)」を呼出す。
     1482         */
     1483        //NET_DEBUG_TCP3("tcp_del_rep1[r=%d,n=%d,x=%d]\n",
     1484        //               repid, TMIN_TCP6_REPID, tmax_tcp6_repid);
     1485        //NET_DEBUG_TCP3("tcp_del_rep2[r=%d,n=%d,x=%d]\n",
     1486        //               repid, TMIN_TCP4_REPID, tmax_tcp4_repid);
     1487        if (VALID_TCP6_REPID(repid))
     1488                return tcp6_del_rep_body(repid);
     1489
     1490        /*
     1491         *  TCP 受付口 ID をチェックする。
     1492         *  IPv4 用 TCP 受付口であれば、
     1493         *  IPv4 用の「TCP 受付口の削除関数(本体)」を呼出す。
     1494         */
     1495        else if (VALID_TCP4_REPID(repid))
     1496                return tcp4_del_rep_body(repid);
     1497        else
     1498                return E_ID;
     1499
     1500        }
     1501
     1502#else   /* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
     1503
     1504ER
     1505tcp_del_rep (ID repid)
     1506{
     1507
     1508        /* TCP 受付口 ID をチェックする。*/
     1509        if (VALID_TCP6_REPID(repid))
     1510                return tcp6_del_rep_body(repid);
     1511        else
     1512                return E_ID;
     1513
     1514        }
     1515
     1516#endif  /* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
     1517
     1518#else   /* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
     1519
     1520ER
     1521tcp_del_rep (ID repid)
     1522{
     1523
     1524        /* TCP 受付口 ID をチェックする。*/
     1525        if (VALID_TCP4_REPID(repid))
     1526                return tcp4_del_rep_body(repid);
     1527        else
     1528                return E_ID;
     1529
     1530        }
     1531
     1532#endif  /* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
     1533
     1534#endif  /* of #ifdef __tcp_del_rep */
     1535
    19161536/*
    19171537 *  tcp_set_opt -- TCP 通信端点オプションの設定【拡張機能】
     
    19221542#ifdef __tcp_set_opt
    19231543
    1924 #ifdef TCP_CFG_EXTENTIONS
    1925 
    19261544ER
    19271545tcp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
     
    19301548
    19311549        /* TCP 通信端点 ID をチェックする。*/
    1932         if (!VAID_TCP_CEPID(cepid))
     1550        if (!VALID_TCP_CEPID(cepid))
    19331551                return E_ID;
    19341552
     
    19431561        }
    19441562
    1945 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    1946 
    19471563#endif  /* of #ifdef __tcp_set_opt */
    19481564
     
    19551571#ifdef __tcp_get_opt
    19561572
    1957 #ifdef TCP_CFG_EXTENTIONS
    1958 
    19591573ER
    19601574tcp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
     
    19631577
    19641578        /* TCP 通信端点 ID をチェックする。*/
    1965         if (!VAID_TCP_CEPID(cepid))
     1579        if (!VALID_TCP_CEPID(cepid))
    19661580                return E_ID;
    19671581
     
    19761590        }
    19771591
     1592#endif  /* of #ifdef __tcp_get_opt */
     1593
    19781594#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    19791595
    1980 #endif  /* of #ifdef __tcp_get_opt */
    1981 
    19821596#endif  /* of #ifdef SUPPORT_TCP */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h

    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 *
     
    7575 */
    7676
    77 #define IP_TCP_HDR_SIZE                 (IP_HDR_SIZE + TCP_HDR_SIZE)
    78 #define IF_IP_TCP_HDR_SIZE              (IF_IP_HDR_SIZE + TCP_HDR_SIZE)
    79 #define IF_IP_TCP_HDR_OFFSET            (IF_IP_HDR_SIZE)
    80 #define IF_IP_TCP_SDU_OFFSET            (IF_IP_TCP_HDR_SIZE)
    81 
    8277#define GET_TCP_HDR(nbuf,thoff)         ((T_TCP_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
    8378#define GET_TCP_OPT(nbuf,thoff)         ((uint8_t*)((nbuf)->buf) + thoff + TCP_HDR_SIZE)
    84 #define GET_TCP_SDU(nbuf,thoff)         ((uint8_t*)((nbuf)->buf) + thoff + GET_TCP_HDR_SIZE2(nbuf,thoff))
     79#define GET_TCP_SDU(nbuf,thoff)         ((uint8_t*)((nbuf)->buf) + thoff + GET_TCP_HDR_SIZE(nbuf,thoff))
    8580
    8681#define GET_TCP_HDR_OFFSET(nbuf)        (GET_IF_IP_HDR_SIZE(nbuf))
    8782
    88 #define GET_TCP_HDR_SIZE2(nbuf,thoff)   (TCP_HDR_LEN(GET_TCP_HDR(nbuf,thoff)->doff))
    89 #define GET_IP_TCP_HDR_SIZE2(nbuf,thoff) \
    90                                         (GET_IP_HDR_SIZE(GET_IP_HDR(nbuf)) + GET_TCP_HDR_SIZE2(nbuf,thoff))
    91 #define GET_IF_IP_TCP_HDR_SIZE2(nbuf,thoff) \
    92                                         (IF_HDR_SIZE + GET_IP_TCP_HDR_SIZE2(nbuf,thoff))
     83#define GET_TCP_HDR_SIZE(nbuf,thoff)    (TCP_HDR_LEN(GET_TCP_HDR(nbuf,thoff)->doff))
     84
     85#define GET_IP_TCP_HDR_SIZE(nbuf,thoff) (GET_IP_HDR_SIZE(nbuf) + GET_TCP_HDR_SIZE(nbuf,thoff))
     86#define GET_IF_IP_TCP_HDR_SIZE(nbuf,thoff) \
     87                                        (IF_HDR_SIZE + GET_IP_TCP_HDR_SIZE(nbuf,thoff))
     88#define IF_IP_TCP_HDR_SIZE(nbuf)        (IF_IP_HDR_SIZE(nbuf) + TCP_HDR_SIZE)
     89#define IF_IP_TCP_HDR_OFFSET(nbuf)      (IF_IP_HDR_SIZE(nbuf))
     90#define IF_IP_TCP_NET_HDR_SIZE(addr)    (IF_IP_NET_HDR_SIZE(addr) + TCP_HDR_SIZE)
     91#define IF_IP_TCP_NET_HDR_OFFSET(addr)  (IF_IP_NET_HDR_SIZE(addr))
    9392
    9493/*
     
    9695 */
    9796
    98 #if defined(SUPPORT_INET4)
     97#if !defined(_IP6_CFG) && defined(_IP4_CFG)
    9998
    10099#define IP4_TCP_HDR_SIZE                IP_TCP_HDR_SIZE
    101100#define IF_IP4_TCP_HDR_SIZE             IF_IP_TCP_HDR_SIZE
    102 #define GET_IP4_TCP_HDR_SIZE(nbuf)      GET_IP_TCP_HDR_SIZE(nbuf)       
    103 #define GET_IF_IP4_TCP_HDR_SIZE(nbuf)   GET_IF_IP_TCP_HDR_SIZE(nbuf)   
    104 
    105 #endif  /* of #if defined(SUPPORT_INET4) */
     101#define GET_IP4_TCP_HDR_SIZE(nbuf)      GET_IP_TCP_HDR_SIZE1(nbuf)     
     102#define GET_IF_IP4_TCP_HDR_SIZE(nbuf)   GET_IF_IP_TCP_HDR_SIZE1(nbuf)   
     103
     104#endif  /* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
    106105
    107106/*
     
    110109
    111110#define TMIN_TCP_CREPID                 TMIN_TCP_REPID
     111#define TNUM_TCP_CREPID                 TNUM_TCP_REPID
     112
    112113#define TMIN_TCP_CCEPID                 TMIN_TCP_CEPID
    113 #define TNUM_TCP_CREPID                 TNUM_TCP_REPID
    114114#define TNUM_TCP_CCEPID                 TNUM_TCP_CEPID
    115115
     
    121121
    122122/*
     123 * TCP で使用する変数の型の定義
     124 */
     125
     126typedef uint32_t T_TCP_SEQ;
     127typedef uint16_t T_TCP_SEG;
     128typedef uint16_t T_TCP_WND;
     129typedef int16_t T_TCP_TIME;
     130
     131/*
     132 *  TCP タイマ変数
     133 */
     134
     135#define NUM_TCP_TIMERS          4       /* TCP のタイマ数    */
     136
     137/*
    123138 *  TCP 受付口
    124139 */
    125140
     141/* IPv6 用 TCP 受付口 */
     142
     143typedef struct t_tcp6_rep {
     144
     145        /*
     146         * ITRON TCP/IP API、TCP 受付口と同じメンバ
     147         */
     148        ATR             repatr;         /* 受付口属性                */
     149        T_IPV6EP        myaddr;         /* 自分のアドレス      */
     150
     151#ifdef TCP_CFG_EXTENTIONS
     152        uint16_t        flags;          /* 受付口フラグ               */
     153        ID              semid_lock;     /* 受付口ロック               */
     154#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
     155
     156        } T_TCP6_REP;
     157
    126158/* IPv4 用 TCP 受付口 */
     159
    127160typedef struct t_tcp4_rep {
    128161
     
    140173        } T_TCP4_REP;
    141174
    142 /* IPv6 用 TCP 受付口 */
    143 typedef struct t_tcp6_rep {
    144 
    145         /*
    146          * ITRON TCP/IP API、TCP 受付口と同じメンバ
    147          */
    148         ATR             repatr;         /* 受付口属性                */
    149         T_IPV6EP        myaddr;         /* 自分のアドレス      */
    150 
    151 #ifdef TCP_CFG_EXTENTIONS
    152         uint16_t        flags;          /* 受付口フラグ               */
    153         ID              semid_lock;     /* 受付口ロック               */
    154 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    155 
    156         } T_TCP6_REP;
    157 
    158 #if defined(SUPPORT_INET4)
     175#if defined(_IP6_CFG)
     176
     177#define T_TCP_REP       T_TCP6_REP
     178
     179#else   /* of #if defined(_IP6_CFG) */
     180
     181#if defined(_IP4_CFG)
     182
    159183#define T_TCP_REP       T_TCP4_REP
    160 #endif
    161 
    162 #if defined(SUPPORT_INET6)
    163 #define T_TCP_REP       T_TCP6_REP
    164 #endif
     184
     185#endif  /* of #if defined(_IP4_CFG) */
     186
     187#endif  /* of #if defined(_IP6_CFG) */
     188
     189#define T_TCP_REP_DEFINED
    165190
    166191/*
     
    175200 */
    176201
    177 typedef uint32_t T_TCP_SEQ;
    178 typedef uint16_t T_TCP_SEG;
    179 typedef uint16_t T_TCP_WND;
    180 
    181 /*
    182  * 通常の IPv4 TCP 通信端点
    183  */
    184 typedef struct t_tcp4_cep {
     202#ifndef T_NET_BUF_DEFINED
     203
     204typedef struct t_net_buf T_NET_BUF;
     205
     206#define T_NET_BUF_DEFINED
     207
     208#endif  /* of #ifndef T_NET_BUF_DEFINED */
     209
     210typedef struct t_tcp_cep {
    185211
    186212        /*
     
    232258#ifdef TCP_CFG_NON_BLOCKING
    233259
    234         T_IPV4EP        *p_dstaddr;     /* 相手のアドレスへのポインタ        */
    235         T_IPV4EP        *p_myaddr;      /* 自分のアドレスへのポインタ        */
     260        T_IPEP          *p_dstaddr;     /* 相手のアドレスへのポインタ        */
     261        T_IPEP          *p_myaddr;      /* 自分のアドレスへのポインタ        */
     262
     263#if defined(_IP6_CFG) && defined(_IP4_CFG)
     264        T_IPV4EP        *p_dstaddr4;    /* 相手のアドレスへのポインタ        */
     265        T_IPV4EP        *p_myaddr4;     /* 自分のアドレスへのポインタ        */
     266#endif
     267       
    236268        int16_t         snd_nblk_tfn;   /* 送信動作中の API 機能コード     */
    237269        int16_t         rcv_nblk_tfn;   /* 受信動作中の API 機能コード     */
     
    247279#ifdef TCP_CFG_SWBUF_CSAVE
    248280        T_NET_BUF       *swbufq;        /* 送信ウィンドバッファキュー        */
    249 #endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
     281#endif
    250282
    251283        /*
     
    254286
    255287        T_TCP_TIME      timer[NUM_TCP_TIMERS];  /* TCP のタイマ             */
    256         T_IPV4EP        dstaddr;        /* 相手のアドレス              */
    257         T_IPV4EP        myaddr;         /* 自分のアドレス              */
    258         T_TCP4_REP      *rep;           /* 受付口                  */
     288        T_IPEP          dstaddr;        /* 相手のアドレス              */
     289        T_IPEP          myaddr;         /* 自分のアドレス              */
    259290        T_NET_BUF       *reassq;        /* 受信再構成キュー             */
     291
     292#if defined(_IP6_CFG)
     293
     294#if defined(_IP4_CFG)
     295
     296        T_TCP4_REP      *rep4;          /* IPv4 用受付口            */
     297
     298#endif  /* of #if defined(_IP4_CFG) */
     299
     300        T_TCP6_REP      *rep;           /* IPv6 用受付口            */
     301
     302#else   /* of #if defined(_IP6_CFG) */
     303
     304#if defined(_IP4_CFG)
     305
     306        T_TCP4_REP      *rep;           /* IPv4 用受付口            */
     307
     308#endif  /* of #if defined(_IP4_CFG) */
     309
     310#endif  /* of #if defined(_IP6_CFG) */
     311
    260312
    261313#ifdef TCP_CFG_RWBUF_CSAVE
    262314        T_NET_BUF       *rwbufq;        /* 受信ウィンドバッファキュー        */
    263 #endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE */
     315#endif
    264316
    265317#ifdef TCP_CFG_EXTENTIONS
     
    298350
    299351#if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
    300         uint8_t         rwbufq_entries; /* 受信ウィンドバッファキューのエントリ数  */
    301 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)       */
    302 
    303         } T_TCP4_CEP;
    304 
    305 /*
    306  * Time Wait 用 IPv4 TCP 通信端点
    307  */
    308 typedef struct t_tcp4_twcep {
     352        uint16_t        rwbufq_entries; /* 受信ウィンドバッファキューのエントリ数  */
     353#endif
     354
     355        } T_TCP_CEP;
     356
     357#define T_TCP6_CEP      T_TCP_CEP
     358#define T_TCP4_CEP      T_TCP_CEP
     359
     360/*
     361 * Time Wait 用 TCP 通信端点
     362 */
     363
     364typedef struct t_tcp_twcep {
    309365        int_t           rbufsz;         /* 受信用ウィンドバッファサイズ       */
    310366        T_TCP_TIME      timer_2msl;     /* 2MSL タイマ                     */
    311         T_IPV4EP        dstaddr;        /* 相手のアドレス              */
    312         T_IPV4EP        myaddr;         /* 自分のアドレス              */
     367        T_IPEP          dstaddr;        /* 相手のアドレス              */
     368        T_IPEP          myaddr;         /* 自分のアドレス              */
    313369        T_TCP_SEQ       snd_una;        /* 未確認の最小送信 SEQ つまり     */
    314370                                        /* 確認された最大送信 SEQ        */
     
    316372        uint16_t        rwbuf_count;    /* 受信ウィンドバッファの使用中サイズ    */
    317373        uint8_t         fsm_state;      /* FSM 状態                       */
    318 
    319         } T_TCP4_TWCEP;
    320 
    321 /*
    322  * 通常の IPv6 TCP 通信端点
    323  */
    324 typedef struct t_tcp6_cep {
    325 
    326         /*
    327          * ITRON TCP/IP API、TCP 通信端点と同じメンバ
    328          */
    329         ATR             cepatr;         /* 通信端点属性                       */
    330         void            *sbuf;          /* 送信用ウィンドバッファ  */
    331         int_t           sbufsz;         /* 送信用ウィンドバッファサイズ       */
    332         void            *rbuf;          /* 受信用ウィンドバッファ  */
    333         int_t           rbufsz;         /* 受信用ウィンドバッファサイズ       */
    334         t_tcp_callback  callback;       /* コールバック関数             */
    335 
    336         /*
    337          * TINET 独自のメンバ
    338          */
    339         uint32_t        flags;          /* 通信端点フラグ              */
    340         ID              semid_lock;     /* 通信端点ロック              */
    341         ID              est_flgid;      /* コネクション状態イベントフラグ      */
    342         ID              snd_flgid;      /* 送信イベントフラグ            */
    343         ID              rcv_flgid;      /* 受信イベントフラグ            */
    344         ID              snd_tskid;      /* 送信タスク識別子             */
    345         ID              rcv_tskid;      /* 受信タスク識別子             */
    346         uint8_t         *sbuf_rptr;     /* 送信用読み出しポインタ          */
    347         uint8_t         *sbuf_wptr;     /* 送信用書き込みポインタ          */
    348         uint8_t         *rbuf_rptr;     /* 受信用読み出しポインタ          */
    349         uint8_t         *rbuf_wptr;     /* 受信用書き込みポインタ          */
    350         T_TCP_SEQ       snd_ssthresh;   /* 輻輳ウィンドサイズ(snd_cwnd)  */
    351                                         /* のしきい値                        */
    352         T_TCP_TIME      rxtcur;         /* 現在の再送タイムアウト          */
    353         T_TCP_TIME      srtt;           /* 平滑化された RTT           */
    354         T_TCP_TIME      rttvar;         /* 平滑化された分散             */
    355         T_TCP_WND       snd_cwnd;       /* 輻輳ウィンドサイズ            */
    356 
    357         /*
    358          *  相手の最大受信セグメントサイズ     
    359          *
    360          *    オリジナルでは、一般のセグメントの最大サイズ (t_maxseg) と、
    361          *    オプション付きのセグメントの最大サイズ (t_maxopd) が別に
    362          *    なっている。これは、現在のインターネットでは、オプション付きの
    363          *    セグメントのほうが多いからと説明されているためである。
    364          *    本実装では、最大セグメントサイズオプション以外のオプションは
    365          *    実装しないので、t_maxseg の使用する。
    366          */
    367         T_TCP_SEG       maxseg;
    368 
    369         T_IPV6EP        *p_dstaddr;     /* 相手のアドレスへのポインタ        */
    370         T_IPV6EP        *p_myaddr;      /* 自分のアドレスへのポインタ        */
    371         int16_t         snd_tfn;        /* 送信動作中の API 機能コード     */
    372         int16_t         rcv_tfn;        /* 受信動作中の API 機能コード     */
    373 
    374 #ifdef TCP_CFG_NON_BLOCKING
    375 
    376         int16_t         snd_nblk_tfn;   /* 送信動作中の API 機能コード     */
    377         int16_t         rcv_nblk_tfn;   /* 受信動作中の API 機能コード     */
    378         void            *snd_data;      /* 送信データ領域の先頭アドレス       */
    379         int_t           snd_len;        /* 送信データ領域の長さ           */
    380         void            *rcv_data;      /* 受信データ領域の先頭アドレス       */
    381         int_t           rcv_len;        /* 受信データ領域の長さ           */
    382         void            **snd_p_buf;    /* 送信バッファへのポインタ */
    383         void            **rcv_p_buf;    /* 受信バッファへのポインタ */
    384 
    385 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING */
    386 
    387 #ifdef TCP_CFG_SWBUF_CSAVE
    388         T_NET_BUF       *swbufq;        /* 送信ウィンドバッファキュー        */
    389 #endif  /* of #ifdef TCP_CFG_SWBUF_CSAVE */
    390 
    391         /*
    392          *  これ以降のメンバーは tcp_init_cep() 関数でゼロクリアーされる。
    393          */
    394 
    395         T_TCP_TIME      timer[NUM_TCP_TIMERS];  /* TCP のタイマ             */
    396         T_IPV6EP        dstaddr;        /* 相手のアドレス              */
    397         T_IPV6EP        myaddr;         /* 自分のアドレス              */
    398         T_TCP6_REP      *rep;           /* 受付口                  */
    399         T_NET_BUF       *reassq;        /* 受信再構成キュー             */
    400 
    401 #ifdef TCP_CFG_RWBUF_CSAVE
    402         T_NET_BUF       *rwbufq;        /* 受信ウィンドバッファキュー        */
    403 #endif  /* of #ifdef TCP_CFG_RWBUF_CSAVE */
    404 
    405 #ifdef TCP_CFG_EXTENTIONS
    406         T_TCP_HDR       *urg_tcph;      /* 緊急データ入りのセグメントの TCP ヘッダ       */
    407         T_TCP_SEQ       snd_up;         /* 送信した緊急ポインタ           */
    408         T_TCP_SEQ       rcv_up;         /* 受信した緊急ポインタ           */
    409 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    410 
    411         T_TCP_SEQ       snd_una;        /* 未確認の最小送信 SEQ つまり     */
    412                                         /* 確認された最大送信 SEQ        */
    413         T_TCP_SEQ       snd_max;        /* 送信した最大 SEQ           */
    414         T_TCP_SEQ       snd_nxt;        /* 次に送信する SEQ           */
    415         T_TCP_SEQ       snd_old_nxt;    /* 元の snd_nxt                   */
    416         T_TCP_SEQ       snd_wl1;        /* 前回ウィンドを更新した SEQ      */
    417         T_TCP_SEQ       snd_wl2;        /* 前回ウィンドを更新した ACK      */
    418         T_TCP_SEQ       iss;            /* 自分の SEQ の初期値         */
    419         T_TCP_SEQ       irs;            /* 相手の SEQ の初期値         */
    420         T_TCP_SEQ       rcv_nxt;        /* 受信を期待している最小の SEQ     */
    421         T_TCP_SEQ       rcv_adv;        /* 受信を期待している最大の SEQ     */
    422         T_TCP_SEQ       rcv_wnd;        /* 受信可能なウィンドサイズ */
    423         T_TCP_SEQ       rtseq;          /* 時間計測を始めた SEQ         */
    424         T_TCP_SEQ       last_ack_sent;  /* 最後に送信した ACK          */
    425         T_TCP_TIME      idle;           /* アイドル時間                       */
    426         ER              error;          /* 非同期に発生したエラー          */
    427         ER              net_error;      /* ネットワークのエラー状態 */
    428         T_TCP_WND       snd_wnd;        /* 相手の受信可能ウィンドサイズ       */
    429         T_TCP_WND       max_sndwnd;     /* 今までの最大送信ウィンドサイズ      */
    430         T_TCP_TIME      rtt;            /* 往復時間                 */
    431         uint16_t        swbuf_count;    /* 送信ウィンドバッファの使用中サイズ    */
    432         uint16_t        rwbuf_count;    /* 受信ウィンドバッファの使用中サイズ    */
    433         uint16_t        rcv_buf_len;    /* tcp_rcv_buf の割当て長    */
    434         uint16_t        get_buf_len;    /* tcp_rcv_buf の割当て長    */
    435         uint8_t         rxtshift;       /* 再送信回数の log(2)                */
    436         uint8_t         fsm_state;      /* FSM 状態                       */
    437         uint8_t         dupacks;        /* 再送 ACK 数                     */
    438 
    439 #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
    440         uint8_t         rwbufq_entries; /* 受信ウィンドバッファキューのエントリ数  */
    441 #endif  /* of #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)       */
    442 
    443         } T_TCP6_CEP;
    444 
    445 /*
    446  * Time Wait 用 IPv6 TCP 通信端点
    447  */
    448 typedef struct t_tcp6_twcep {
    449         int_t           rbufsz;         /* 受信用ウィンドバッファサイズ       */
    450         T_TCP_TIME      timer_2msl;     /* 2MSL タイマ                     */
    451         T_IPV6EP        dstaddr;        /* 相手のアドレス              */
    452         T_IPV6EP        myaddr;         /* 自分のアドレス              */
    453         T_TCP_SEQ       snd_una;        /* 未確認の最小送信 SEQ つまり     */
    454                                         /* 確認された最大送信 SEQ        */
    455         T_TCP_SEQ       iss;            /* 自分の SEQ の初期値         */
    456         T_TCP_SEQ       irs;            /* 相手の SEQ の初期値         */
    457         T_TCP_SEQ       rcv_nxt;        /* 受信を期待している最小の SEQ     */
    458         T_TCP_WND       snd_wnd;        /* 相手の受信可能ウィンドサイズ       */
    459         uint16_t        rwbuf_count;    /* 受信ウィンドバッファの使用中サイズ    */
    460         uint8_t         fsm_state;      /* FSM 状態                       */
    461 
    462         } T_TCP6_TWCEP;
    463 
    464 #if defined(SUPPORT_INET4)
    465 #define T_TCP_CEP       T_TCP4_CEP
    466 #define T_TCP_TWCEP     T_TCP4_TWCEP
    467 #endif  /* of #if defined(SUPPORT_INET4) */
    468 
    469 #if defined(SUPPORT_INET6)
    470 #define T_TCP_CEP       T_TCP6_CEP
    471 #define T_TCP_TWCEP     T_TCP6_TWCEP
    472 #endif  /* of #if defined(SUPPORT_INET6) */
     374        uint8_t flags;                  /* 通信端点フラグ              */
     375
     376        } T_TCP_TWCEP;
    473377
    474378#define T_TCP_CEP_DEFINED
     
    478382 */
    479383
    480 #define TCP_CEP_FLG_ACK_NOW             ULONG_C(0x00000001)     /* 直ちに相手に ACK を送る。      */
    481 #define TCP_CEP_FLG_DEL_ACK             ULONG_C(0x00000002)     /* ACK を遅延する。           */
    482 #define TCP_CEP_FLG_SENT_FIN            ULONG_C(0x00000004)     /* FIN を送ってある。          */
    483 #define TCP_CEP_FLG_NEED_SYN            ULONG_C(0x00000008)     /* SYN を送信する。           */
    484 #define TCP_CEP_FLG_NEED_FIN            ULONG_C(0x00000010)     /* FIN を送信する。           */
    485 #define TCP_CEP_FLG_FORCE               ULONG_C(0x00000020)     /* 強制送信。                        */
    486 #define TCP_CEP_FLG_NO_PUSH             ULONG_C(0x00000040)     /* push しない。            */
    487 #define TCP_CEP_FLG_NO_DELAY            ULONG_C(0x00000080)     /* 遅延しない。                       */
    488 #define TCP_CEP_FLG_FORCE_CLEAR         ULONG_C(0x00000100)     /* 強制送信した後フラグをクリアーする。*/
    489 #define TCP_CEP_FLG_POST_OUTPUT         ULONG_C(0x00000200)     /* 送信を開始する。             */
    490 #define TCP_CEP_FLG_RESERVE_OUTPUT      ULONG_C(0x00000400)     /* 送信を予約する。             */
    491 #define TCP_CEP_FLG_DYNAMIC             ULONG_C(0x00001000)     /* 動的生成・削除可能通信端点。       */
    492 #define TCP_CEP_FLG_VALID               ULONG_C(0x00002000)     /* 生成済みで有効な通信端点。        */
    493 #define TCP_CEP_FLG_CLOSE_AFTER_OUTPUT  ULONG_C(0x00004000)     /* 送信した後コネクションを閉じる。*/
    494 #define TCP_CEP_FLG_RESTORE_NEXT_OUTPUT ULONG_C(0x00008000)     /* 送信した後、snd_nxt を元に戻す。*/
     384#define TCP_CEP_FLG_IPV4                ULONG_C(0x00000001)     /* IPv4 用。                      */
     385#define TCP_CEP_FLG_ACK_NOW             ULONG_C(0x00000100)     /* 直ちに相手に ACK を送る。      */
     386#define TCP_CEP_FLG_DEL_ACK             ULONG_C(0x00000200)     /* ACK を遅延する。           */
     387#define TCP_CEP_FLG_SENT_FIN            ULONG_C(0x00000400)     /* FIN を送ってある。          */
     388#define TCP_CEP_FLG_NEED_SYN            ULONG_C(0x00000800)     /* SYN を送信する。           */
     389#define TCP_CEP_FLG_NEED_FIN            ULONG_C(0x00001000)     /* FIN を送信する。           */
     390#define TCP_CEP_FLG_FORCE               ULONG_C(0x00002000)     /* 強制送信。                        */
     391#define TCP_CEP_FLG_NO_PUSH             ULONG_C(0x00004000)     /* push しない。            */
     392#define TCP_CEP_FLG_NO_DELAY            ULONG_C(0x00008000)     /* 遅延しない。                       */
     393#define TCP_CEP_FLG_FORCE_CLEAR         ULONG_C(0x00010000)     /* 強制送信した後フラグをクリアーする。*/
     394#define TCP_CEP_FLG_POST_OUTPUT         ULONG_C(0x00020000)     /* 送信を開始する。             */
     395#define TCP_CEP_FLG_RESERVE_OUTPUT      ULONG_C(0x00040000)     /* 送信を予約する。             */
     396#define TCP_CEP_FLG_DYNAMIC             ULONG_C(0x00100000)     /* 動的生成・削除可能通信端点。       */
     397#define TCP_CEP_FLG_VALID               ULONG_C(0x00200000)     /* 生成済みで有効な通信端点。        */
     398#define TCP_CEP_FLG_CLOSE_AFTER_OUTPUT  ULONG_C(0x00400000)     /* 送信した後コネクションを閉じる。*/
     399#define TCP_CEP_FLG_RESTORE_NEXT_OUTPUT ULONG_C(0x00800000)     /* 送信した後、snd_nxt を元に戻す。*/
    495400
    496401/* 送受信ウィンドバッファの省コピー機能 */
    497 #define TCP_CEP_FLG_WBCS_NBUF_REQ       ULONG_C(0x00080000)     /* ネットワークバッファ割当て要求      */
    498 #define TCP_CEP_FLG_WBCS_MASK           ULONG_C(0x00070000)     /* マスク                  */
     402#define TCP_CEP_FLG_WBCS_NBUF_REQ       ULONG_C(0x80000000)     /* ネットワークバッファ割当て要求*/
     403#define TCP_CEP_FLG_WBCS_MASK           ULONG_C(0x70000000)     /* マスク                  */
    499404#define TCP_CEP_FLG_WBCS_FREE           ULONG_C(0x00000000)     /* 送信ウィンドバッファ未使用        */
    500 #define TCP_CEP_FLG_WBCS_WOPEN_PEND     ULONG_C(0x00010000)     /* 相手の受信ウィンドの開き待ち       */
    501 #define TCP_CEP_FLG_WBCS_NBUF_PEND      ULONG_C(0x00020000)     /* ネットワークバッファ予約待ち       */
    502 #define TCP_CEP_FLG_WBCS_NBUF_RSVD      ULONG_C(0x00030000)     /* ネットワークバッファ予約済み       */
    503 #define TCP_CEP_FLG_WBCS_NBUF_READY     ULONG_C(0x00040000)     /* ネットワークバッファ割当て済み      */
    504 #define TCP_CEP_FLG_WBCS_SEND_READY     ULONG_C(0x00050000)     /* 送信可能                 */
    505 #define TCP_CEP_FLG_WBCS_SENT           ULONG_C(0x00060000)     /* 送信済みで、ACK待ち          */
    506 #define TCP_CEP_FLG_WBCS_ACKED          ULONG_C(0x00070000)     /* 送信済みで、ACK完了          */
     405#define TCP_CEP_FLG_WBCS_WOPEN_PEND     ULONG_C(0x10000000)     /* 相手の受信ウィンドの開き待ち       */
     406#define TCP_CEP_FLG_WBCS_NBUF_PEND      ULONG_C(0x20000000)     /* ネットワークバッファ予約待ち       */
     407#define TCP_CEP_FLG_WBCS_NBUF_RSVD      ULONG_C(0x30000000)     /* ネットワークバッファ予約済み       */
     408#define TCP_CEP_FLG_WBCS_NBUF_READY     ULONG_C(0x40000000)     /* ネットワークバッファ割当て済み*/
     409#define TCP_CEP_FLG_WBCS_SEND_READY     ULONG_C(0x50000000)     /* 送信可能                 */
     410#define TCP_CEP_FLG_WBCS_SENT           ULONG_C(0x60000000)     /* 送信済みで、ACK待ち          */
     411#define TCP_CEP_FLG_WBCS_ACKED          ULONG_C(0x70000000)     /* 送信済みで、ACK完了          */
     412
     413/* 初期化から除外するフラグの定義 */
     414#define TCP_CEP_FLG_NOT_CLEAR           (TCP_CEP_FLG_WBCS_NBUF_REQ|TCP_CEP_FLG_WBCS_MASK|\
     415                                         TCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4)
    507416
    508417/*
     
    513422#define TCP_CEP_EVT_CLOSED              ULONG_C(0x00000002)     /* 未使用状態                        */
    514423#define TCP_CEP_EVT_SWBUF_READY         ULONG_C(0x00000004)     /* 送信ウィンドバッファ空き */
    515 #define TCP_CEP_EVT_RWBUF_READY         ULONG_C(0x00000008)     /* 送信ウィンドバッファデータあり      */
     424#define TCP_CEP_EVT_RWBUF_READY         ULONG_C(0x00000008)     /* 送信ウィンドバッファデータあり*/
    516425#define TCP_CEP_EVT_ALL                 ULONG_C(0xffffffff)     /* 全イベント                        */
    517426
     
    571480
    572481#define GET_TCP_Q_HDR(nbuf,thoff)       ((T_TCP_Q_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
    573 #define GET_TCP_IP_Q_HDR(nbuf)          ((T_TCP_IP_Q_HDR*)GET_IP_HDR(nbuf))
    574482
    575483/*
     
    577485 */
    578486
    579 #define TMIN_TCP_REPID          1       /* TCP 受付口   ID の最小値                    */
    580 #define TMIN_TCP_CEPID          1       /* TCP 通信端点 ID の最小値                     */
    581 #define TMIN_TCP_TWCEPID        1       /* Time Wait 用 TCP 通信端点 ID の最小値 */
     487#define TMIN_TCP_REPID          1                       /* TCP      受付口 ID の最小値                 */
     488#define TMIN_TCP6_REPID         1                       /* TCP/IPv6 受付口 ID の最小値                 */
     489#define TMIN_TCP4_REPID         (TNUM_TCP6_REPID+1)     /* TCP/IPv4 受付口 ID の最小値                 */
     490
     491#define TMIN_TCP_CEPID          1                       /* TCP      通信端点 ID の最小値                        */
     492#define TMIN_TCP6_CEPID         1                       /* TCP/IPv6 通信端点 ID の最小値                        */
     493#define TMIN_TCP4_CEPID         (TNUM_TCP6_CEPID+1)     /* TCP/IPv4 通信端点 ID の最小値                        */
     494
     495#define TMIN_TCP_TWCEPID        1                       /* Time Wait 用 TCP 通信端点 ID の最小値 */
    582496
    583497/*
    584498 *  制御セグメント(データなし)サイズのネットワークバッファ
    585499 */
     500
     501#if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE)
    586502
    587503typedef struct t_net_buf_cseg {
     
    599515        } T_NET_BUF_CSEG;
    600516
    601 #ifdef SUPPORT_MIB
     517#endif  /* of #if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE) */
    602518
    603519/*
     
    618534} T_TCP_STATS;
    619535
    620 #endif  /* of #ifdef SUPPORT_MIB */
    621 
    622536/*
    623537 *  関数シミュレーションマクロ
    624538 */
    625539
    626 #define VAID_TCP_REPID(id)      (TMIN_TCP_REPID<=(id)&&(id)<=tmax_tcp_repid)
    627 #define VAID_TCP_CEPID(id)      (TMIN_TCP_CEPID<=(id)&&(id)<=tmax_tcp_cepid)
    628 
    629 #define INDEX_TCP_REP(id)       ((id)-TMIN_TCP_REPID)
     540/* TCP 受付口 */
     541
     542#define VALID_TCP6_REPID(id)    (TMIN_TCP6_REPID<=(id)&&(id)<=tmax_tcp6_repid)
     543#define VALID_TCP4_REPID(id)    (TMIN_TCP4_REPID<=(id)&&(id)<=tmax_tcp4_repid)
     544
     545#define INDEX_TCP6_REP(id)      ((id)-TMIN_TCP6_REPID)
     546#define INDEX_TCP4_REP(id)      ((id)-TMIN_TCP4_REPID)
     547
     548#define GET_TCP6_REP(id)        (&(tcp6_rep[INDEX_TCP6_REP(id)]))
     549#define GET_TCP4_REP(id)        (&(tcp4_rep[INDEX_TCP4_REP(id)]))
     550
     551#define GET_TCP6_REPID(rep)     ((ID)(((rep)-tcp6_rep)+TMIN_TCP6_REPID))
     552#define GET_TCP4_REPID(rep)     ((ID)(((rep)-tcp4_rep)+TMIN_TCP4_REPID))
     553
     554#ifdef TCP_CFG_EXTENTIONS
     555
     556#define VALID_TCP_REP(rep)      (((rep)->flags&TCP_REP_FLG_VALID)!=0)
     557#define DYNAMIC_TCP_REP(rep)    (((rep)->flags&TCP_REP_FLG_DYNAMIC)!=0)
     558
     559#else   /* of #ifdef TCP_CFG_EXTENTIONS */
     560
     561#define VALID_TCP_REP(rep)      (true)
     562#define DYNAMIC_TCP_REP(rep)    (false)
     563
     564#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
     565
     566/* TCP 通信端点 */
     567
     568#define VALID_TCP_CEPID(id)     (TMIN_TCP_CEPID<=(id)&&(id)<=tmax_tcp_cepid)
    630569#define INDEX_TCP_CEP(id)       ((id)-TMIN_TCP_CEPID)
    631570
    632 #define GET_TCP_REP(id)         (&(tcp_rep[INDEX_TCP_REP(id)]))
    633571#define GET_TCP_CEP(id)         (&(tcp_cep[INDEX_TCP_CEP(id)]))
    634572
    635 #define GET_TCP_REPID(rep)      ((ID)(((rep)-tcp_rep)+TMIN_TCP_REPID))
    636573#define GET_TCP_CEPID(cep)      ((ID)(((cep)-tcp_cep)+TMIN_TCP_CEPID))
    637574#define GET_TCP_TWCEPID(cep)    ((ID)(((cep)-tcp_twcep)+TMIN_TCP_TWCEPID))
     575
     576#define VALID_TCP_CEP(cep)      (((cep)->flags&TCP_CEP_FLG_VALID)!=0)
     577#define DYNAMIC_TCP_CEP(cep)    (((cep)->flags&TCP_CEP_FLG_DYNAMIC)!=0)
     578#define TCP_IS_CEP_IPV6(cep)    (((cep)->flags&TCP_CEP_FLG_IPV4)==0)
     579#define TCP_IS_CEP_IPV4(cep)    (((cep)->flags&TCP_CEP_FLG_IPV4)!=0)
    638580
    639581#define IS_TFN_TCP_RCV(t)       ((t)==TFN_TCP_ACP_CEP||(t)==TFN_TCP_RCV_DAT||\
     
    651593#define VALID_URG_POINTER(urg)  (TCP_CFG_URG_OFFSET==0||urg!=0)
    652594
    653 #define VALID_TCP_CEP(cep)      (((cep)->flags&TCP_CEP_FLG_VALID)!=0)
    654 #define DYNAMIC_TCP_CEP(cep)    (((cep)->flags&TCP_CEP_FLG_DYNAMIC)!=0)
    655 
    656 #ifdef TCP_CFG_EXTENTIONS
    657 
    658 #define VALID_TCP_REP(rep)      (((rep)->flags&TCP_REP_FLG_VALID)!=0)
    659 #define DYNAMIC_TCP_REP(rep)    (((rep)->flags&TCP_REP_FLG_DYNAMIC)!=0)
    660 
    661 #else   /* of #ifdef TCP_CFG_EXTENTIONS */
    662 
    663 #define VALID_TCP_REP(rep)      (true)
    664 #define DYNAMIC_TCP_REP(rep)    (false)
    665 
    666 #endif  /* of #ifdef TCP_CFG_EXTENTIONS */
    667 
    668595/*
    669596 *  全域変数
    670597 */
    671598
    672 extern T_TCP_REP tcp_rep[];
     599extern uint8_t tcp_initialized;
     600
     601extern T_TCP_STATS tcp_stats;
     602
     603/* TCP 受付口 */
     604
     605extern T_TCP6_REP tcp6_rep[];
     606extern T_TCP4_REP tcp4_rep[];
     607
     608#if defined(SUPPORT_INET6)
     609#define tcp_rep tcp6_rep
     610#elif defined(SUPPORT_INET4)
     611#define tcp_rep tcp4_rep
     612#endif
     613
     614extern const ID tmax_tcp_repid;
     615
     616#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     617extern const ID tmax_tcp6_repid;
     618extern const ID tmax_tcp4_repid;
     619#else
     620#define tmax_tcp6_repid tmax_tcp_repid
     621#define tmax_tcp4_repid tmax_tcp_repid
     622#endif
     623
     624/* TCP 通信端点 */
     625
    673626extern T_TCP_CEP tcp_cep[];
    674 extern uint8_t tcp_initialized;
    675 extern const ID tmax_tcp_repid;
     627extern T_TCP_TWCEP tcp_twcep[];
     628
    676629extern const ID tmax_tcp_cepid;
    677 extern T_TCP_TWCEP tcp_twcep[];
    678 
    679 #ifdef SUPPORT_MIB
    680 
    681 extern T_TCP_STATS tcp_stats;
    682 
    683 #endif  /* of #ifdef SUPPORT_MIB */
     630
     631#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     632extern const ID tmax_tcp6_cepid;
     633extern const ID tmax_tcp4_cepid;
     634#else
     635#define tmax_tcp6_cepid tmax_tcp_cepid
     636#define tmax_tcp4_cepid tmax_tcp_cepid
     637#endif
    684638
    685639/*
     
    866820extern void tcp_respond (T_NET_BUF *nbuf, T_TCP_CEP *cep,
    867821                         T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags);
    868 extern void tcp_set_header (T_NET_BUF *nbuf, T_TCP_CEP *cep, uint_t thoff, uint_t optlen);
    869822extern ER tcp_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
    870823                           uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
     824extern ER tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
     825                            uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
    871826extern void tcp_init_cep (T_TCP_CEP *cep);
    872827extern void tcp_notify (T_NET_BUF *input, int code);
     
    876831extern void tcp_alloc_auto_port (T_TCP_CEP *cep);
    877832extern ER tcp_alloc_port (T_TCP_CEP *cep, uint16_t portno);
    878 extern void tcp_move_twcep (T_TCP_CEP *cep);
    879833extern ER tcp_lock_cep (ID cepid, T_TCP_CEP **p_cep, FN tfn);
    880834extern void tcp_free_reassq (T_TCP_CEP *cep);
     
    885839extern ER tcp_wait_rwbuf (T_TCP_CEP *cep, TMO tmout);
    886840extern T_TCP_CEP *tcp_user_closed (T_TCP_CEP *cep);
     841extern T_TCP_CEP *tcp_find_cep (T_NET_BUF *input, uint_t off);
     842extern T_TCP_TWCEP*tcp_find_twcep (T_NET_BUF *input, uint_t off);
     843extern bool_t tcp_is_addr_accept (T_NET_BUF *input, uint_t off);
     844extern void tcp_move_twcep (T_TCP_CEP *cep);
    887845
    888846/*
     
    974932
    975933/*
    976  *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
    977  *
    978  *    注意: myaddr は、
    979  *          TINET-1.2 からネットワークバイトオーダ、
    980  *          TINET-1.1 までは、ホストバイトオーダ
    981  */
    982 extern T_TCP_CEP *tcp_find_cep (T_IN_ADDR *dstaddr,  uint16_t dstport,
    983                                 T_IN_ADDR *peeraddr, uint16_t peerport);
    984 
    985 /*
    986934 *  TCP ヘッダのトレース出力機能用関数
    987935 */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.cfg

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_input.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 *
     
    7272#include <sil.h>
    7373#include <t_syslog.h>
     74#include "tinet_cfg.h"
    7475
    7576#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    7980#include <s_services.h>
    8081#include <t_services.h>
    81 #include "kernel_id.h"
     82#include "tinet_id.h"
    8283
    8384#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9293#include <net/ppp_ipcp.h>
    9394#include <net/net.h>
     95#include <net/net_endian.h>
    9496#include <net/net_buf.h>
    9597#include <net/net_count.h>
     
    9799#include <netinet/in.h>
    98100#include <netinet/in_var.h>
    99 #include <netinet6/in6.h>
    100 #include <netinet6/in6_var.h>
    101101#include <netinet/in_itron.h>
    102102#include <netinet/ip.h>
    103103#include <netinet/ip_var.h>
    104 #include <netinet/ip6.h>
    105 #include <netinet6/ip6_var.h>
    106104#include <netinet/ip_icmp.h>
    107 #include <netinet/icmp6.h>
    108 
    109105#include <netinet/udp.h>
    110106#include <netinet/udp_var.h>
     
    124120#endif  /* of #ifdef SUPPORT_MIB */
    125121
    126 #if defined(SUPPORT_INET4)
    127 
    128 #ifdef DHCP_CFG
    129 
    130122/*
    131  *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
    132  *
    133  *    DHCP_CFG が定義されているときは、以下のデータグラムを受信する。
    134  *
    135  *      ・あて先アドレスがブロードキャスト
    136  *      ・ローカルアドレスが未定義
     123 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
    137124 */
    138125
    139 static bool_t
    140 udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
    141 {
    142         T_IFNET *ifp = IF_GET_IFNET();
     126#undef  IN_COPY_TO_HOST
    143127
    144         if (ifp->in_ifaddr.addr == IPV4_ADDRANY ||
    145             ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
    146             ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
    147                 return true;
    148         else
    149                 return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
    150         }
     128#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
    151129
    152 #elif defined(ETHER_CFG_MULTICAST)
     130#define UDP_INPUT               udp6_input
     131#define UDP_INPUT_SELECT        udp6_input_select
     132#define UDP_REPLY_NO_PORT       udp6_reply_no_port
     133#define UDP_FIND_CEP            udp6_find_cep
     134#define GET_UDP_CEPID           GET_UDP6_CEPID
     135#define T_UDP_CEP               T_UDP6_CEP
     136#define API_PROTO               API_PROTO_IPV6
    153137
    154 /*
    155  *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
    156  *
    157  *    以下の場合もデータグラムを受信する。
    158  *
    159  *      ・あて先アドレスがブロードキャスト
    160  */
     138#if defined(_IP4_CFG)
     139#define IN_COPY_TO_HOST         inn_copy_to_host
     140#else
     141#define IN_COPY_TO_HOST         IN6_COPY_TO_HOST
     142#endif
    161143
    162 static bool_t
    163 udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
    164 {
    165         T_IFNET *ifp = IF_GET_IFNET();
    166         T_IN4_ADDR      dst = ntohl(*dstaddr);
     144#include <netinet6/udp6_input.c>
     145#include <netinet/udpn_input.c>
    167146
    168         if (dst == IPV4_ADDR_BROADCAST ||
    169             dst == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask) ||
    170                 IN4_IS_ADDR_MULTICAST(dst))
    171                 return true;
    172         else
    173                 return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
    174         }
     147#undef  UDP_INPUT
     148#undef  UDP_INPUT_SELECT
     149#undef  UDP_REPLY_NO_PORT
     150#undef  UDP_FIND_CEP
     151#undef  GET_UDP_CEPID
     152#undef  T_UDP_CEP
     153#undef  IN_COPY_TO_HOST
     154#undef  API_PROTO
    175155
    176 #else   /* of #ifdef DHCP_CFG */
     156#endif  /* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
    177157
    178 /*
    179  *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
    180  *
    181  *    以下の場合もデータグラムを受信する。
    182  *
    183  *      ・あて先アドレスがブロードキャスト
    184  */
     158#if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \
     159                          ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
    185160
    186 static bool_t
    187 udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
    188 {
    189         T_IFNET *ifp = IF_GET_IFNET();
     161#define UDP_INPUT               udp4_input
     162#define UDP_INPUT_SELECT        udp4_input_select
     163#define UDP_REPLY_NO_PORT       udp4_reply_no_port
     164#define UDP_FIND_CEP            udp4_find_cep
     165#define GET_UDP_CEPID           GET_UDP4_CEPID
     166#define T_UDP_CEP               T_UDP4_CEP
     167#define IN_COPY_TO_HOST         IN4_COPY_TO_HOST
     168#define API_PROTO               API_PROTO_IPV4
    190169
    191         if (ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
    192             ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
    193                 return true;
    194         else
    195                 return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
    196         }
     170#include <netinet/udp4_input.c>
     171#include <netinet/udpn_input.c>
    197172
    198 #endif  /* of #ifdef DHCP_CFG */
    199 
    200 #endif  /* of #if defined(SUPPORT_INET4) */
    201 
    202 #if defined(SUPPORT_INET6)
    203 
    204 /*
    205  *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
    206  *
    207  *    以下の場合もデータグラムを受信する。
    208  *
    209  *      ・あて先アドレスがマルチキャスト
    210  */
    211 
    212 static bool_t
    213 udp_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
    214 {
    215         if (IN6_IS_ADDR_MULTICAST(dstaddr))
    216                 return true;
    217         else
    218                 return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
    219         }
    220 
    221 #endif  /* of #if defined(SUPPORT_INET6) */
    222 
    223 /*
    224  *  udp_input -- UDP の入力関数
    225  */
    226 
    227 uint_t
    228 udp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
    229 {
    230         T_NET_BUF       *input = *inputp;
    231         T_UDP_CEP       *cep;
    232         T_UDP_HDR       *udph;
    233         T_IP_HDR        *iph;
    234         int_t           ix;
    235         uint_t          len, hlen, ulen;
    236 
    237         hlen = (uint_t)GET_IF_IP_HDR_SIZE(input);
    238 
    239         NET_COUNT_UDP(net_count_udp.in_octets,  input->len - hlen);
    240         NET_COUNT_UDP(net_count_udp.in_packets, 1);
    241         NET_COUNT_MIB(udp_stats.udpInDatagrams, 1);
    242 
    243         /* ヘッダ長をチェックする。*/
    244         if (input->len < hlen + UDP_HDR_SIZE)
    245                 goto buf_rel;
    246 
    247         udph = (T_UDP_HDR *)(input->buf + *offp);
    248 
    249         /* データグラム長をチェックする */
    250         ulen  = ntohs(udph->ulen);
    251         if (ulen != input->len - hlen)
    252                 goto buf_rel;
    253 
    254         /* 宛先ポートが 0 のデータグラムは破棄する。RFC768 */
    255         if (udph->dport == 0)
    256                 goto buf_rel;
    257 
    258 #ifdef UDP_CFG_IN_CHECKSUM
    259 
    260         /* チェックサムをチェックする */
    261         if (udph->sum && IN_CKSUM(input, IPPROTO_UDP, *offp, ulen) != 0)
    262                 goto buf_rel;
    263 
    264 #endif  /* of #ifdef UDP_CFG_IN_CHECKSUM */
    265 
    266         iph = GET_IP_HDR(input);
    267 
    268         /* 宛先アドレスとポートをチェックする */
    269         for (ix = tmax_udp_ccepid; ix -- > 0; ) {
    270                 cep = &udp_cep[ix];
    271                 if (VALID_UDP_CEP(cep) &&
    272                     udp_is_dstaddr_accept(&cep->myaddr.ipaddr, &iph->dst) &&
    273                     ntohs(udph->dport) == cep->myaddr.portno) {
    274                         len = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
    275 
    276                         if (cep->rcv_tskid != TA_NULL) {        /* 非ノンブロッキングコールでペンディング中 */
    277                                 if (psnd_dtq(cep->rcvqid, (intptr_t)input) != E_OK)
    278                                         goto buf_rel;
    279                                 }
    280 
    281 #ifdef UDP_CFG_NON_BLOCKING
    282 
    283                         else if (cep->rcv_p_dstaddr != NULL) {  /* ノンブロッキングコールでペンディング中 */
    284 
    285                                 /* p_dstaddr を設定する。*/
    286                                 cep->rcv_p_dstaddr->portno = ntohs(udph->sport);
    287                                 IN_COPY_TO_HOST(&cep->rcv_p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
    288 
    289                                 /* データをバッファに移す。*/
    290                                 memcpy(cep->rcv_data, GET_UDP_SDU(input, *offp),
    291                                        (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
    292                                 syscall(rel_net_buf(input));
    293 
    294                                 if (IS_PTR_DEFINED(cep->callback))
    295 
    296 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    297 
    298                                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
    299 
    300 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    301 
    302                                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
    303 
    304 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    305 
    306                                 else
    307                                         syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
    308                                 cep->rcv_p_dstaddr = NULL;
    309                                 }
    310 
    311 #endif  /* of #ifdef UDP_CFG_NON_BLOCKING */
    312 
    313                         else if (IS_PTR_DEFINED(cep->callback)) {
    314 
    315                                 /* コールバック関数を呼び出す。*/
    316                                 cep->cb_netbuf = input;
    317 
    318 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    319 
    320                                 (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
    321 
    322 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    323 
    324                                 (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
    325 
    326 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    327 
    328                                 /*
    329                                  *  ネットワークバッファがそのままであれば、コールバック関数内で
    330                                  *  データを読み出さなかったことになるので、捨てる。
    331                                  */
    332                                 if (cep->cb_netbuf != NULL)
    333                                         syscall(rel_net_buf(cep->cb_netbuf));
    334                                 }
    335                         else
    336                                 goto buf_rel;
    337 
    338                         return IPPROTO_DONE;
    339                         }
    340                 }
    341 
    342         NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
    343 
    344 #if defined(SUPPORT_INET4)
    345 
    346         /* ローカル IP アドレスに届いたデータグラムのみ ICMP エラーを通知する。*/
    347         if (ntohl(iph->dst) == IF_GET_IFNET()->in_ifaddr.addr) {
    348                 syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
    349 
    350                 icmp_error(ICMP4_UNREACH_PORT, input);
    351                 /* icmp_error では、ネットワークバッファ input を返却しないので下へ抜ける。*/
    352                 }
    353 
    354 #endif  /* of #if defined(SUPPORT_INET4) */
    355 
    356 #if defined(SUPPORT_INET6)
    357 
    358         /* マルチキャストアドレスに届いたデータグラムは ICMP エラーを通知しない。*/
    359         if (!IN6_IS_ADDR_MULTICAST(&iph->dst)) {
    360                 syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
    361 
    362                 /* icmp6_error で、ネットワークバッファ input を返却する。*/
    363                 icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
    364 
    365                 NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
    366                 NET_COUNT_MIB(udp_stats.udpInErrors, 1);
    367                 return IPPROTO_DONE;
    368                 }
    369 
    370 #endif  /* of #if defined(SUPPORT_INET6) */
    371 
    372 buf_rel:
    373         NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
    374         NET_COUNT_MIB(udp_stats.udpInErrors, 1);
    375         syscall(rel_net_buf(input));
    376         return IPPROTO_DONE;
    377         }
     173#endif  /* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
    378174
    379175#endif  /* of #ifdef SUPPORT_UDP */
  • 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        }
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c

    r321 r331  
    22 *  TINET (UDP/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 *
     
    7171#include <kernel.h>
    7272#include <sil.h>
     73#include <t_syslog.h>
    7374#include "kernel_cfg.h"
     75#include "tinet_cfg.h"
    7476
    7577#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8082#include <t_services.h>
    8183#include "kernel_id.h"
     84#include "tinet_id.h"
    8285
    8386#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9194#include <net/ethernet.h>
    9295#include <net/net.h>
     96#include <net/net_endian.h>
    9397#include <net/net_buf.h>
    9498#include <net/net_count.h>
     
    96100
    97101#include <netinet/in.h>
    98 #include <netinet6/in6.h>
    99102#include <netinet/in_var.h>
    100103#include <netinet/in_itron.h>
     
    102105#include <netinet/ip_var.h>
    103106#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>
    109107#include <netinet/udp.h>
    110108#include <netinet/udp_var.h>
     109#include <netinet/ip_igmp.h>
     110
     111#include <net/if_var.h>
    111112
    112113#ifdef SUPPORT_UDP
     
    116117 */
    117118
     119#if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0)
     120
    118121static uint16_t udp_port_auto = UDP_PORT_FIRST_AUTO;    /* 自動割り当て番号     */
    119122
     123#endif  /* of #if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0) */
     124
    120125/*
    121  *  udp_alloc_auto_port -- 自動割り当てポート番号を設定する。
     126 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
    122127 */
    123128
    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
    129130
    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)
    135132
    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
    143134
    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) */
    150136
    151                 } while (portno_start != udp_port_auto);
     137#define UDP_IS_DSTADDR_ACCEPT   udp6_is_dstaddr_accept
    152138
    153         return E_NOID;
    154         }
     139#endif  /* of #if defined(_IP4_CFG) */
    155140
    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
    159153
    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>
    164156
    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 */
    175195
    176196#endif  /* of #ifdef SUPPORT_UDP */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c

    r321 r331  
    22 *  TINET (UDP/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 *
     
    7878#include <kernel.h>
    7979#include <sil.h>
     80#include "tinet_cfg.h"
    8081
    8182#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8586#include <s_services.h>
    8687#include <t_services.h>
    87 #include "kernel_id.h"
     88#include "tinet_id.h"
    8889
    8990#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9798#include <net/ethernet.h>
    9899#include <net/net.h>
     100#include <net/net_endian.h>
    99101#include <net/net_buf.h>
    100102#include <net/net_count.h>
     
    102104
    103105#include <netinet/in.h>
    104 #include <netinet6/in6.h>
    105106#include <netinet/in_var.h>
    106107#include <netinet/in_itron.h>
     
    108109#include <netinet/ip_var.h>
    109110#include <netinet/ip_icmp.h>
    110 #include <netinet6/in6_var.h>
    111 #include <netinet/ip6.h>
    112 #include <netinet6/ip6_var.h>
    113 #include <netinet6/nd6.h>
    114 #include <netinet/icmp6.h>
    115111#include <netinet/udp.h>
    116112#include <netinet/udp_var.h>
     113#include <netinet/ip_igmp.h>
    117114
    118115#ifdef SUPPORT_UDP
    119 
    120 /*
    121  *  IPv4 と IPv6 の切り替えマクロ
    122  */
    123 
    124 #if defined(SUPPORT_INET4)
    125 
    126 #define UDP_CRE_CEP     udp_cre_cep
    127 #define UDP_SND_DAT     udp_snd_dat
    128 #define UDP_RCV_DAT     udp_rcv_dat
    129 
    130 #endif  /* of #if defined(SUPPORT_INET4) */
    131 
    132 #if defined(SUPPORT_INET6)
    133 
    134 #define UDP_CRE_CEP     udp6_cre_cep
    135 #define UDP_SND_DAT     udp6_snd_dat
    136 #define UDP_RCV_DAT     udp6_rcv_dat
    137 
    138 #endif  /* of #if defined(SUPPORT_INET6) */
    139116
    140117/*
     
    158135#endif  /* of #ifndef UDP_CFG_LIBRARY */
    159136
    160 #ifdef __udp_send_data
    161 
    162 /*
    163  *  udp_send_data -- パケット送信の主要部
    164  */
    165 
    166 ER_UINT
    167 udp_send_data (T_UDP_CEP *cep, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
    168 {
    169         T_NET_BUF       *output;
    170         T_UDP_HDR       *udph;
    171         SYSTIM          before, after;
    172         ER              error = E_OK;
    173 
    174 #ifdef UDP_CFG_OUT_CHECKSUM
    175         uint16_t        sum;
    176 #endif  /* of #ifdef UDP_CFG_OUT_CHECKSUM */
    177 
    178         NET_COUNT_UDP(net_count_udp.out_octets,  len);
    179         NET_COUNT_UDP(net_count_udp.out_packets, 1);
    180 
    181         /* IP データグラム割り当ての時間を tmout から減ずる。*/
    182         if (!(tmout == TMO_POL || tmout == TMO_FEVR))
    183                 syscall(get_tim(&before));
    184 
    185         /* IP データグラムを割り当てる。*/
    186         if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + len), 0,
    187                                      &p_dstaddr->ipaddr,
    188                                      &cep->myaddr.ipaddr,
    189                                      IPPROTO_UDP, IP_DEFTTL,
    190                                      NBA_SEARCH_ASCENT, tmout)) != E_OK)
    191                 goto err_ret;
    192 
    193         /* IP データグラム割り当ての時間を tmout から減ずる。*/
    194         if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
    195                 syscall(get_tim(&after));
    196                 if (after - before > tmout) {
    197                         syscall(rel_net_buf(output));
    198                         error = E_TMOUT;
    199                         goto err_ret;
    200                         }
    201                 tmout -= (TMO)(after - before);
    202                 }
    203 
    204         /* UDP ヘッダに情報を設定する。*/
    205         udph            = GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET);
    206         udph->sport     = htons(cep->myaddr.portno);
    207         udph->dport     = htons(p_dstaddr->portno);
    208         udph->ulen      = htons(UDP_HDR_SIZE + len);
    209         udph->sum       = 0;
    210 
    211         /* データをコピーする。*/
    212         memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET), data, (size_t)len);
    213 
    214 #ifdef UDP_CFG_OUT_CHECKSUM
    215 
    216         sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET, (uint_t)(UDP_HDR_SIZE + len));
    217 
    218         /* 計算したチェックサムの値が 0 なら 0xffff を入れる。*/
    219         if (sum == 0)
    220                 sum = 0xffff;
    221         udph->sum = sum;
    222 
    223 #endif  /* of #ifdef UDP_CFG_OUT_CHECKSUM */
    224 
    225         /* ネットワークバッファ長を調整する。*/
    226         output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE + len);
    227 
    228         /* ネットワーク層 (IP) の出力関数を呼び出す。*/
    229         if ((error = IP_OUTPUT(output, tmout)) == E_OK) {
    230                 NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
    231                 cep->snd_tskid = TA_NULL;
    232                 return len;
    233                 }
    234 
    235 err_ret:
    236         NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
    237         cep->snd_tskid = TA_NULL;
    238         return error;
    239         }
    240 
    241 #endif  /* of #ifdef __udp_send_data */
    242 
    243 /*
    244  *  udp_cre_cep -- UDP 通信端点の生成【拡張機能】
    245  */
    246 
    247 #ifdef __udp_cre_cep
    248 
    249 #ifdef UDP_CFG_EXTENTIONS
    250 
    251 ER
    252 UDP_CRE_CEP (ID cepid, T_UDP_CCEP *pk_ccep)
    253 {
    254         T_UDP_CEP       *cep;
    255         ER              error;
    256 
    257         /* UDP 通信端点 ID をチェックする。*/
    258         if (!VALID_UDP_CEPID(cepid))
    259                 return E_ID;
    260 
    261         /* pk_ccep が NULL ならエラー */
    262         if (pk_ccep == NULL)
    263                 return E_PAR;
    264 
    265         /* UDP 通信端点を得る。*/
    266         cep = GET_UDP_CEP(cepid);
    267 
    268         /* UDP 通信端点をチェックする。*/
    269         if (VALID_UDP_CEP(cep))
    270                 return E_OBJ;
    271 
    272         /* UDP 通信端点が、動的生成用でなければエラー */
    273         if (!DYNAMIC_UDP_CEP(cep))
    274                 return E_ID;
    275 
    276         /* 通信端点をロックする。*/
    277         syscall(wai_sem(cep->semid_lock));
    278 
    279         /*
    280          * UDP 通信端点をチェックする。生成済みであればエラー
    281          */
    282         if (VALID_UDP_CEP(cep))
    283                 error = E_OBJ;
    284         else {
    285 
    286                 /*
    287                  *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
    288                  */
    289                 if (pk_ccep->myaddr.portno == UDP_PORTANY)
    290                         error = udp_alloc_auto_port(cep);
    291                 else
    292                         error = udp_alloc_port(cep, pk_ccep->myaddr.portno);
    293                
    294                 if (error == E_OK) {
    295 
    296                         /* UDP 通信端点生成情報をコピーする。*/
    297                         cep->cepatr        = pk_ccep->cepatr;                   /* 通信端点属性               */
    298                         cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;            /* 自分のアドレス      */
    299                         cep->callback      = (void*)pk_ccep->callback;          /* コールバック               */
    300 
    301                         /* UDP 通信端点を生成済みにする。*/
    302                         cep->flags |= UDP_CEP_FLG_VALID;
    303                         }
    304                 }
    305 
    306         /* 通信端点のロックを解除する。*/
    307         syscall(sig_sem(cep->semid_lock));
    308 
    309         return error;
    310         }
    311 
    312 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    313 
    314 #endif  /* of #ifdef __udp_cre_cep */
    315 
    316 /*
    317  *  udp_del_cep -- UDP 通信端点の削除【拡張機能】
    318  */
    319 
    320 #ifdef __udp_del_cep
    321 
    322 #ifdef UDP_CFG_EXTENTIONS
    323 
    324 ER
    325 udp_del_cep (ID cepid)
    326 {
    327         T_UDP_CEP       *cep;
    328         ER              error;
    329 
    330         /* UDP 通信端点 ID をチェックする。*/
    331         if (!VALID_UDP_CEPID(cepid))
    332                 return E_ID;
    333 
    334         /* UDP 通信端点を得る。*/
    335         cep = GET_UDP_CEP(cepid);
    336 
    337         /* UDP 通信端点をチェックする。*/
    338         if (!VALID_UDP_CEP(cep))
    339                 return E_NOEXS;
    340 
    341         /* UDP 通信端点が、動的生成用でなければエラー */
    342         if (!DYNAMIC_UDP_CEP(cep))
    343                 return E_ID;
    344 
    345         /* 通信端点をロックする。*/
    346         syscall(wai_sem(cep->semid_lock));
    347 
    348         /*
    349          * UDP 通信端点をチェックする。未生成の場合はエラー
    350          * ・未生成。
    351          */
    352         if (!VALID_UDP_CEP(cep))
    353                 error = E_NOEXS;
    354         else {
    355                 udp_can_snd(cep, E_DLT);
    356                 udp_can_rcv(cep, E_DLT);
    357 
    358                 /* UDP 通信端点を未生成にする。*/
    359                 cep->flags &= ~UDP_CEP_FLG_VALID;
    360                 error = E_OK;
    361                 }
    362 
    363         /* 通信端点のロックを解除する。*/
    364         syscall(sig_sem(cep->semid_lock));
    365 
    366         return error;
    367         }
    368 
    369 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    370 
    371 #endif  /* of #ifdef __udp_del_cep */
     137/*
     138 *  IPv6 と IPv4 で引数が異なる関数のコンパイル
     139 */
     140
     141#undef  IN_GET_DATAGRAM
     142#undef  IN_COPY_TO_HOST
     143
     144#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
     145
     146#define UDP_CANCEL_CEP          udp6_cancel_cep
     147#define UDP_DELETE_CEP          udp6_delete_cep
     148#define UDP_SET_OPTION          udp6_set_option
     149#define UDP_GET_OPTION          udp6_get_option
     150#define UDP_CRE_CEP             udp6_cre_cep
     151#define UDP_DEL_CEP             udp6_del_cep
     152#define UDP_SET_OPT             udp6_set_opt
     153#define UDP_GET_OPT             udp6_get_opt
     154#define UDP_SND_DAT             udp6_snd_dat
     155#define UDP_RCV_DAT             udp6_rcv_dat
     156#define UDP_CAN_SND             udp6_can_snd
     157#define UDP_CAN_RCV             udp6_can_rcv
     158#define UDP_ALLOC_AUTO_PORT     udp6_alloc_auto_port
     159#define UDP_ALLOC_PORT          udp6_alloc_port
     160#define UDP_SEND_DATA           udp6_send_data
     161#define VALID_UDP_CEPID         VALID_UDP6_CEPID
     162#define GET_UDP_CEP             GET_UDP6_CEP
     163#define GET_UDP_CEPID           GET_UDP6_CEPID
     164#define T_UDP_CEP               T_UDP6_CEP
     165#define T_UDPN_CCEP             T_UDP6_CCEP
     166#define T_IPEP                  T_IPV6EP
     167#define API_PROTO               API_PROTO_IPV6
     168
     169#if defined(_IP4_CFG)
     170#define IN_GET_DATAGRAM         inn_get_datagram
     171#define IN_COPY_TO_HOST         inn_copy_to_host
     172#else
     173#define IN_GET_DATAGRAM         in6_get_datagram
     174#define IN_COPY_TO_HOST         IN6_COPY_TO_HOST
     175#endif
     176
     177#include <netinet/udpn_usrreq.c>
     178
     179#undef  UDP_CANCEL_CEP
     180#undef  UDP_DELETE_CEP
     181#undef  UDP_SET_OPTION
     182#undef  UDP_GET_OPTION
     183#undef  UDP_CRE_CEP
     184#undef  UDP_DEL_CEP
     185#undef  UDP_SET_OPT
     186#undef  UDP_GET_OPT
     187#undef  UDP_SND_DAT
     188#undef  UDP_RCV_DAT
     189#undef  UDP_CAN_SND
     190#undef  UDP_CAN_RCV
     191#undef  UDP_ALLOC_AUTO_PORT
     192#undef  UDP_ALLOC_PORT
     193#undef  UDP_SEND_DATA
     194#undef  VALID_UDP_CEPID
     195#undef  GET_UDP_CEP
     196#undef  GET_UDP_CEPID
     197#undef  T_UDP_CEP
     198#undef  T_UDPN_CCEP
     199#undef  T_IPEP
     200#undef  API_PROTO
     201#undef  IN_GET_DATAGRAM
     202#undef  IN_COPY_TO_HOST
     203
     204#endif  /* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
     205
     206#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
     207
     208#define UDP_CANCEL_CEP          udp4_cancel_cep
     209#define UDP_DELETE_CEP          udp4_delete_cep
     210#define UDP_SET_OPTION          udp4_set_option
     211#define UDP_GET_OPTION          udp4_get_option
     212#define UDP_CRE_CEP             udp_cre_cep
     213#define UDP_DEL_CEP             udp_del_cep
     214#define UDP_SET_OPT             udp_set_opt
     215#define UDP_GET_OPT             udp_get_opt
     216#define UDP_SND_DAT             udp_snd_dat
     217#define UDP_RCV_DAT             udp_rcv_dat
     218#define UDP_CAN_SND             udp4_can_snd
     219#define UDP_CAN_RCV             udp4_can_rcv
     220#define UDP_ALLOC_AUTO_PORT     udp4_alloc_auto_port
     221#define UDP_ALLOC_PORT          udp4_alloc_port
     222#define UDP_SEND_DATA           udp4_send_data
     223#define VALID_UDP_CEPID         VALID_UDP4_CEPID
     224#define GET_UDP_CEP             GET_UDP4_CEP
     225#define GET_UDP_CEPID           GET_UDP4_CEPID
     226#define T_UDP_CEP               T_UDP4_CEP
     227#define T_UDPN_CCEP             T_UDP_CCEP
     228#define T_IPEP                  T_IPV4EP
     229#define API_PROTO               API_PROTO_IPV4
     230
     231#define IN_COPY_TO_HOST         IN4_COPY_TO_HOST
     232#define IN_GET_DATAGRAM         in4_get_datagram
     233
     234#include <netinet/udpn_usrreq.c>
     235
     236#endif  /* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
     237
     238#if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0)
     239
     240/*
     241 *  udp_can_cep -- ペンディングしている処理のキャンセル【標準機能】
     242 */
    372243
    373244#ifdef __udp_can_cep
    374 
    375 /*
    376  *  udp_can_cep -- ペンディングしている処理のキャンセル【標準機能】
    377  */
    378245
    379246ER
    380247udp_can_cep (ID cepid, FN fncd)
    381248{
    382         T_UDP_CEP       *cep;
    383         ER              error = E_OK, snd_err, rcv_err;
    384 
    385         /* API 機能コードをチェックする。*/
    386         if (!VALID_TFN_UDP_CAN(fncd))
    387                 return E_PAR;
    388 
    389         /* UDP 通信端点 ID をチェックする。*/
    390         if (!VALID_UDP_CEPID(cepid))
     249        /* IPv6 用の UDP 通信端点 ID をチェックする。*/
     250        if (VALID_UDP6_CEPID(cepid)) {
     251
     252                /* UDP 通信端点を得てメイン関数を呼び出す。*/
     253                return udp6_cancel_cep(GET_UDP6_CEP(cepid), fncd);
     254                }
     255
     256        /* IPv4 用の UDP 通信端点 ID をチェックする。*/
     257        else if (VALID_UDP4_CEPID(cepid)) {
     258
     259                /* UDP 通信端点を得てメイン関数を呼び出す。*/
     260                return udp4_cancel_cep(GET_UDP4_CEP(cepid), fncd);
     261                }
     262
     263        else
    391264                return E_ID;
    392 
    393         /* UDP 通信端点を得る。*/
    394         cep = GET_UDP_CEP(cepid);
    395 
    396         /* UDP 通信端点をチェックする。*/
    397         if (!VALID_UDP_CEP(cep))
    398                 return E_NOEXS;
    399 
    400         /* 通信端点をロックする。*/
    401         syscall(wai_sem(cep->semid_lock));
    402 
    403         if (fncd == TFN_UDP_ALL) {      /* TFN_UDP_ALL の処理 */
    404 
    405                 snd_err = udp_can_snd(cep, E_RLWAI);
    406                 rcv_err = udp_can_rcv(cep, E_RLWAI);
    407 
    408                 /*
    409                  *  snd_err と rcv_err のどちらも EV_NOPND
    410                  *  なら、ペンディングしていないのでエラー
    411                  */
    412                 if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
    413                         error = E_OBJ;
    414                 else {
    415                         if (snd_err == EV_NOPND)
    416                                 snd_err = E_OK;
    417                         if (rcv_err == EV_NOPND)
    418                                 rcv_err = E_OK;
    419 
    420                         if (snd_err != E_OK)
    421                                 error = snd_err;
    422                         else if (rcv_err != E_OK)
    423                                 error = rcv_err;
    424                         }
    425                 }
    426         else if (fncd == TFN_UDP_SND_DAT) {     /* 送信処理のキャンセル */
    427                 if ((error = udp_can_snd(cep, E_RLWAI)) == EV_NOPND)
    428                         error = E_OBJ;
    429                 }
    430         else if (fncd == TFN_UDP_RCV_DAT) {     /* 受信処理のキャンセル */
    431                 if ((error = udp_can_rcv(cep, E_RLWAI)) == EV_NOPND)
    432                         error = E_OBJ;
    433                 }
    434         else
    435                 error = E_PAR;
    436 
    437         /* 通信端点をロックを解除する。*/
    438         syscall(sig_sem(cep->semid_lock));
    439 
    440         return error;
    441265        }
    442266
    443267#endif  /* of #ifdef __udp_can_cep */
    444268
    445 /*
    446  *  udp_set_opt -- UDP 通信端点オプションの設定【拡張機能】
    447  *
    448  *  注意: 設定可能な UDP 通信端点オプションは無いため、E_PAR が返される。
    449  */
    450 
    451 #ifdef __udp_set_opt
    452 
    453 #ifdef UDP_CFG_EXTENTIONS
    454 
    455 ER
    456 udp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
    457 {
    458         T_UDP_CEP       *cep;
    459 
    460         /* UDP 通信端点 ID をチェックする。*/
    461         if (!VALID_UDP_CEPID(cepid))
    462                 return E_ID;
    463 
    464         /* UDP 通信端点を得る。*/
    465         cep = GET_UDP_CEP(cepid);
    466 
    467         /* UDP 通信端点をチェックする。*/
    468         if (!VALID_UDP_CEP(cep))
    469                 return E_NOEXS;
    470 
    471         return E_OK/*E_PAR*/;
    472         }
    473 
    474 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    475 
    476 #endif  /* of #ifdef __udp_set_opt */
    477 
    478 /*
    479  *  udp_get_opt -- UDP 通信端点オプションの設定【拡張機能】
    480  *
    481  *  注意: 設定可能な UDP 通信端点オプションは無いため、E_PAR が返される。
    482  */
    483 
    484 #ifdef __udp_get_opt
    485 
    486 #ifdef UDP_CFG_EXTENTIONS
    487 
    488 ER
    489 udp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
    490 {
    491         T_UDP_CEP       *cep;
    492 
    493         /* UDP 通信端点 ID をチェックする。*/
    494         if (!VALID_UDP_CEPID(cepid))
    495                 return E_ID;
    496 
    497         /* UDP 通信端点を得る。*/
    498         cep = GET_UDP_CEP(cepid);
    499 
    500         /* UDP 通信端点をチェックする。*/
    501         if (!VALID_UDP_CEP(cep))
    502                 return E_NOEXS;
    503 
    504         return E_OK/*E_PAR*/;
    505         }
    506 
    507 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    508 
    509 #endif  /* of #ifdef __udp_get_opt */
    510 
    511 #ifdef UDP_CFG_NON_BLOCKING
    512 
    513 #include "udp_usrreq_nblk.c"
    514 
    515 #else   /* of #ifdef UDP_CFG_NON_BLOCKING */
    516 
    517 #ifdef __udp_can_snd
    518 
    519 /*
    520  *  udp_can_snd -- ペンディングしている送信のキャンセル
    521  */
    522 
    523 ER
    524 udp_can_snd (T_UDP_CEP *cep, ER error)
    525 {
    526         if (cep->snd_tskid != TA_NULL) {        /* 非ノンブロッキングコールでペンディング中 */
    527 
    528 #ifdef UDP_CFG_EXTENTIONS
    529 
    530                 /* 待ち中に発生したエラー情報を設定する。*/
    531                 cep->error = error;
    532 
    533 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    534 
    535                 error = rel_wai(cep->snd_tskid);
    536                 cep->snd_tskid = TA_NULL;
    537                 }
    538         else                                    /* どちらでもないならペンディングしていない */
    539                 error = EV_NOPND;
    540 
    541         return error;
    542         }
    543 
    544 #endif  /* of #ifdef __udp_can_snd */
    545 
    546 #ifdef __udp_can_rcv
    547 
    548 /*
    549  *  udp_can_rcv -- ペンディングしている受信のキャンセル
    550  */
    551 
    552 ER
    553 udp_can_rcv (T_UDP_CEP *cep, ER error)
    554 {
    555         if (cep->rcv_tskid != TA_NULL) {        /* 非ノンブロッキングコールでペンディング中 */
    556 
    557 #ifdef UDP_CFG_EXTENTIONS
    558 
    559                 /* 待ち中に発生したエラー情報を設定する。*/
    560                 cep->error = error;
    561 
    562 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    563 
    564                 error = rel_wai(cep->rcv_tskid);
    565                 cep->rcv_tskid = TA_NULL;
    566                 }
    567         else                                    /* どちらでもないならペンディングしていない */
    568                 error = EV_NOPND;
    569 
    570         return error;
    571         }
    572 
    573 #endif  /* of #ifdef __udp_can_rcv */
    574 
    575 #ifdef __udp_snd_dat
    576 
    577 /*
    578  *  udp_snd_dat -- パケットの送信【標準機能】
    579  */
    580 
    581 ER_UINT
    582 UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
    583 {
    584         T_UDP_CEP       *cep;
    585         ER              error;
    586 
    587         /* p_dstaddr または data が NULL か、tmout が TMO_NBLK ならエラー */
    588         if (p_dstaddr == NULL || data == NULL || tmout == TMO_NBLK)
    589                 return E_PAR;
    590 
    591         /* データ長をチェックする。*/
    592         if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
    593                 return E_PAR;
    594 
    595         /* UDP 通信端点 ID をチェックする。*/
    596         if (!VALID_UDP_CEPID(cepid))
    597                 return E_ID;
    598 
    599         /* UDP 通信端点を得る。*/
    600         cep = GET_UDP_CEP(cepid);
    601 
    602         /* UDP 通信端点をチェックする。*/
    603         if (!VALID_UDP_CEP(cep))
    604                 return E_NOEXS;
    605 
    606         /*
    607          *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
    608          */
    609         if (cep->myaddr.portno == UDP_PORTANY) {
    610                 if ((error = udp_alloc_auto_port(cep)) != E_OK)
    611                         return error;
    612                 }
    613        
    614         /* 通信端点をロックする。*/
    615         syscall(wai_sem(cep->semid_lock));
    616 
    617         if (cep->snd_tskid != TA_NULL) {
    618 
    619                 /* 非ノンブロッキングコールでペンディング中 */
    620                 error = E_QOVR;
    621 
    622                 /* 通信端点をロックを解除する。*/
    623                 syscall(sig_sem(cep->semid_lock));
    624                 }
    625         else {
    626                 /* 現在のタスク識別子を記録する。*/
    627                 get_tid(&(cep->snd_tskid));
    628 
    629 #ifdef UDP_CFG_EXTENTIONS
    630 
    631                 /* 待ち中に発生したエラー情報をリセットする。*/
    632                 cep->error = E_OK;
    633 
    634 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    635 
    636                 /* 通信端点をロックを解除する。*/
    637                 syscall(sig_sem(cep->semid_lock));
    638 
    639                 /* パケットを送信する。*/
    640                 error = udp_send_data(cep, p_dstaddr, data, len, tmout);
    641 
    642 #ifdef UDP_CFG_EXTENTIONS
    643 
    644                 /* 待ち中に発生したエラー情報を返す。*/
    645                 if (error == E_RLWAI)
    646                         error = cep->error;
    647 
    648 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    649                 }
    650 
    651         return error;
    652         }
    653 
    654 #endif  /* of #ifdef __udp_snd_dat */
    655 
    656 #ifdef __udp_rcv_dat
    657 
    658 /*
    659  *  udp_rcv_dat -- パケットの受信【標準機能】
    660  */
    661 
    662 ER_UINT
    663 UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
    664 {
    665         T_NET_BUF       *input;
    666         T_UDP_CEP       *cep;
    667         T_UDP_HDR       *udph;
    668         ER_UINT         error;
    669         uint_t          ulen, uhoff;
    670 
    671         /* p_dstaddr または data が NULL 、len < 0 か、tmout が TMO_NBLK ならエラー */
    672         if (p_dstaddr == NULL || data == NULL || len < 0 || tmout == TMO_NBLK)
    673                 return E_PAR;
    674 
    675         /* UDP 通信端点 ID をチェックする。*/
    676         if (!VALID_UDP_CEPID(cepid))
    677                 return E_ID;
    678 
    679         /* UDP 通信端点を得る。*/
    680         cep = GET_UDP_CEP(cepid);
    681 
    682         /* UDP 通信端点をチェックする。*/
    683         if (!VALID_UDP_CEP(cep))
    684                 return E_NOEXS;
    685 
    686         /* 通信端点をロックする。*/
    687         syscall(wai_sem(cep->semid_lock));
    688 
    689         if (cep->rcv_tskid != TA_NULL) {
    690 
    691                 /* 非ノンブロッキングコールでペンディング中 */
    692                 error = E_QOVR;
    693 
    694                 /* 通信端点をロックを解除する。*/
    695                 syscall(sig_sem(cep->semid_lock));
    696                 }
    697         else {
    698 
    699                 /* 現在のタスク識別子を記録する。*/
    700                 get_tid(&(cep->rcv_tskid));
    701 
    702 #ifdef UDP_CFG_EXTENTIONS
    703 
    704                 /* 待ち中に発生したエラー情報をリセットする。*/
    705                 cep->error = E_OK;
    706 
    707 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    708 
    709                 /* 通信端点をロックを解除する。*/
    710                 syscall(sig_sem(cep->semid_lock));
    711 
    712                 /* 入力があるまで待つ。*/
    713                 if (cep->cb_netbuf != NULL) {
    714 
    715                         /*
    716                          *  ここにくる場合は、コールバック関数の中から
    717                          *  udp_rcv_dat を呼び出していることになり、
    718                          *  すでに入力済みである。
    719                          */
    720                         input = cep->cb_netbuf;
    721                         cep->cb_netbuf = NULL;
    722                         }
    723                 else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
    724 
    725 #ifdef UDP_CFG_EXTENTIONS
    726 
    727                         /* 待ち中に発生したエラー情報を返す。*/
    728                         if (error == E_RLWAI)
    729                                 error = cep->error;
    730 
    731 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    732 
    733                         cep->rcv_tskid = TA_NULL;
    734                         return error;
    735                         }
    736 
    737                 /* p_dstaddr を設定する。*/
    738                 uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
    739                 udph = GET_UDP_HDR(input, uhoff);
    740                 p_dstaddr->portno = ntohs(udph->sport);
    741                 IN_COPY_TO_HOST(&p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
    742 
    743                 /* データをバッファに移す。*/
    744                 ulen = ntohs(udph->ulen);
    745                 if (ulen - UDP_HDR_SIZE > len)
    746                         error = E_BOVR;
    747                 else {
    748                         len   =    (uint_t)(ulen - UDP_HDR_SIZE);
    749                         error = (ER_UINT)(ulen - UDP_HDR_SIZE);
    750                         }
    751 
    752                 memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
    753 
    754                 syscall(rel_net_buf(input));
    755 
    756                 cep->rcv_tskid = TA_NULL;
    757                 }
    758 
    759         return error;
    760         }
    761 
    762 #endif  /* of #ifdef __udp_rcv_dat */
    763 
    764 #endif  /* of #ifdef UDP_CFG_NON_BLOCKING */
     269#endif  /* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
    765270
    766271#endif  /* of #ifdef SUPPORT_UDP */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq_nblk.c

    r321 r331  
    22 *  TINET (UDP/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 *
     
    7575#include <sil.h>
    7676#include "kernel_cfg.h"
     77#include "tinet_cfg.h"
    7778
    7879#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    8384#include <t_services.h>
    8485#include "kernel_id.h"
     86#include "tinet_id.h"
    8587
    8688#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    9496#include <net/ethernet.h>
    9597#include <net/net.h>
     98#include <net/net_endian.h>
    9699#include <net/net_buf.h>
    97100#include <net/net_count.h>
     
    99102
    100103#include <netinet/in.h>
    101 #include <netinet6/in6.h>
    102104#include <netinet/in_var.h>
    103105#include <netinet/in_itron.h>
     
    105107#include <netinet/ip_var.h>
    106108#include <netinet/ip_icmp.h>
    107 #include <netinet6/in6_var.h>
    108 #include <netinet/ip6.h>
    109 #include <netinet6/ip6_var.h>
    110 #include <netinet6/nd6.h>
    111 #include <netinet/icmp6.h>
    112109#include <netinet/udp.h>
    113110#include <netinet/udp_var.h>
    114111
    115112#ifdef SUPPORT_UDP
    116 
    117 /*
    118  *  IPv4 と IPv6 の切り替えマクロ
    119  */
    120 
    121 #if defined(SUPPORT_INET4)
    122 
    123 #define UDP_SND_DAT     udp_snd_dat
    124 #define UDP_RCV_DAT     udp_rcv_dat
    125 
    126 #endif  /* of #if defined(SUPPORT_INET4) */
    127 
    128 #if defined(SUPPORT_INET6)
    129 
    130 #define UDP_SND_DAT     udp6_snd_dat
    131 #define UDP_RCV_DAT     udp6_rcv_dat
    132 
    133 #endif  /* of #if defined(SUPPORT_INET6) */
    134113
    135114/*
     
    140119#ifndef UDP_CFG_LIBRARY
    141120
    142 #define __udp_can_snd
    143 #define __udp_can_rcv
    144 #define __udp_snd_dat
    145 #define __udp_rcv_dat
     121#define __udp_can_snd_nblk
     122#define __udp_can_rcv_nblk
     123#define __udp_snd_dat_nblk
     124#define __udp_rcv_dat_nblk
    146125
    147126#endif  /* of #ifndef UDP_CFG_LIBRARY */
     
    149128#ifdef UDP_CFG_NON_BLOCKING
    150129
    151 #ifdef __udp_can_snd
    152 
    153130/*
    154  *  udp_can_snd -- ペンディングしている送信のキャンセ
     131 *  IPv6 と IPv4 で引数が異なる関数のコンパイ
    155132 */
    156133
    157 ER
    158 udp_can_snd (T_UDP_CEP *cep, ER error)
    159 {
    160         if (cep->snd_p_dstaddr != NULL) {       /* ノンブロッキングコールでペンディング中 */
    161                 if (IS_PTR_DEFINED(cep->callback))
     134#undef  IN_COPY_TO_HOST
    162135
    163 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
     136#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
    164137
    165                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
     138#define UDP_SND_DAT             udp6_snd_dat
     139#define UDP_RCV_DAT             udp6_rcv_dat
     140#define UDP_CAN_SND             udp6_can_snd
     141#define UDP_CAN_RCV             udp6_can_rcv
     142#define UDP_ALLOC_AUTO_PORT     udp6_alloc_auto_port
     143#define UDP_SEND_DATA           udp6_send_data
     144#define VALID_UDP_CEPID         VALID_UDP6_CEPID
     145#define GET_UDP_CEP             GET_UDP6_CEP
     146#define GET_UDP_CEPID           GET_UDP6_CEPID
     147#define T_UDP_CEP               T_UDP6_CEP
     148#define T_IPEP                  T_IPV6EP
     149#define API_PROTO               API_PROTO_IPV6
    166150
    167 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
     151#if defined(SUPPORT_INET4)
     152#define IN_COPY_TO_HOST         inn_copy_to_host
     153#else
     154#define IN_COPY_TO_HOST         IN6_COPY_TO_HOST
     155#endif
    168156
    169                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
     157#include <netinet/udpn_usrreq_nblk.c>
    170158
    171 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
     159#undef  UDP_SND_DAT
     160#undef  UDP_RCV_DAT
     161#undef  UDP_CAN_SND
     162#undef  UDP_CAN_RCV
     163#undef  UDP_ALLOC_AUTO_PORT
     164#undef  UDP_SEND_DATA
     165#undef  VALID_UDP_CEPID
     166#undef  GET_UDP_CEP
     167#undef  GET_UDP_CEPID
     168#undef  T_UDP_CEP
     169#undef  T_IPEP
     170#undef  API_PROTO
     171#undef  IN_COPY_TO_HOST
    172172
    173                 else
    174                         error = E_OBJ;
    175                 cep->snd_p_dstaddr = NULL;
    176                 }
    177         else if (cep->snd_tskid != TA_NULL) {   /* 非ノンブロッキングコールでペンディング中 */
     173#endif  /* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
    178174
    179 #ifdef UDP_CFG_EXTENTIONS
     175#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
    180176
    181                 /* 待ち中に発生したエラー情報を設定する。*/
    182                 cep->error = error;
     177#define UDP_SND_DAT             udp_snd_dat
     178#define UDP_RCV_DAT             udp_rcv_dat
     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_SEND_DATA           udp4_send_data
     183#define VALID_UDP_CEPID         VALID_UDP4_CEPID
     184#define GET_UDP_CEP             GET_UDP4_CEP
     185#define GET_UDP_CEPID           GET_UDP4_CEPID
     186#define T_UDP_CEP               T_UDP4_CEP
     187#define T_IPEP                  T_IPV4EP
     188#define API_PROTO               API_PROTO_IPV4
    183189
    184 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
     190#define IN_COPY_TO_HOST         IN4_COPY_TO_HOST
    185191
    186                 error = rel_wai(cep->snd_tskid);
    187                 cep->snd_tskid = TA_NULL;
    188                 }
    189         else                                    /* どちらでもないならペンディングしていない */
    190                 error = EV_NOPND;
     192#include <netinet/udpn_usrreq_nblk.c>
    191193
    192         return error;
    193         }
    194 
    195 #endif  /* of #ifdef __udp_can_snd */
    196 
    197 #ifdef __udp_can_rcv
    198 
    199 /*
    200  *  udp_can_rcv -- ペンディングしている受信のキャンセル
    201  */
    202 
    203 ER
    204 udp_can_rcv (T_UDP_CEP *cep, ER error)
    205 {
    206         if (cep->rcv_p_dstaddr != NULL) {       /* ノンブロッキングコールでペンディング中 */
    207                 if (IS_PTR_DEFINED(cep->callback))
    208 
    209 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    210 
    211                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
    212 
    213 #else   /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    214 
    215                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
    216 
    217 #endif  /* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
    218 
    219                 else
    220                         error = E_OBJ;
    221                 cep->rcv_p_dstaddr = NULL;
    222                 }
    223         else if (cep->rcv_tskid != TA_NULL) {   /* 非ノンブロッキングコールでペンディング中 */
    224 
    225 #ifdef UDP_CFG_EXTENTIONS
    226 
    227                 /* 待ち中に発生したエラー情報を設定する。*/
    228                 cep->error = error;
    229 
    230 #endif  /* of #ifdef UDP_CFG_EXTENTIONS */
    231 
    232                 error = rel_wai(cep->rcv_tskid);
    233                 cep->rcv_tskid = TA_NULL;
    234                 }
    235         else                                    /* どちらでもないならペンディングしていない */
    236                 error = EV_NOPND;
    237 
    238         return error;
    239         }
    240 
    241 #endif  /* of #ifdef __udp_can_rcv */
    242 
    243 #ifdef __udp_snd_dat
    244 
    245 /*
    246  *  udp_snd_dat -- パケットの送信【標準機能】
    247  */
    248 
    249 ER_UINT
    250 UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
    251 {
    252         T_UDP_CEP       *cep;
    253         ER              error;
    254 
    255         /* p_dstaddr または data が NULL ならエラー */
    256         if (p_dstaddr == NULL || data == NULL)
    257                 return E_PAR;
    258 
    259         /* データ長をチェックする。*/
    260         if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
    261                 return E_PAR;
    262 
    263         /* UDP 通信端点 ID をチェックする。*/
    264         if (!VALID_UDP_CEPID(cepid))
    265                 return E_ID;
    266 
    267         /* UDP 通信端点を得る。*/
    268         cep = GET_UDP_CEP(cepid);
    269 
    270         /* UDP 通信端点をチェックする。*/
    271         if (!VALID_UDP_CEP(cep))
    272                 return E_NOEXS;
    273 
    274         /*
    275          *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
    276          */
    277         if (cep->myaddr.portno == UDP_PORTANY) {
    278                 if ((error = udp_alloc_auto_port(cep)) != E_OK)
    279                         return error;
    280                 }
    281 
    282         /*
    283          * タイムアウトをチェックする。
    284          */
    285 
    286         if (tmout == TMO_NBLK) {        /* ノンブロッキングコール */
    287 
    288                 /* 通信端点をロックする。*/
    289                 syscall(wai_sem(cep->semid_lock));
    290 
    291                 if (cep->snd_p_dstaddr != NULL) {
    292 
    293                         /* ノンブロッキングコールでペンディング中 */
    294                         error = E_QOVR;
    295 
    296                         /* 通信端点をロックを解除する。*/
    297                         syscall(sig_sem(cep->semid_lock));
    298                         }
    299                 else if (cep->snd_tskid != TA_NULL) {
    300 
    301                         /* 非ノンブロッキングコールでペンディング中 */
    302                         error = E_OBJ;
    303 
    304                         /* 通信端点をロックを解除する。*/
    305                         syscall(sig_sem(cep->semid_lock));
    306                         }
    307                 else {
    308 
    309                         cep->snd_p_dstaddr = p_dstaddr;
    310                         cep->snd_data   = data;
    311                         cep->snd_len    = len;
    312 
    313                         /* 通信端点をロックを解除する。*/
    314                         syscall(sig_sem(cep->semid_lock));
    315 
    316                         cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
    317                         sig_sem(SEM_UDP_POST_OUTPUT);
    318                         error = E_WBLK;
    319                         }
    320                 }
    321         else {                          /* 非ノンブロッキングコール */
    322        
    323                 /* 通信端点をロックする。*/
    324                 syscall(wai_sem(cep->semid_lock));
    325 
    326                 if (cep->snd_p_dstaddr != NULL) {
    327 
    328                         /* ノンブロッキングコールでペンディング中 */
    329                         error = E_OBJ;
    330 
    331                         /* 通信端点をロックを解除する。*/
    332                         syscall(sig_sem(cep->semid_lock));
    333                         }
    334                 else if (cep->snd_tskid != TA_NULL) {
    335 
    336                         /* 非ノンブロッキングコールでペンディング中 */
    337                         error = E_QOVR;
    338 
    339                         /* 通信端点をロックを解除する。*/
    340                         syscall(sig_sem(cep->semid_lock));
    341                         }
    342                 else {
    343 
    344                         /* 現在のタスク識別子を記録する。*/
    345                         get_tid(&(cep->snd_tskid));
    346 
    347                         /* 通信端点をロックを解除する。*/
    348                         syscall(sig_sem(cep->semid_lock));
    349 
    350                         /* パケットを送信する。*/
    351                         error = udp_send_data(cep, p_dstaddr, data, len, tmout);
    352                         }
    353                 }
    354 
    355         return error;
    356         }
    357 
    358 #endif  /* of #ifdef __udp_snd_dat */
    359 
    360 #ifdef __udp_rcv_dat
    361 
    362 /*
    363  *  udp_rcv_dat -- パケットの受信【標準機能】
    364  */
    365 
    366 ER_UINT
    367 UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
    368 {
    369         T_NET_BUF       *input;
    370         T_UDP_CEP       *cep;
    371         T_UDP_HDR       *udph;
    372         ER_UINT         error;
    373         uint_t          ulen, uhoff;
    374 
    375         /* p_dstaddr または data が NULL か、len < 0 ならエラー */
    376         if (p_dstaddr == NULL || data == NULL || len < 0)
    377                 return E_PAR;
    378 
    379         /* UDP 通信端点 ID をチェックする。*/
    380         if (!VALID_UDP_CEPID(cepid))
    381                 return E_ID;
    382 
    383         /* UDP 通信端点を得る。*/
    384         cep = GET_UDP_CEP(cepid);
    385 
    386         /* UDP 通信端点をチェックする。*/
    387         if (!VALID_UDP_CEP(cep))
    388                 return E_NOEXS;
    389 
    390         /*
    391          * タイムアウトをチェックする。
    392          */
    393 
    394         if (tmout == TMO_NBLK) {        /* ノンブロッキングコール */
    395 
    396                 /* 通信端点をロックする。*/
    397                 syscall(wai_sem(cep->semid_lock));
    398 
    399                 if (cep->rcv_p_dstaddr != NULL)
    400 
    401                         /* ノンブロッキングコールでペンディング中 */
    402                         error = E_QOVR;
    403 
    404                 else if (cep->rcv_tskid != TA_NULL)
    405 
    406                         /* 非ノンブロッキングコールでペンディング中 */
    407                         error = E_OBJ;
    408                 else {
    409                         cep->rcv_p_dstaddr = p_dstaddr;
    410                         cep->rcv_data   = data;
    411                         cep->rcv_len    = len;
    412                         error = E_WBLK;
    413                         }
    414 
    415                 /* 通信端点をロックを解除する。*/
    416                 syscall(sig_sem(cep->semid_lock));
    417                 return error;
    418                 }
    419         else {                          /* 非ノンブロッキングコール */
    420 
    421                 /* 通信端点をロックする。*/
    422                 syscall(wai_sem(cep->semid_lock));
    423 
    424                 if (cep->rcv_p_dstaddr != NULL) {
    425 
    426                         /* ノンブロッキングコールでペンディング中 */
    427                         error = E_OBJ;
    428 
    429                         /* 通信端点をロックを解除する。*/
    430                         syscall(sig_sem(cep->semid_lock));
    431                         }
    432                 else if (cep->rcv_tskid != TA_NULL) {
    433 
    434                         /* 非ノンブロッキングコールでペンディング中 */
    435                         error = E_QOVR;
    436 
    437                         /* 通信端点をロックを解除する。*/
    438                         syscall(sig_sem(cep->semid_lock));
    439                         }
    440                 else {
    441 
    442                         /* 現在のタスク識別子を記録する。*/
    443                         get_tid(&(cep->rcv_tskid));
    444 
    445                         /* 通信端点をロックを解除する。*/
    446                         syscall(sig_sem(cep->semid_lock));
    447 
    448                         /* 入力があるまで待つ。*/
    449                         if (cep->cb_netbuf != NULL) {
    450 
    451                                 /*
    452                                  *  ここにくる場合は、コールバック関数の中から
    453                                  *  udp_rcv_dat を呼び出していることになり、
    454                                  *  すでに入力済みである。
    455                                  */
    456                                 input = cep->cb_netbuf;
    457                                 cep->cb_netbuf = NULL;
    458                                 }
    459                         else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
    460                                 cep->rcv_tskid = TA_NULL;
    461                                 return error;
    462                                 }
    463 
    464                         /* p_dstaddr を設定する。*/
    465                         uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
    466                         udph = GET_UDP_HDR(input, uhoff);
    467                         p_dstaddr->portno = ntohs(udph->sport);
    468                         IN_COPY_TO_HOST(&p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
    469 
    470                         /* データをバッファに移す。*/
    471                         ulen = ntohs(udph->ulen);
    472                         if (ulen - UDP_HDR_SIZE > len)
    473                                 error = E_BOVR;
    474                         else {
    475                                 len   =     (int_t)(ulen - UDP_HDR_SIZE);
    476                                 error = (ER_UINT)(ulen - UDP_HDR_SIZE);
    477                                 }
    478 
    479                         memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
    480 
    481                         syscall(rel_net_buf(input));
    482 
    483                         cep->rcv_tskid = TA_NULL;
    484                         }
    485                 return error;
    486                 }
    487         }
    488 
    489 #endif  /* of #ifdef __udp_rcv_dat */
     194#endif  /* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
    490195
    491196#endif  /* of #ifdef UDP_CFG_NON_BLOCKING */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h

    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 *
     
    7575 */
    7676
    77 #define IP_UDP_HDR_SIZE                 (IP_HDR_SIZE + UDP_HDR_SIZE)
    78 #define IF_IP_UDP_HDR_SIZE              (IF_IP_HDR_SIZE + UDP_HDR_SIZE)
    79 #define IF_IP_UDP_HDR_OFFSET            (IF_IP_HDR_SIZE)
    80 
    8177#define GET_UDP_HDR(nbuf,uhoff)         ((T_UDP_HDR*)((uint8_t*)((nbuf)->buf) + uhoff))
     78#define GET_UDP_HDR_OFFSET(nbuf)        (GET_IF_IP_HDR_SIZE(nbuf))
    8279#define GET_UDP_SDU(nbuf,uhoff)         ((uint8_t*)((nbuf)->buf) + uhoff+ UDP_HDR_SIZE)
    8380
    84 #define GET_UDP_HDR_OFFSET(nbuf)        (GET_IF_IP_HDR_SIZE(nbuf))
    85 
    86 #define GET_IP_UDP_HDR_SIZE(nbuf)       (GET_IP_HDR_SIZE(GET_IP_HDR(nbuf)) + UDP_HDR_SIZE)
    87 #define GET_IF_IP_UDP_HDR_SIZE(nbuf)    (IF_HDR_SIZE + GET_IP_UDP_HDR_SIZE(nbuf))
     81#define IF_IP_UDP_HDR_SIZE(nbuf)        (IF_IP_HDR_SIZE(nbuf) + UDP_HDR_SIZE)
     82#define IF_IP_UDP_HDR_OFFSET(nbuf)      (IF_IP_HDR_SIZE(nbuf))
    8883
    8984/*
     
    9186 */
    9287
    93 #if defined(SUPPORT_INET4)
     88#if defined(_IP4_CFG)
    9489
    9590#define IP4_UDP_HDR_SIZE                IP_UDP_HDR_SIZE
     
    9893#define GET_IF_IP4_UDP_HDR_SIZE(nbuf)   GET_IF_IP_UDP_HDR_SIZE(nbuf)
    9994
    100 #endif  /* of #if defined(SUPPORT_INET4) */
     95#endif  /* of #if defined(_IP4_CFG) */
    10196
    10297/*
     
    110105 */
    111106
    112 
    113 /*
    114  *  IPv4 UDP 通信端点
    115  */
    116 typedef struct t_udp4_cep {
     107/* IPv6 用 UDP 通信端点 */
     108
     109typedef struct t_udp6_cep {
    117110
    118111        /*
     
    120113         */
    121114        ATR             cepatr;         /* UDP 通信端点属性           */
    122         T_IPV4EP        myaddr;         /* 自分のアドレス              */
     115        T_IPV6EP        myaddr;         /* 自分のアドレス              */
    123116        t_udp_callback  callback;       /* コールバック関数             */
    124117
     
    135128#ifdef UDP_CFG_NON_BLOCKING
    136129
    137         T_IPV4EP        *snd_p_dstaddr; /* 送信相手のアドレスへのポインタ*/
    138         T_IPV4EP        *rcv_p_dstaddr; /* 受信相手のアドレスへのポインタ*/
     130        T_IPV6EP        *snd_p_dstaddr; /* 送信相手のアドレスへのポインタ*/
     131        T_IPV6EP        *rcv_p_dstaddr; /* 受信相手のアドレスへのポインタ*/
    139132        void            *snd_data;      /* 送信データ領域の先頭アドレス       */
    140133        int_t           snd_len;        /* 送信データ領域の長さ           */
     
    148141#endif
    149142
    150         } T_UDP4_CEP;
    151 
    152 #if defined(SUPPORT_INET4)
    153 #define T_UDP_CEP       T_UDP4_CEP
    154 #endif
    155 
    156 /*
    157  *  IPv6 UDP 通信端点
    158  */
    159 
    160 typedef struct t_udp6_cep {
     143        } T_UDP6_CEP;
     144
     145/* IPv4 用 UDP 通信端点 */
     146
     147typedef struct t_udp4_cep {
    161148
    162149        /*
     
    164151         */
    165152        ATR             cepatr;         /* UDP 通信端点属性           */
    166         T_IPV6EP        myaddr;         /* 自分のアドレス              */
     153        T_IPV4EP        myaddr;         /* 自分のアドレス              */
    167154        t_udp_callback  callback;       /* コールバック関数             */
    168155
     
    179166#ifdef UDP_CFG_NON_BLOCKING
    180167
    181         T_IPV6EP        *snd_p_dstaddr; /* 送信相手のアドレスへのポインタ*/
    182         T_IPV6EP        *rcv_p_dstaddr; /* 受信相手のアドレスへのポインタ*/
     168        T_IPV4EP        *snd_p_dstaddr; /* 送信相手のアドレスへのポインタ*/
     169        T_IPV4EP        *rcv_p_dstaddr; /* 受信相手のアドレスへのポインタ*/
    183170        void            *snd_data;      /* 送信データ領域の先頭アドレス       */
    184171        int_t           snd_len;        /* 送信データ領域の長さ           */
     
    191178        ER              error;          /* 待ち中に発生したエラー  */
    192179#endif
    193 
    194         } T_UDP6_CEP;
    195 
    196 #if defined(SUPPORT_INET6)
     180#ifdef SUPPORT_IGMP
     181        bool_t igmp_loopback;
     182        uint8_t igmp_ttl;
     183        T_IN4_ADDR      igmp_mcaddr;    /*  */
     184#endif
     185        } T_UDP4_CEP;
     186
     187#if defined(_IP6_CFG)
     188
    197189#define T_UDP_CEP       T_UDP6_CEP
    198 #endif
     190
     191#else   /* of #if defined(_IP6_CFG) */
     192
     193#if defined(_IP4_CFG)
     194
     195#define T_UDP_CEP       T_UDP4_CEP
     196
     197#endif  /* of #if defined(_IP4_CFG) */
     198
     199#endif  /* of #if defined(_IP6_CFG) */
    199200
    200201/*
     
    210211 */
    211212
    212 #define TMIN_UDP_CEPID          1       /* UDP 通信端点 ID の最小値 */
    213 
    214 #ifdef SUPPORT_MIB
     213#define TMIN_UDP_CEPID          1                       /* UDP      通信端点 ID の最小値 */
     214#define TMIN_UDP6_CEPID         1                       /* UDP/IPv6 通信端点 ID の最小値 */
     215#define TMIN_UDP4_CEPID         (TNUM_UDP6_CEPID+1)     /* UDP/IPv4 通信端点 ID の最小値 */
    215216
    216217/*
     
    225226} T_UDP_STATS;
    226227
    227 #endif  /* of #ifdef SUPPORT_MIB */
    228 
    229228/*
    230229 *  関数シミュレーションマクロ
    231230 */
    232231
    233 #define VALID_UDP_CEPID(id)     (TMIN_UDP_CEPID<=(id)&&(id)<=tmax_udp_cepid)
    234 
    235 #define INDEX_UDP_CEP(id)       ((id)-TMIN_UDP_CEPID)
    236 
    237 #define GET_UDP_CEP(id)         (&(udp_cep[INDEX_UDP_CEP(id)]))
    238 
    239 #define GET_UDP_CEPID(cep)      ((ID)(((cep)-udp_cep)+TMIN_UDP_CEPID))
     232#define VALID_UDP6_CEPID(id)    (TMIN_UDP6_CEPID<=(id)&&(id)<=tmax_udp6_cepid)
     233#define VALID_UDP4_CEPID(id)    (TMIN_UDP4_CEPID<=(id)&&(id)<=tmax_udp4_cepid)
     234
     235#define INDEX_UDP6_CEP(id)      ((id)-TMIN_UDP6_CEPID)
     236#define INDEX_UDP4_CEP(id)      ((id)-TMIN_UDP4_CEPID)
     237
     238#define GET_UDP6_CEP(id)        (&(udp6_cep[INDEX_UDP6_CEP(id)]))
     239#define GET_UDP4_CEP(id)        (&(udp4_cep[INDEX_UDP4_CEP(id)]))
     240
     241#define GET_UDP6_CEPID(cep)     ((ID)(((cep)-udp6_cep)+TMIN_UDP6_CEPID))
     242#define GET_UDP4_CEPID(cep)     ((ID)(((cep)-udp4_cep)+TMIN_UDP4_CEPID))
    240243
    241244#define VALID_TFN_UDP_CAN(t)    ((t)==TFN_UDP_SND_DAT||(t)==TFN_UDP_RCV_DAT||\
     
    249252 */
    250253
    251 extern T_UDP_CEP udp_cep[];
     254extern T_UDP_STATS udp_stats;
     255
     256/* UDP 通信端点 */
     257
     258extern T_UDP6_CEP udp6_cep[];
     259extern T_UDP4_CEP udp4_cep[];
     260
     261#if defined(SUPPORT_INET6)
     262#define udp_cep udp6_cep
     263#elif defined(SUPPORT_INET4)
     264#define udp_cep udp4_cep
     265#endif
     266
    252267extern const ID tmax_udp_cepid;
    253268
    254 #ifdef SUPPORT_MIB
    255 
    256 extern T_UDP_STATS udp_stats;
    257 
    258 #endif  /* of #ifdef SUPPORT_MIB */
     269#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     270extern const ID tmax_udp6_cepid;
     271extern const ID tmax_udp4_cepid;
     272#else
     273#define tmax_udp6_cepid tmax_udp_cepid
     274#define tmax_udp4_cepid tmax_udp_cepid
     275#endif
    259276
    260277/*
     
    269286 */
    270287
    271 extern uint_t udp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
    272 extern ER_UINT udp_send_data (T_UDP_CEP *cep, T_IPEP *p_dstaddr,
    273                               void *data, int_t len, TMO tmout);
    274 extern ER udp_can_snd (T_UDP_CEP *cep, ER error);
    275 extern ER udp_can_rcv (T_UDP_CEP *cep, ER error);
    276 extern ER udp_alloc_auto_port (T_UDP_CEP *cep);
    277 extern ER udp_alloc_port (T_UDP_CEP *cep, uint16_t portno);
     288/* IPv6 */
     289
     290extern uint_t udp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
     291extern ER_UINT udp6_send_data (T_UDP6_CEP *cep, T_IPV6EP *p_dstaddr,
     292                               void *data, int_t len, TMO tmout);
     293extern ER udp6_can_snd (T_UDP6_CEP *cep, ER error);
     294extern ER udp6_can_rcv (T_UDP6_CEP *cep, ER error);
     295extern ER udp6_alloc_auto_port (T_UDP6_CEP *cep);
     296extern ER udp6_alloc_port (T_UDP6_CEP *cep, uint16_t portno);
     297extern T_UDP6_CEP*udp6_find_cep (T_NET_BUF *input, uint_t off);
     298extern void udp6_notify (T_NET_BUF *input, ER error);
     299extern void udp6_input_select (T_UDP6_CEP *cep, T_NET_BUF *input, uint_t off);
     300
     301/* IPv4 */
     302
     303extern uint_t udp4_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
     304extern ER_UINT udp4_send_data (T_UDP4_CEP *cep, T_IPV4EP *p_dstaddr,
     305                               void *data, int_t len, TMO tmout);
     306extern ER udp4_can_snd (T_UDP4_CEP *cep, ER error);
     307extern ER udp4_can_rcv (T_UDP4_CEP *cep, ER error);
     308extern ER udp4_alloc_auto_port (T_UDP4_CEP *cep);
     309extern ER udp4_alloc_port (T_UDP4_CEP *cep, uint16_t portno);
     310extern T_UDP4_CEP*udp4_find_cep (T_NET_BUF *input, uint_t off);
     311extern void udp4_notify (T_NET_BUF *input, ER error);
     312extern void udp4_input_select (T_UDP4_CEP *cep, T_NET_BUF *input, uint_t off);
    278313
    279314/* ノンブロッキングコールを行う場合に組み込むタスク */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h

    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 *
     
    6767#define _AH_H_
    6868
    69 #ifdef SUPPORT_INET6
    70 
    7169/*
    7270 *  RFC2402 認証ヘッダ
     
    8078        uint32_t        spi;    /* Security Parameter Index (SPI)       */
    8179        uint32_t        seq;    /* シーケンス番号                      */
    82         } __attribute__((packed, aligned(2)))T_IP6_AH_HDR;
    83 
    84 #endif  /* of #ifdef SUPPORT_INET6 */
     80        } __attribute__((packed, aligned(2))) T_IP6_AH_HDR;
    8581
    8682#endif  /* of #ifndef _AH_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h

    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 *
     
    6767#define _AH6_H_
    6868
    69 #ifdef SUPPORT_INET6
    70 
    7169/*
    7270 *  関数
     
    7573extern uint_t ah6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
    7674
    77 #endif  /* of #ifdef SUPPORT_INET6 */
    78 
    7975#endif  /* of #ifndef _AH6_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.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 *
     
    8282
    8383#include <net/net.h>
     84#include <net/net_endian.h>
    8485#include <net/if.h>
    8586#include <net/if_loop.h>
     
    9293
    9394#include <netinet/in.h>
    94 #include <netinet6/in6.h>
    95 #include <netinet6/in6_var.h>
     95#include <netinet/in_var.h>
     96#include <netinet/ip.h>
     97#include <netinet/ip_var.h>
     98#include <netinet/ip_icmp.h>
    9699#include <netinet6/nd6.h>
    97 #include <netinet/ip6.h>
    98 #include <netinet6/ip6_var.h>
    99 #include <netinet/icmp6.h>
    100100#include <netinet6/ah.h>
    101101#include <netinet6/ah6.h>
    102102
    103 #ifdef SUPPORT_INET6
     103#ifdef _IP6_CFG
    104104
    105105/*
     
    116116        }
    117117
    118 #endif /* of #ifdef SUPPORT_INET6 */
     118#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.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 *
     
    8888#include <net/ppp_ipcp.h>
    8989#include <net/net.h>
     90#include <net/net_endian.h>
    9091#include <net/net_buf.h>
    9192#include <net/net_count.h>
    9293
    9394#include <netinet/in.h>
    94 #include <netinet6/in6.h>
    95 #include <netinet6/in6_var.h>
     95#include <netinet/in_var.h>
     96#include <netinet/ip.h>
     97#include <netinet/ip_var.h>
     98#include <netinet/ip_icmp.h>
    9699#include <netinet6/nd6.h>
    97 #include <netinet/ip6.h>
    98 #include <netinet6/ip6_var.h>
    99 #include <netinet/icmp6.h>
    100100
    101 #ifdef SUPPORT_INET6
     101#ifdef _IP6_CFG
    102102
    103103/*
     
    163163        }
    164164
    165 #endif /* of #ifdef SUPPORT_INET6 */
     165#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h

    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 *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
     
    6868#define _ESP_H_
    6969
    70 #if defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC)
    71 
    7270/*
    7371 *  RFC2406 暗号化ヘッダ
     
    129127#endif  /* of #ifdef T_IPSEC_REQUEST_DEFINED */
    130128
    131 #endif /* defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC) */
    132 
    133129#endif  /* of #ifndef _ESP_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h

    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 *
     
    6767#define _ESP6_H_
    6868
    69 #ifdef SUPPORT_INET6
    70 
    7169/*
    7270 *  関数
     
    7573extern uint_t esp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
    7674
    77 #endif  /* of #ifdef SUPPORT_INET6 */
    78 
    7975#endif  /* of #ifndef _ESP6_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.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 *
     
    8888#include <net/ppp_ipcp.h>
    8989#include <net/net.h>
     90#include <net/net_endian.h>
    9091#include <net/net_buf.h>
    9192#include <net/net_count.h>
    9293
    9394#include <netinet/in.h>
    94 #include <netinet6/in6.h>
    95 #include <netinet6/in6_var.h>
     95#include <netinet/in_var.h>
     96#include <netinet/ip.h>
     97#include <netinet/ip_var.h>
     98#include <netinet/ip_icmp.h>
    9699#include <netinet6/nd6.h>
    97 #include <netinet/ip6.h>
    98 #include <netinet6/ip6_var.h>
    99 #include <netinet/icmp6.h>
    100100#include <netinet6/ah.h>
    101101#include <netinet6/ah6.h>
     
    103103#include <netinet6/esp6.h>
    104104
    105 #ifdef SUPPORT_INET6
     105#ifdef _IP6_CFG
    106106
    107107/*
     
    122122        }
    123123
    124 #endif /* of #ifdef SUPPORT_INET6 */
     124#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.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 *
     
    9292#include <net/ppp_ipcp.h>
    9393#include <net/net.h>
     94#include <net/net_endian.h>
    9495#include <net/net_buf.h>
    9596#include <net/net_var.h>
     
    9798
    9899#include <netinet/in.h>
    99 #include <netinet6/in6.h>
    100 #include <netinet6/in6_var.h>
     100#include <netinet/in_var.h>
     101#include <netinet/ip.h>
     102#include <netinet/ip_var.h>
     103#include <netinet/ip_icmp.h>
    101104#include <netinet6/nd6.h>
    102 #include <netinet/ip6.h>
    103 #include <netinet6/ip6_var.h>
    104 #include <netinet/icmp6.h>
    105 
    106 #ifdef SUPPORT_INET6
     105
     106#ifdef _IP6_CFG
    107107
    108108#ifdef IP6_CFG_FRAGMENT
     
    606606                        /* 送信先アドレスを元に戻す。*/
    607607                        ip6h = GET_IP6_HDR(input);
    608                         ip6h->dst = ip6_frag_dest[ip6fq - ip6_frag_queue];
     608                        memcpy(&ip6h->dst, &ip6_frag_dest[ip6fq - ip6_frag_queue], sizeof(T_IN6_ADDR));
    609609
    610610                        /* offp を、再構成した断片の先頭に設定する。*/
     
    669669        }
    670670
    671 #endif /* of #ifdef SUPPORT_INET6 */
     671#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.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 *
     
    106106#include <sil.h>
    107107#include <t_syslog.h>
     108#include "tinet_cfg.h"
    108109
    109110#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    113114#include <s_services.h>
    114115#include <t_services.h>
     116#include "tinet_id.h"
    115117
    116118#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    124126#include <net/ethernet.h>
    125127#include <net/net.h>
     128#include <net/net_endian.h>
    126129#include <net/net_buf.h>
    127130#include <net/net_timer.h>
     
    130133#include <netinet/in.h>
    131134#include <netinet/in_var.h>
    132 #include <netinet6/in6.h>
    133 #include <netinet6/in6_var.h>
    134 #include <netinet/ip6.h>
    135 #include <netinet6/ip6_var.h>
    136 #include <netinet/icmp6.h>
     135#include <netinet/ip.h>
     136#include <netinet/ip_var.h>
     137#include <netinet/ip_icmp.h>
     138#include <netinet/tcp.h>
     139#include <netinet/tcp_var.h>
     140#include <netinet/udp_var.h>
     141
    137142#include <netinet6/nd6.h>
    138 #include <netinet/tcp.h>
    139 #include <netinet/tcp_timer.h>
    140 #include <netinet/tcp_var.h>
    141 
    142 #ifdef SUPPORT_INET6
     143
     144#ifdef _IP6_CFG
    143145
    144146/*
     
    178180                return;
    179181                }
    180         ip6h->src = ia->addr;
     182        memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
    181183
    182184        icmp6h = GET_ICMP6_HDR(output, off);
     
    241243
    242244        /* IPv6 ヘッダの発信元アドレスと宛先アドレスを入替える。*/
    243         dst       = ip6h->dst;
    244         ip6h->dst = ip6h->src;
    245         ip6h->src = dst;
     245        memcpy(&dst, &ip6h->dst, sizeof(T_IN6_ADDR));
     246        memcpy(&ip6h->dst, &ip6h->src, sizeof(T_IN6_ADDR));
     247        memcpy(&ip6h->src, &dst, sizeof(T_IN6_ADDR));
    246248
    247249        /*
     
    256258                        }
    257259                else
    258                         ip6h->src = ia->addr;
     260                        memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
    259261                }
    260262
    261263        /* 次ヘッダとホップリミットを設定する。*/
    262264        ip6h->next = IPPROTO_ICMPV6;
    263         ip6h->hlim = IP_DEFTTL;
     265        ip6h->hlim = IP6_DEFTTL;
    264266
    265267        /* チェックサムを計算する。*/
     
    299301        loff = ip6_lasthdr(input, poff + ICMP6_HDR_SIZE, IPPROTO_IPV6, &next);
    300302
    301         /* 最終ヘッダが TCP のみ対応する。*/
    302         if (loff >= 0 && next == IPPROTO_TCP) {
    303 
    304 #ifdef SUPPORT_TCP
     303        /* 最終ヘッダが TCP/UDP のみ対応する。*/
     304        if (loff >= 0 && (next == IPPROTO_TCP || next == IPPROTO_UDP)) {
    305305
    306306                memcpy(GET_IP6_HDR(input), input->buf + (loff + ICMP6_HDR_SIZE),
    307307                                           input->len - (loff + ICMP6_HDR_SIZE));
    308308                input->len -= loff + ICMP6_HDR_SIZE;
    309                 tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
    310 
    311 #endif  /* of #ifdef SUPPORT_TCP */
     309
     310#if defined(SUPPORT_TCP)
     311
     312                if (next == IPPROTO_TCP)
     313
     314                        tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
     315
     316#endif  /* of #if defined(SUPPORT_TCP) */
     317
     318#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
     319
     320                if (next == IPPROTO_UDP)
     321
     322                        udp6_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
     323
     324#endif  /* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
    312325
    313326                }
     
    340353#endif  /* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
    341354
    342 #if NUM_REDIRECT_ROUTE_ENTRY > 0
     355#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
     356#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
    343357
    344358/*
     
    350364{
    351365        T_IP6_HDR               *ip6h;
    352         T_IN6_ADDR              *gw;
     366        const T_IN6_ADDR        *gw;
    353367        T_ND_REDIRECT_HDR       *rdh;
    354368        T_ND_OPT_HDR            *opth;
     
    440454        }
    441455
    442 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     456#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
     457#endif  /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
    443458
    444459/*
     
    472487
    473488        /* チェックサムを計算する。*/
    474         if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP_HDR_SIZE)) & 0xffff) != 0) {
     489        if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE)) & 0xffff) != 0) {
    475490                NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
    476491                NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
     
    530545                NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRedirects, 1);
    531546
    532 #if NUM_REDIRECT_ROUTE_ENTRY > 0
     547#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
     548#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
    533549
    534550                if (code != 0 || len < ND_REDIRECT_HDR_SIZE)
     
    537553                return IPPROTO_DONE;
    538554
    539 #else   /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     555#else   /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
    540556
    541557                syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
    542558
    543 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     559#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
     560#else   /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
     561
     562                syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
     563
     564#endif  /* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
    544565
    545566                break;
     
    571592        case ICMP6_FQDN_QUERY:                  /* FQDN 照会                      */
    572593        case ICMP6_FQDN_REPLY:                  /* FQDN 応答                      */
    573                 syslog(LOG_WARNING, "[ICMP6] unsupported type: %d.", icmp6h->type);
     594                syslog(LOG_INFO, "[ICMP6] unsupported type: %d.", icmp6h->type);
    574595                break;
    575596
     
    693714        }
    694715
    695 #endif /* of #ifdef SUPPORT_INET6 */
     716#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.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 *
     
    8787#include <net/if_arp.h>
    8888#include <net/net.h>
     89#include <net/net_endian.h>
    8990#include <net/net_timer.h>
    9091#include <net/net_buf.h>
     
    9293
    9394#include <netinet/in.h>
     95#include <netinet/in_var.h>
    9496#include <netinet/ip.h>
    9597#include <netinet/if_ether.h>
     
    98100#include <netinet6/in6_var.h>
    99101
    100 #include <net/if6_var.h>
     102#include <net/if_var.h>
    101103
    102 #if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER)
     104#if defined(_IP6_CFG) && defined(SUPPORT_ETHER)
    103105
    104106/*
     
    107109
    108110void
    109 ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr)
     111ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr)
    110112{
    111113        eaddr->lladdr[0] = UINT_C(0x33);
     
    117119        }
    118120
    119 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER) */
     121#endif /* of #if defined(_IP6_CFG) && defined(SUPPORT_ETHER) */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h

    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 *
     
    6868#define _IF6_ETHER_H_
    6969
    70 #ifdef SUPPORT_INET6
    71 
    7270/*
    7371 *  関数
    7472 */
    7573
    76 extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr);
    77 
    78 #endif  /* of #ifdef SUPPORT_INET6 */
     74extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr);
    7975
    8076#endif  /* of #ifndef _IF6_ETHER_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.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 *
     
    126126#include <net/ppp_ipcp.h>
    127127#include <net/net.h>
     128#include <net/net_endian.h>
    128129#include <net/net_buf.h>
    129130#include <net/net_timer.h>
    130131#include <net/net_count.h>
     132
     133#include <netinet/in.h>
     134#include <netinet/in_var.h>
    131135
    132136#include <netinet6/in6.h>
     
    135139#include <netinet6/in6_ifattach.h>
    136140
    137 #include <net/if6_var.h>
    138 
    139 #ifdef SUPPORT_INET6
     141#include <net/if_var.h>
     142
     143#ifdef _IP6_CFG
    140144
    141145/*
     
    143147 */
    144148
    145 T_IN6_ADDR in6_addr_unspecified =
     149const T_IN6_ADDR in6_addr_unspecified =
    146150        IPV6_ADDR_UNSPECIFIED_INIT;
    147151
    148 T_IN6_ADDR in6_addr_linklocal_allnodes =
     152const T_IN6_ADDR in6_addr_linklocal_allnodes =
    149153        IPV6_ADDR_LINKLOCAL_ALLNODES_INIT;
    150154
    151 T_IN6_ADDR in6_addr_linklocal_allrouters =
     155const T_IN6_ADDR in6_addr_linklocal_allrouters =
    152156        IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT;
    153157
     
    172176
    173177static ER
    174 in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr, uint_t prefix_len)
     178in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr, uint_t prefix_len)
    175179{
    176180        /* アドレスとプレフィックス長を設定する。*/
     
    200204
    201205        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    202                 ia = &ifp->in_ifaddrs[ix];
     206                ia = &ifp->in6_ifaddrs[ix];
    203207                memset(ia, sizeof(T_IN6_IFADDR), 0);
    204208                ia->router_index = IN6_RTR_IX_UNREACH;
     
    226230
    227231int_t
    228 in6_addr2ifaix (T_IN6_ADDR *addr)
     232in6_addr2ifaix (const T_IN6_ADDR *addr)
    229233{
    230234        T_IFNET         *ifp = IF_GET_IFNET();
     
    233237
    234238        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    235                 ia = &ifp->in_ifaddrs[ix];
     239                ia = &ifp->in6_ifaddrs[ix];
    236240                if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
    237241                    in6_are_prefix_equal(addr, &ia->addr, ia->prefix_len))
     
    247251
    248252int_t
    249 in6_addr2maix (T_IN6_ADDR *addr)
     253in6_addr2maix (const T_IN6_ADDR *addr)
    250254{
    251255        if (addr->s6_addr8[0] == 0xff) {
     
    268272
    269273ER
    270 in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
     274in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
    271275                uint_t prefix_len, uint32_t vltime, uint32_t pltime,
    272276                int_t router_index, int_t prefix_index, uint_t flags)
     
    365369in6ifa_ifpwithix (T_IFNET *ifp, int_t ix)
    366370{
    367         return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in_ifaddrs[ix] : NULL;
     371        return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in6_ifaddrs[ix] : NULL;
    368372        }
    369373
     
    379383
    380384        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
    381                 if (ifp->in_ifaddrs[ix].router_index == router_index)
    382                         return &ifp->in_ifaddrs[ix];
     385                if (ifp->in6_ifaddrs[ix].router_index == router_index)
     386                        return &ifp->in6_ifaddrs[ix];
    383387        return NULL;
    384388        }
    385389
    386390/*
    387  * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレスを、
     391 * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレス情報を、
    388392 *                   ネットワークインタフェースから探索する。
    389393 */
    390394
    391395T_IN6_IFADDR *
    392 in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst)
     396in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst)
    393397{
    394398        uint_t  scope;
     
    397401        /* 宛先アドレスと同じスコープのアドレスを返す。*/
    398402        if ((ix = in6_addr2ifaix(dst)) != IPV6_IFADDR_IX_INVALID)
    399                 return &ifp->in_ifaddrs[ix];
     403                return &ifp->in6_ifaddrs[ix];
    400404        else if ((ix = in6_addr2maix(dst)) == IPV6_MADDR_IX_SOL_NODE ||
    401405                  ix                       == IPV6_MADDR_IX_LL_ALL_NODE)
    402                 return &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
     406                return &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
    403407        else {
    404408                scope = in6_addrscope(dst);
    405409                for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    406                         if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
    407                             (ifp->in_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
    408                             in6_addrscope(&ifp->in_ifaddrs[ix].addr) == scope) {
    409                                 return &ifp->in_ifaddrs[ix];
     410                        if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
     411                            (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
     412                            in6_addrscope(&ifp->in6_ifaddrs[ix].addr) == scope) {
     413                                return &ifp->in6_ifaddrs[ix];
    410414                                }
    411415                        }
    412416                return NULL;
     417                }
     418        }
     419
     420/*
     421 * in6_addrwithifp -- 宛先アドレスにふさわしい送信元アドレスを、
     422 *                    ネットワークインタフェースから探索する。
     423 */
     424
     425const T_IN6_ADDR *
     426in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst)
     427{
     428        T_IN6_IFADDR *ifaddr;
     429
     430        if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
     431                return NULL;
     432        else {
     433                *src = ifaddr->addr;
     434                return src;
    413435                }
    414436        }
     
    431453        dad_delay = 0;
    432454        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
    433                 if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
    434                     (ifp->in_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
    435                         nd6_dad_start(ifp, &ifp->in_ifaddrs[ix], &dad_delay);
     455                if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
     456                    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
     457                        nd6_dad_start(ifp, &ifp->in6_ifaddrs[ix], &dad_delay);
    436458#endif  /* of #if 0 */
    437459
     
    449471
    450472bool_t
    451 in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix, uint_t prefix_len)
     473in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix, uint_t prefix_len)
    452474{
    453475        uint_t bitlen, bytelen;
     
    478500        syscall(get_tim(&now));
    479501        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    480                 ia = &ifp->in_ifaddrs[ix];
     502                ia = &ifp->in6_ifaddrs[ix];
    481503
    482504                if ((ia->flags & IN6_IFF_DEFINED) == 0)
     
    500522        }
    501523
    502 #endif /* of #ifdef SUPPORT_INET6 */
     524#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h

    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 *
     
    103103
    104104/*
     105 *  IPv6 アドレス構造
     106 *
     107 *    RFC4291(RFC1884、RFC2373、RFC3513 のアップデート)
     108 */
     109
     110/*
    105111 *  IPv6 アドレス
    106112 */
     
    150156
    151157/*
    152  *  アドレスの定義
    153  */
    154 
    155 #ifdef _NET_CFG_BYTE_ORDER
    156 
    157 #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
    158 
    159 #define IPV6_ADDR_INT32_ONE             ULONG_C(0x00000001)
    160 #define IPV6_ADDR_INT32_TWO             ULONG_C(0x00000002)
    161 #define IPV6_ADDR_INT32_0000FFFF        ULONG_C(0x0000ffff)
    162 #define IPV6_ADDR_INT32_MNL             ULONG_C(0xff010000)
    163 #define IPV6_ADDR_INT32_MLL             ULONG_C(0xff020000)
    164 #define IPV6_ADDR_INT32_ULL             ULONG_C(0xfe800000)
    165 #define IPV6_ADDR_INT16_ULL             UINT_C(0xfe80)
    166 #define IPV6_ADDR_INT16_USL             UINT_C(0xfec0)
    167 #define IPV6_ADDR_INT16_MLL             UINT_C(0xff02)
    168 
    169 #elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
    170 
    171 #define IPV6_ADDR_INT32_ONE             ULONG_C(0x01000000)
    172 #define IPV6_ADDR_INT32_TWO             ULONG_C(0x02000000)
    173 #define IPV6_ADDR_INT32_0000FFFF        ULONG_C(0xffff0000)
    174 #define IPV6_ADDR_INT32_MNL             ULONG_C(0x000001ff)
    175 #define IPV6_ADDR_INT32_MLL             ULONG_C(0x000002ff)
    176 #define IPV6_ADDR_INT32_ULL             ULONG_C(0x000080fe)
    177 #define IPV6_ADDR_INT16_ULL             UINT_C(0x80fe)
    178 #define IPV6_ADDR_INT16_USL             UINT_C(0xc0fe)
    179 #define IPV6_ADDR_INT16_MLL             UINT_C(0x02ff)
    180 
    181 #endif  /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
    182 
    183 #endif  /* of #ifdef _NET_CFG_BYTE_ORDER */
    184 
    185 /*
    186158 *  特別なアドレスのチェック
    187159 */
     
    197169        (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
    198170         (a)->s6_addr8[15] == 0x01)
    199 
    200 /* IPv4 互換 */
    201 
    202 #define IN6_IS_ADDR_V4COMPAT(a)         \
    203         (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
    204          (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
    205 
    206 /* IPv4 マップ */
    207 
    208 #define IN6_IS_ADDR_V4MAPPED(a)         \
    209         (((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
    210          ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
    211          ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
    212171
    213172/*
     
    248207#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr8[0] == UINT_C(0xff))
    249208
    250 /* 要請マルチキャスト */
    251 
    252 #define IN6_IS_ADDR_NS_MULTICAST(a)     \
    253         (((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
    254          ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
    255          ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
    256          ((a)->s6_addr8[12] == UINT_C(0xff)))
    257 
    258209/*
    259210 *  同一のチェック
     
    272223 */
    273224
    274 #define IPV6_DEFAULT_MULTICAST_HOPS     1       /* マルチキャスト時のホップリミットの規定値 */
     225#define IPV6_DEFAULT_MULTICAST_HOPS     1       /* マルチキャスト時のホップリミットの規定値 */
     226#define ND6_INFINITE_LIFETIME           0xffffffff      /* アドレスの無制限有効時間         */
    275227
    276228/*
     
    282234        uint16_t        portno;         /* ポート番号        */
    283235        } T_IPV6EP;
     236
     237#define T_IPV6EP_DEFINED
    284238
    285239/*
     
    299253        /* 実装依存 */
    300254        } T_TCP6_CREP;
    301 
    302 #if defined(SUPPORT_INET6)
    303 #define T_TCP_CREP      T_TCP6_CREP
    304 #endif
    305255
    306256/*
     
    316266        } T_UDP6_CCEP;
    317267
    318 #if defined(SUPPORT_INET6)
    319 #define T_UDP_CCEP      T_UDP6_CCEP
    320 #endif
    321 
    322 /*
    323  *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
    324  */
    325 
    326 #if defined(SUPPORT_INET6)
    327 
    328 #define T_IN_ADDR                       T_IN6_ADDR
    329 #define T_IPEP                          T_IPV6EP
    330 #define IP_ADDRANY                      IPV6_ADDRANY
    331 
    332 #define IN_ARE_ADDR_EQUAL(n,h)          IN6_ARE_ADDR_EQUAL(n,h)
    333 #define IN_ARE_NET_ADDR_EQUAL(n,h)      IN6_ARE_ADDR_EQUAL(n,h)
    334 #define IN_COPY_TO_NET(d,s)             memcpy(d,s,sizeof(T_IN6_ADDR))
    335 #define IN_COPY_TO_HOST(d,s)            memcpy(d,s,sizeof(T_IN6_ADDR))
    336 #define IN_IS_ADDR_MULTICAST(a)         IN6_IS_ADDR_MULTICAST(a)
    337 #define IN_IS_NET_ADDR_MULTICAST(a)     IN6_IS_ADDR_MULTICAST(a)
    338 #define IN_IS_ADDR_ANY(a)               IN6_IS_ADDR_UNSPECIFIED(a)
    339 
    340 #endif  /* of #if defined(SUPPORT_INET6) */
    341 
    342268/*
    343269 *  前方参照
     
    356282 */
    357283
    358 extern T_IN6_ADDR in6_addr_unspecified;
    359 extern T_IN6_ADDR in6_addr_linklocal_allnodes;
    360 extern T_IN6_ADDR in6_addr_linklocal_allrouters;
     284extern const T_IN6_ADDR in6_addr_unspecified;
     285extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
     286extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
    361287
    362288#define ipv6_addrany    in6_addr_unspecified
     
    366292 */
    367293
    368 extern char *ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr);
    369 extern ER_UINT in6_get_maxnum_ifaddr (void);
     294extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
     295extern uint_t in6_get_maxnum_ifaddr (void);
    370296extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
     297extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
     298                          uint32_t vltime, uint32_t pltime);
     299extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
     300extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
     301extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
    371302
    372303#endif  /* of #ifndef _IN6_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.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 *
     
    8787#include <net/if_arp.h>
    8888#include <net/net.h>
     89#include <net/net_endian.h>
     90
     91#include <netinet/in.h>
     92#include <netinet/in_var.h>
    8993
    9094#include <netinet6/in6.h>
     
    9397#include <netinet6/in6_ifattach.h>
    9498
    95 #include <net/if6_var.h>
    96 
    97 #ifdef SUPPORT_INET6
     99#include <net/if_var.h>
     100
     101#ifdef _IP6_CFG
    98102
    99103/*
     
    126130#endif  /* of #ifdef SUPPORT_ETHER */
    127131
     132#ifdef SUPPORT_PPP
     133
     134/*
     135 * get_rand_ifid -- 乱数により、インタフェース識別子を設定する。
     136 */
     137
     138static ER
     139get_rand_ifid (T_IFNET *ifp, T_IN6_ADDR *ifra_addr)
     140{
     141        return E_OK;
     142        }
     143
     144#endif  /* of #ifdef SUPPORT_PPP */
     145
    128146#ifdef IP6_CFG_AUTO_LINKLOCAL
    129147
     
    149167
    150168        /* インタフェースのアドレス情報を更新する。*/
    151         if ((error = in6_update_ifa(ifp, &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
     169        if ((error = in6_update_ifa(ifp, &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
    152170                                    &addr, 64, ND6_INFINITE_LIFETIME,
    153171                                               ND6_INFINITE_LIFETIME,
     
    171189#ifdef IP6_CFG_AUTO_LINKLOCAL
    172190
    173         if ((ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
     191        if ((ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
    174192                if ((error = in6_ifattach_linklocal(ifp)) != E_OK)
    175193                        return error;
     
    180198        }
    181199
    182 #endif /* of #ifdef SUPPORT_INET6 */
     200#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h

    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 *
     
    4141/* netinet6/in6.c */
    4242
     43#define in6_are_prefix_equal    _tinet_in6_are_prefix_equal
     44#define in6ifa_ifpwithrtrix     _tinet_in6ifa_ifpwithrtrix
     45#define in6_if_up               _tinet_in6_if_up
     46#define in6_if2idlen            _tinet_in6_if2idlen
     47#define in6_ifaddr_timer        _tinet_in6_ifaddr_timer
     48#define in6ifa_ifpwithix        _tinet_in6ifa_ifpwithix
     49#define in6_addr2maix           _tinet_in6_addr2maix
     50#define in6_ifawithifp          _tinet_in6_ifawithifp
     51#define in6_addr2ifaix          _tinet_in6_addr2ifaix
     52#define in6_update_ifa          _tinet_in6_update_ifa
     53#define in6_ifainit             _tinet_in6_ifainit
     54#define in6_addrwithifp         _tinet_in6_addrwithifp
    4355#define in6_addr_loopback       _tinet_in6_addr_loopback
    44 #define in6_ifainit             _tinet_in6_ifainit
    45 #define in6_addr2ifaix          _tinet_in6_addr2ifaix
    46 #define in6_addr2maix           _tinet_in6_addr2maix
    47 #define in6_update_ifa          _tinet_in6_update_ifa
    48 #define in6ifa_ifpwithix        _tinet_in6ifa_ifpwithix
    49 #define in6ifa_ifpwithrtrix     _tinet_in6ifa_ifpwithrtrix
    50 #define in6_ifawithifp          _tinet_in6_ifawithifp
    51 #define in6_if_up               _tinet_in6_if_up
    52 #define in6_rtalloc             _tinet_in6_rtalloc
    53 #define in6_are_prefix_equal    _tinet_in6_are_prefix_equal
    54 #define in6_addr_linklocal_allrouters   \
    55                                 _tinet_in6_addr_linklocal_allrouters
    56 #define in6_addr_linklocal_allnodes     \
    57                                 _tinet_in6_addr_linklocal_allnodes
    58 #define in6_ifaddr_timer        _tinet_in6_ifaddr_timer
    5956
    6057/* netinet6/in6_ifattach.c */
     
    6461/* netinet6/in6_subr.c */
    6562
     63#define inn6_is_dstaddr_accept  _tinet_inn6_is_dstaddr_accept
     64#define in6_lookup_ifaddr       _tinet_in6_lookup_ifaddr
     65#define in6_rtalloc             _tinet_in6_rtalloc
     66#define in6_get_ifaddr          _tinet_in6_get_ifaddr
     67#define in6_cksum               _tinet_in6_cksum
     68#define in6_gateway_lookup      _tinet_in6_gateway_lookup
     69#define in6_is_dstaddr_accept   _tinet_in6_is_dstaddr_accept
     70#define in6_hostcache_getmtu    _tinet_in6_hostcache_getmtu
     71#define in6_set_header          _tinet_in6_set_header
     72#define in6_get_datagram        _tinet_in6_get_datagram
     73#define in6_rtredirect          _tinet_in6_rtredirect
     74#define get_ip6_hdr_size        _tinet_get_ip6_hdr_size
     75#define in6_plen2pmask          _tinet_in6_plen2pmask
     76#define in6_rtnewentry          _tinet_in6_rtnewentry
     77#define in6_rtinit              _tinet_in6_rtinit
     78#define in6_rttimer             _tinet_in6_rttimer
    6679#define in6_lookup_multi        _tinet_in6_lookup_multi
    67 #define get_ip6_hdr_size        _tinet_get_ip6_hdr_size
    68 #define in6_lookup_ifaddr       _tinet_in6_lookup_ifaddr
    69 #define in6_get_datagram        _tinet_in6_get_datagram
    70 #define in6_cksum               _tinet_in6_cksum
    71 #define in6_is_dstaddr_accept   _tinet_in6_is_dstaddr_accept
    72 #define in6_plen2pmask          _tinet_in6_plen2pmask
     80#define in6_hostcache_update    _tinet_in6_hostcache_update
    7381#define in6_init                _tinet_in6_init
    74 #define in6_rtredirect          _tinet_in6_rtredirect
    75 #define in6_gateway_lookup      _tinet_in6_gateway_lookup
    76 #define in6_set_header          _tinet_in6_set_header
    77 #define in6_hostcache_getmtu    _tinet_in6_hostcache_getmtu
    78 #define in6_hostcache_update    _tinet_in6_hostcache_update
    7982
    8083/* netinet6/if6_ether.c */
     
    151154/* netinet6/nd6_rtr.c */
    152155
     156#define nd6_get_prl             _tinet_nd6_get_prl
    153157#define nd6_router_lookup       _tinet_nd6_router_lookup
     158#define nd6_onlink_prefix_lookup        \
     159                                _tinet_nd6_onlink_prefix_lookup
     160#define nd6_defrtrlist_del      _tinet_nd6_defrtrlist_del
     161#define nd6_prefix_onlink       _tinet_nd6_prefix_onlink
     162#define nd6_get_drl             _tinet_nd6_get_drl
     163#define nd6_rtrsol_ctl          _tinet_nd6_rtrsol_ctl
    154164#define nd6_defrtrlist_timer    _tinet_nd6_defrtrlist_timer
     165#define nd6_ra_input            _tinet_nd6_ra_input
    155166#define nd6_prelist_timer       _tinet_nd6_prelist_timer
    156 #define nd6_ra_input            _tinet_nd6_ra_input
    157 #define nd6_rtrsol_ctl          _tinet_nd6_rtrsol_ctl
     167#define nd6_prefix_offlink      _tinet_nd6_prefix_offlink
     168#define nd6_defrtrlist_lookup   _tinet_nd6_defrtrlist_lookup
    158169#define ip6_defhlim             _tinet_ip6_defhlim
    159170#define nd6_reachable_time      _tinet_nd6_reachable_time
     
    162173                                _tinet_nd6_recalc_reachtm_interval
    163174#define nd6_retrans_time        _tinet_nd6_retrans_time
    164 #define nd6_defrtrlist_lookup   _tinet_nd6_defrtrlist_lookup
    165 #define nd6_prefix_onlink       _tinet_nd6_prefix_onlink
    166 #define nd6_prefix_offlink      _tinet_nd6_prefix_offlink
    167 #define nd6_get_prl             _tinet_nd6_get_prl
    168 #define nd6_get_drl             _tinet_nd6_get_drl
    169 #define nd6_defrtrlist_del      _tinet_nd6_defrtrlist_del
    170175
    171176/* netinet6/scope6.c */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.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 *
     
    122122#include <net/if_arp.h>
    123123#include <net/net.h>
     124#include <net/net_endian.h>
    124125#include <net/net_var.h>
    125126#include <net/net_buf.h>
     
    128129#include <netinet/in.h>
    129130#include <netinet/in_var.h>
    130 
    131 #include <netinet6/in6.h>
    132 #include <netinet6/in6_var.h>
    133 #include <netinet/ip6.h>
    134 #include <netinet6/ip6_var.h>
     131#include <netinet/ip.h>
     132#include <netinet/ip_var.h>
     133
     134#include <netinet6/nd6.h>
    135135#include <netinet6/ah.h>
    136 #include <netinet6/nd6.h>
    137 
    138 #include <net/if6_var.h>
    139 
    140 #ifdef SUPPORT_INET6
     136
     137#include <net/if_var.h>
     138
     139/*
     140 *  in6_make_ipv4mapped -- IPv4 射影アドレスを生成する。
     141 *
     142 *  注意:
     143 *    src はホストバイトオーダー
     144 *
     145 */
     146
     147T_IN6_ADDR *
     148in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src)
     149{
     150        dst->s6_addr32[0] = ULONG_C(0x00000000);
     151        dst->s6_addr32[1] = ULONG_C(0x00000000);
     152        dst->s6_addr32[2] = IPV6_ADDR_INT32_0000FFFF;
     153        dst->s6_addr32[3] = htonl(src);
     154
     155        return dst;
     156        }
     157
     158#ifdef _IP6_CFG
     159
     160#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
     161
     162/*
     163 *  in6_rtinit -- ルーティング表を初期化する。
     164 */
     165
     166void
     167in6_rtinit (void)
     168{
     169        int_t ix;
     170
     171        for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++)
     172                routing6_tbl[ix].flags = IN_RTF_DEFINED;
     173
     174        for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
     175                routing6_tbl[ix].flags = 0;
     176        }
     177
     178/*
     179 *  in6_rtnewentry -- 新しいエントリを獲得する。
     180 */
     181
     182T_IN6_RTENTRY *
     183in6_rtnewentry (uint8_t flags, uint32_t tmo)
     184{
     185        SYSTIM          now;
     186        T_IN6_RTENTRY   *rt, *frt = NULL;
     187        int_t           ix;
     188
     189        /* 空きエントリを探す。*/
     190        for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
     191                rt = &routing6_tbl[ix];
     192                if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
     193                        frt = rt;
     194                        break;
     195                        }
     196                }
     197
     198        /* expire の単位は [s]。*/
     199        syscall(get_tim(&now));
     200        now /= SYSTIM_HZ;
     201
     202        if (frt == NULL) {
     203                /* 空きがなければ、有効時間がもっとも短いエントリを空きにする。*/
     204                T_IN6_RTENTRY   *srt = NULL;
     205                int_t           diff, sdiff = INT_MAX;
     206
     207                syscall(wai_sem(SEM_IN6_ROUTING_TBL));
     208                for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
     209                        rt = &routing6_tbl[ix];
     210                        diff = (int_t)(rt->expire - now);
     211                        if (diff <= 0) {        /* rt->expire <= now */
     212                                /* 既に、有効時間が過ぎている。*/
     213                                frt = rt;
     214                                break;
     215                                }
     216                        else if (diff < sdiff) {
     217                                srt = rt;
     218                                sdiff = diff;
     219                                }
     220                        }
     221                if (frt == NULL)
     222                        frt = srt;
     223                frt->flags = 0;
     224                syscall(sig_sem(SEM_IN6_ROUTING_TBL));
     225                }
     226
     227        frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
     228        frt->expire = now + tmo / SYSTIM_HZ;
     229        return frt;
     230        }
     231
     232/*
     233 *  in6_rttimer -- ルーティング表の管理タイマー
     234 */
     235
     236void
     237in6_rttimer (void)
     238{
     239        SYSTIM  now;
     240        int_t   ix;
     241
     242        /* expire の単位は [s]。*/
     243        syscall(get_tim(&now));
     244        now /= SYSTIM_HZ;
     245
     246        syscall(wai_sem(SEM_IN6_ROUTING_TBL));
     247        for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
     248                if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
     249                    (int_t)(routing6_tbl[ix].expire - now) <= 0)
     250                        routing6_tbl[ix].flags = 0;
     251        syscall(sig_sem(SEM_IN6_ROUTING_TBL));
     252        }
     253
     254#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
    141255
    142256#if NUM_IN6_HOSTCACHE_ENTRY > 0
     
    155269
    156270T_IN6_IFADDR *
    157 in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr)
     271in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr)
    158272{
    159273        int_t ix;
    160274
    161275        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    162                 if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
    163                     IN6_ARE_ADDR_EQUAL(addr, &ifp->in_ifaddrs[ix].addr))
    164                         return &ifp->in_ifaddrs[ix];
     276                if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
     277                    IN6_ARE_ADDR_EQUAL(addr, &ifp->in6_ifaddrs[ix].addr))
     278                        return &ifp->in6_ifaddrs[ix];
    165279                }
    166280        return NULL;
     
    172286
    173287bool_t
    174 in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr)
     288in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr)
    175289{
    176290        int_t ix;
    177291
    178292        for (ix = MAX_IN6_MADDR_CNT; ix -- > 0; )
    179                 if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in_maddrs[ix]))
     293                if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in6_maddrs[ix]))
    180294                        return true;
    181295        return false;
     
    188302ER
    189303in6_set_header (T_NET_BUF *nbuf, uint_t len,
    190                 T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     304                const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
    191305                uint8_t next, uint8_t hlim)
    192306{
     
    216330                memset(&ip6h->dst, 0, sizeof(T_IN6_ADDR));
    217331        else
    218                 ip6h->dst = *dstaddr;
     332                memcpy(&ip6h->dst, dstaddr, sizeof(T_IN6_ADDR));
    219333
    220334        if (srcaddr == NULL)
    221335                memset(&ip6h->src, 0, sizeof(T_IN6_ADDR));
    222336        else
    223                 ip6h->src = *srcaddr;
     337                memcpy(&ip6h->src, srcaddr, sizeof(T_IN6_ADDR));
    224338
    225339        return E_OK;
     
    232346ER
    233347in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
    234                   T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     348                  const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
    235349                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
    236350{
     
    269383 */
    270384
    271 ER_UINT
     385uint_t
    272386in6_get_maxnum_ifaddr (void)
    273387{
     
    285399
    286400        if (index < NUM_IN6_IFADDR_ENTRY &&
    287             (ifp->in_ifaddrs[index].flags & IN6_IFF_DEFINED))
    288                 return &ifp->in_ifaddrs[index].addr;
     401            (ifp->in6_ifaddrs[index].flags & IN6_IFF_DEFINED))
     402                return &ifp->in6_ifaddrs[index].addr;
    289403        else
    290404                return NULL;
     
    296410
    297411char *
    298 ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr)
    299 {
    300         static char     addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:89ab:cdef")];
     412ipv62str (char *buf, const T_IN6_ADDR *p_addr)
     413{
     414        static char     addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:255.255.255.255")];
    301415        static int_t    bix = NUM_IPV6ADDR_STR_BUFF;
    302416
    303417        bool_t  omit = false, zero = false;
    304418        char    *start;
    305         int_t   ix;
     419        int_t   ix, len6;
    306420
    307421        if (buf == NULL) {
     
    314428
    315429        start = buf;
    316         if (p_ip6addr == NULL) {
     430        if (p_addr == NULL || IN6_IS_ADDR_UNSPECIFIED(p_addr)) {
     431                *buf ++ = '0';
    317432                *buf ++ = ':';
    318433                *buf ++ = ':';
     434                *buf ++ = '0';
    319435                }
    320436        else {
    321                 for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
     437                if (IN6_IS_ADDR_V4MAPPED(p_addr))
     438                        len6 = sizeof(T_IN6_ADDR) / 2 - 2;
     439                else
     440                        len6 = sizeof(T_IN6_ADDR) / 2;
     441                for (ix = 0; ix < len6; ix ++) {
    322442                        if (omit) {
    323                                 buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' ');
     443                                buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' ');
    324444                                if (ix < 7)
    325445                                        *buf ++ = ':';
    326446                                }
    327                         else if (ix > 0 && ix < 7 && p_ip6addr->s6_addr16[ix] == 0)
     447                        else if (ix > 0 && ix < 7 && p_addr->s6_addr16[ix] == 0)
    328448                                zero = true;
    329449                        else {
     
    332452                                        *buf ++ = ':';
    333453                                        }
    334                                 buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' ');
     454                                buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' ');
    335455                                if (ix < 7)
    336456                                        *buf ++ = ':';
    337457                                }
    338458                        }
     459
     460                if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
     461                        T_IN4_ADDR ipv4addr;
     462
     463                        ipv4addr = ntohl(p_addr->s6_addr32[3]);
     464                        buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 24) & 0xff), 10, 0, ' ');
     465                        *(buf ++) = '.';
     466                        buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 16) & 0xff), 10, 0, ' ');
     467                        *(buf ++) = '.';
     468                        buf += convert_hexdigit(buf, (uint_t)((ipv4addr >>  8) & 0xff), 10, 0, ' ');
     469                        *(buf ++) = '.';
     470                        buf += convert_hexdigit(buf, (uint_t)((ipv4addr      ) & 0xff), 10, 0, ' ');
     471                        }
    339472                }
    340473        *buf = '\0';
     
    370503
    371504/*
    372  *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
    373  */
    374 
    375 bool_t
    376 in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
    377 {
    378         if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
    379                 return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
    380         else
    381                 return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
    382         }
    383 
    384 /*
    385505 *  get_ip6_hdr_size -- 拡張ヘッダも含めた IPv6 ヘッダ長を返す。
    386506 */
    387507
    388508uint_t
    389 get_ip6_hdr_size (T_IP6_HDR *iph)
    390 {
    391         uint_t  size = IP6_HDR_SIZE, hsize;
    392         uint8_t curr = iph->next, next;
    393         uint8_t *hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
     509get_ip6_hdr_size (T_NET_BUF *nbuf)
     510{
     511        T_IP6_HDR       *iph = GET_IP6_HDR(nbuf);
     512        uint_t          size = IP6_HDR_SIZE, hsize;
     513        uint8_t         curr = iph->next, next;
     514        uint8_t         *hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
    394515
    395516        while (1) {
     
    436557 */
    437558
    438 T_IN6_ADDR *
    439 in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst)
     559const T_IN6_ADDR *
     560in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst)
    440561{
    441562        if (IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MULTICAST(dst))
     
    456577                /* 推奨有効時間内のアドレスを探索する。*/
    457578                for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    458                         ia = &ifp->in_ifaddrs[ix];
     579                        ia = &ifp->in6_ifaddrs[ix];
    459580                        if (IFA6_IS_READY(ia) &&
    460581                            in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
     
    467588                /* 有効時間内のアドレスを探索する。*/
    468589                for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    469                         ia = &ifp->in_ifaddrs[ix];
     590                        ia = &ifp->in6_ifaddrs[ix];
    470591                        if (IFA6_IS_READY(ia) &&
    471592                            in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
     
    485606                 */
    486607
    487 #if NUM_ROUTE_ENTRY > 0
    488 
    489                 syscall(wai_sem(SEM_IN_ROUTING_TBL));
    490                 for (ix = NUM_ROUTE_ENTRY; ix --; ) {
    491                         if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
    492                             in6_are_prefix_equal(dst, &routing_tbl[ix].target,
    493                                                        routing_tbl[ix].prefix_len)) {
     608#if NUM_IN6_ROUTE_ENTRY > 0
     609
     610                syscall(wai_sem(SEM_IN6_ROUTING_TBL));
     611                for (ix = NUM_IN6_ROUTE_ENTRY; ix --; ) {
     612                        if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
     613                            in6_are_prefix_equal(dst, &routing6_tbl[ix].target,
     614                                                       routing6_tbl[ix].prefix_len)) {
    494615
    495616                                /*
     
    498619                                 *  TMO_IN_REDIRECT の単位は [ms]。
    499620                                 */
    500                                 if (ix > NUM_STATIC_ROUTE_ENTRY) {
     621                                if (ix > NUM_IN6_STATIC_ROUTE_ENTRY) {
    501622                                        SYSTIM  now;
    502623
    503624                                        syscall(get_tim(&now));
    504                                         routing_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
     625                                        routing6_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
    505626                                        }
    506627
    507                                 syscall(sig_sem(SEM_IN_ROUTING_TBL));
    508                                 return &routing_tbl[ix].gateway;
     628                                syscall(sig_sem(SEM_IN6_ROUTING_TBL));
     629                                return &routing6_tbl[ix].gateway;
    509630                                }
    510631                        }
    511                 syscall(sig_sem(SEM_IN_ROUTING_TBL));
    512 
    513 #endif  /* of #if NUM_ROUTE_ENTRY > 0 */
     632                syscall(sig_sem(SEM_IN6_ROUTING_TBL));
     633
     634#endif  /* of #if NUM_IN6_ROUTE_ENTRY > 0 */
    514635
    515636                /*
     
    520641        }
    521642
    522 #if NUM_REDIRECT_ROUTE_ENTRY > 0
     643#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
    523644
    524645/*
     
    526647 */
    527648
    528 T_IN_RTENTRY *
    529 in6_gateway_lookup (T_IN6_ADDR *gw)
     649T_IN6_RTENTRY *
     650in6_gateway_lookup (const T_IN6_ADDR *gw)
    530651{
    531652        int_t   ix;
    532653
    533         for (ix = NUM_ROUTE_ENTRY; ix --; )
    534                 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
    535                     IN6_ARE_ADDR_EQUAL(&routing_tbl[ix].gateway, gw))
    536                         return &routing_tbl[ix];
     654        for (ix = NUM_IN6_ROUTE_ENTRY; ix --; )
     655                if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
     656                    IN6_ARE_ADDR_EQUAL(&routing6_tbl[ix].gateway, gw))
     657                        return &routing6_tbl[ix];
    537658        return NULL;
    538659        }
     
    545666
    546667void
    547 in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
    548 {
    549         T_IN_RTENTRY    *frt;
    550 
    551         frt = in_rtnewentry(flags, tmo);
    552         frt->gateway    = *gateway;
    553         frt->target     = *target;
     668in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
     669{
     670        T_IN6_RTENTRY   *frt;
     671
     672        frt = in6_rtnewentry(flags, tmo);
     673        memcpy(&frt->gateway, gateway, sizeof(T_IN6_ADDR));
     674        memcpy(&frt->target, target, sizeof(T_IN6_ADDR));
    554675        frt->prefix_len = prefix_len;
    555676        }
    556677
    557 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     678#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
    558679
    559680#if NUM_IN6_HOSTCACHE_ENTRY > 0
     
    564685
    565686static T_IN6_HOSTCACHE_ENTRY*
    566 in6_hostcache_lookup (T_IN6_ADDR *dst)
     687in6_hostcache_lookup (const T_IN6_ADDR *dst)
    567688{
    568689        int_t ix;
     
    625746                return;
    626747                }
    627         hc->dst    = *dst;
     748        memcpy(&hc->dst, dst, sizeof(T_IN6_ADDR));
    628749        hc->expire = now + IN6_HOSTCACHE_EXPIRE;
    629750        hc->mtu    = mtu;
     
    637758
    638759uint32_t
    639 in6_hostcache_getmtu (T_IN6_ADDR *dst)
     760in6_hostcache_getmtu (const T_IN6_ADDR *dst)
    640761{
    641762        T_IN6_HOSTCACHE_ENTRY   *hc;
     
    679800in6_timer (void)
    680801{
    681 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    682 
    683         in_rttimer();
    684 
    685 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     802#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
     803
     804        in6_rttimer();
     805
     806#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
    686807
    687808#ifdef IP6_CFG_FRAGMENT
     
    707828in6_init (void)
    708829{
    709 #if NUM_REDIRECT_ROUTE_ENTRY > 0
    710 
    711         in_rtinit();
    712 
    713 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     830#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
     831
     832        in6_rtinit();
     833
     834#endif  /* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
    714835
    715836        timeout((callout_func)nd6_timer, NULL, ND6_TIMER_TMO);
     
    717838        }
    718839
    719 #endif /* of #ifdef SUPPORT_INET6 */
     840/*
     841 *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
     842 */
     843
     844bool_t
     845in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr)
     846{
     847        if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
     848                return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
     849        else
     850                return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
     851        }
     852
     853#if defined(DHCP6_CLI_CFG)
     854
     855/*
     856 *  in6_add_ifaddr -- インタフェースに IPv6 アドレスを設定する。
     857 *
     858 *    vltime と pltime の単位は[s]
     859 */
     860
     861static ER
     862in6_add_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
     863                uint32_t vltime, uint32_t pltime)
     864{
     865        T_IFNET         *ifp = IF_GET_IFNET();
     866        T_IN6_IFADDR    *ia = NULL;
     867        int_t           ix;
     868
     869        /* 空きのエントリーを探す。*/
     870        ix = 0;
     871        while (true) {
     872                ia = in6ifa_ifpwithix(ifp, ix ++);
     873
     874                /* 空きが無ければエラー */
     875                if (ia == NULL)
     876                        return E_OBJ;
     877
     878                if ((ia->flags & IN6_IFF_DEFINED) == 0)
     879                        break;
     880                }
     881
     882        /* 登録する。*/
     883        return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
     884                              IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
     885        }
     886
     887/*
     888 *  in6_upd_ifaddr -- インタフェースに設定されている IPv6 アドレスを更新する。
     889 *
     890 *    登録されていなければ、追加する。
     891 *    vltime と pltime の単位は[s]
     892 */
     893
     894ER
     895in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
     896                uint32_t vltime, uint32_t pltime)
     897{
     898        T_IFNET         *ifp = IF_GET_IFNET();
     899        T_IN6_IFADDR    *ia;
     900        int_t           ix;
     901
     902        /*
     903         *  アドレスが一致するエントリーを探す。
     904         *  無ければ登録する。
     905         */
     906        if ((ix = in6_addr2ifaix(addr)) == IPV6_IFADDR_IX_INVALID)
     907                return in6_add_ifaddr(addr, prefix_len, vltime, pltime);
     908
     909        /*
     910         *  インデックス番号から、エントリーに変換する。
     911         *  エラーにならないはずであるが、確認する。
     912         */
     913        if ((ia = in6ifa_ifpwithix (ifp, ix)) == NULL)
     914                return E_OBJ;
     915
     916        /* 更新する。*/
     917        return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
     918                              IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
     919        }
     920
     921/*
     922 *  in6_del_ifaddr -- インタフェースに設定されている IPv6 アドレスを削除する。
     923 */
     924
     925ER
     926in6_del_ifaddr (T_IN6_ADDR *addr)
     927{
     928        T_IFNET         *ifp = IF_GET_IFNET();
     929        int_t           ix;
     930
     931        /* アドレスが一致するエントリーを探す。*/
     932        if ((ix = in6_addr2ifaix(addr)) != IPV6_IFADDR_IX_INVALID) {
     933
     934                /* エントリーを無効にする。*/
     935                ifp->in6_ifaddrs[ix].flags &= ~IN6_IFF_DEFINED;
     936                return E_OK;
     937                }
     938        return E_PAR;
     939        }
     940
     941#endif  /* of #if defined(DHCP6_CLI_CFG) */
     942
     943#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h

    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 *
     
    102102#define _IN6_VAR_H_
    103103
    104 #ifdef SUPPORT_INET6
     104/*
     105 *  アドレスの定義
     106 */
     107
     108#ifdef _NET_CFG_BYTE_ORDER
     109
     110#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     111
     112#define IPV6_ADDR_INT32_ONE             ULONG_C(0x00000001)
     113#define IPV6_ADDR_INT32_TWO             ULONG_C(0x00000002)
     114#define IPV6_ADDR_INT32_0000FFFF        ULONG_C(0x0000ffff)
     115#define IPV6_ADDR_INT32_MNL             ULONG_C(0xff010000)
     116#define IPV6_ADDR_INT32_MLL             ULONG_C(0xff020000)
     117#define IPV6_ADDR_INT32_ULL             ULONG_C(0xfe800000)
     118#define IPV6_ADDR_INT16_ULL             UINT_C(0xfe80)
     119#define IPV6_ADDR_INT16_USL             UINT_C(0xfec0)
     120#define IPV6_ADDR_INT16_MLL             UINT_C(0xff02)
     121
     122#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
     123
     124#define IPV6_ADDR_INT32_ONE             ULONG_C(0x01000000)
     125#define IPV6_ADDR_INT32_TWO             ULONG_C(0x02000000)
     126#define IPV6_ADDR_INT32_0000FFFF        ULONG_C(0xffff0000)
     127#define IPV6_ADDR_INT32_MNL             ULONG_C(0x000001ff)
     128#define IPV6_ADDR_INT32_MLL             ULONG_C(0x000002ff)
     129#define IPV6_ADDR_INT32_ULL             ULONG_C(0x000080fe)
     130#define IPV6_ADDR_INT16_ULL             UINT_C(0x80fe)
     131#define IPV6_ADDR_INT16_USL             UINT_C(0xc0fe)
     132#define IPV6_ADDR_INT16_MLL             UINT_C(0x02ff)
     133
     134#endif  /* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
     135
     136#endif  /* of #ifdef _NET_CFG_BYTE_ORDER */
     137
     138/*
     139 *  特別なアドレスのチェック
     140 */
     141
     142/* IPv4 互換 */
     143
     144#ifdef _NET_CFG_BYTE_ORDER
     145#define IN6_IS_ADDR_V4COMPAT(a)         \
     146        (memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
     147         (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
     148#endif
     149
     150/* IPv4 射影 */
     151
     152#ifdef _NET_CFG_BYTE_ORDER
     153#define IN6_IS_ADDR_V4MAPPED(a)         \
     154        (((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
     155         ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
     156         ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
     157#endif
     158
     159/* 要請マルチキャスト */
     160
     161#ifdef _NET_CFG_BYTE_ORDER
     162#define IN6_IS_ADDR_NS_MULTICAST(a)     \
     163        (((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
     164         ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
     165         ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
     166         ((a)->s6_addr8[12] == UINT_C(0xff)))
     167#endif
     168
     169#ifndef _MACRO_ONLY
    105170
    106171/*
     
    197262                                                /* IPv6 マルチキャストアドレス配列の最大サイズ     */
    198263
    199 /*
    200  *  ルーティングの制御
    201  */
    202 
    203264/* ルーティング表エントリ構造体 */
    204265
     
    231292
    232293/*
    233  *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
    234  */
    235 
    236 #define IN_SET_HEADER(nbuf,len,dst,src,next,hlim)       \
    237                                         in6_set_header(nbuf,len,dst,src,next,hlim)
    238 #define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)  \
    239                                         in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
    240 #define IN_CKSUM(nbuf,proto,off,len)    in6_cksum(nbuf,proto,off,len)
    241 #define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr)                    \
    242                                         in6_is_dstaddr_accept(myaddr,dstaddr)
    243 #define IN_IFAWITHIFP(ifp,dst)          in6_ifawithifp(ifp,dst)
    244 #define T_IN_IFADDR                     T_IN6_IFADDR
    245 #define T_IN_RTENTRY                    T_IN6_RTENTRY
     294 *  ルーティング表
     295 */
     296
     297extern T_IN6_RTENTRY routing6_tbl[];
    246298
    247299/*
     
    264316
    265317/*
     318 *  関数シミュレーションマクロ
     319 */
     320
     321#define IN6_COPY_TO_HOST(dst,nbuf)      memcpy(dst,&GET_IP6_HDR(nbuf)->src,sizeof(T_IN6_ADDR))
     322#define INN6_IS_DSTADDR_ACCEPT(addr,nbuf)       \
     323                                        in6_is_dstaddr_accept(addr,&GET_IP6_HDR(nbuf)->dst)
     324
     325/*
    266326 *  関数
    267327 */
    268328
    269329extern void in6_ifainit (void);
    270 extern int_t in6_addr2maix (T_IN6_ADDR *addr);
    271 extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
     330extern int_t in6_addr2maix (const T_IN6_ADDR *addr);
     331extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
    272332                          uint_t prefix_len, uint32_t vltime, uint32_t pltime,
    273333                          int_t router_index, int_t prefix_index, uint_t flags);
    274334extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
    275                           T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     335                          const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
    276336                          uint8_t next, uint8_t hlim);
    277337extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
    278                             T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
     338                            const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
    279339                            uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
    280340extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
    281341extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
    282342extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
    283 extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst);
     343extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst);
     344extern const T_IN6_ADDR *in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst);
    284345extern void ip6_input (T_NET_BUF *input);
    285 extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr);
    286 extern bool_t in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr);
    287 extern bool_t in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr);
    288 extern T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst);
     346extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr);
     347extern bool_t in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr);
     348extern bool_t in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr);
     349extern bool_t inn6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, T_NET_BUF *input);
     350extern const T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst);
    289351extern int_t in6_if2idlen (T_IFNET *ifp);
    290 extern int_t in6_addr2ifaix (T_IN6_ADDR *addr);
     352extern int_t in6_addr2ifaix (const T_IN6_ADDR *addr);
    291353extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
    292 extern bool_t in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix,
     354extern bool_t in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix,
    293355                                  uint_t prefix_len);
    294356extern void in6_ifaddr_timer (T_IFNET *ifp);
    295 extern T_IN6_RTENTRY *in6_gateway_lookup (T_IN6_ADDR *src);
    296 extern void in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target,
     357extern T_IN6_RTENTRY *in6_gateway_lookup (const T_IN6_ADDR *src);
     358extern void in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target,
    297359                            uint_t prefix_len, uint8_t flags, uint32_t tmo);
    298360extern void in6_init (void);
    299361extern void in6_if_up (T_IFNET *ifp);
    300362extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
    301 extern uint32_t in6_hostcache_getmtu (T_IN6_ADDR *dst);
    302 extern uint_t in6_addrscope (T_IN6_ADDR *addr);
     363extern uint32_t in6_hostcache_getmtu (const T_IN6_ADDR *dst);
     364extern uint_t in6_addrscope (const T_IN6_ADDR *addr);
    303365extern const T_NET_BUF**ip6_get_frag_queue (void);
    304366
    305 #endif  /* of #ifdef SUPPORT_INET6 */
     367#endif  /* of #ifndef _MACRO_ONLY */
    306368
    307369#endif  /* of #ifndef _IN6_VAR_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg

    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 *
     
    3636 */
    3737
    38 #ifdef SUPPORT_INET6
     38#ifdef _IP6_CFG
    3939
    4040/* 近隣キャッシュ */
     
    5858#endif  /* of #ifdef IP6_CFG_FRAGMENT */
    5959
    60 #if NUM_REDIRECT_ROUTE_ENTRY > 0
     60#if NUM_IN6_ROUTE_ENTRY > 0
    6161
    62 /* ルーティング表(向け直し)*/
     62/* ルーティング表 */
    6363
    64 CRE_SEM(SEM_IN_ROUTING_TBL, { TA_TPRI, 1, 1 });
     64CRE_SEM(SEM_IN6_ROUTING_TBL, { TA_TPRI, 1, 1 });
    6565
    66 #endif  /* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
     66#endif  /* of #if NUM_IN6_ROUTE_ENTRY > 0 */
    6767
    68 #endif  /* of #ifdef SUPPORT_INET6 */
     68#endif  /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.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 *
     
    105105#include <kernel.h>
    106106#include <sil.h>
     107#include <t_syslog.h>
     108#include "tinet_cfg.h"
    107109
    108110#endif  /* of #ifdef TARGET_KERNEL_ASP */
     
    112114#include <s_services.h>
    113115#include <t_services.h>
     116#include "tinet_id.h"
    114117
    115118#endif  /* of #ifdef TARGET_KERNEL_JSP */
     
    124127#include <net/ppp_ipcp.h>
    125128#include <net/net.h>
     129#include <net/net_endian.h>
    126130#include <net/net_buf.h>
    127131#include <net/net_count.h>
    128132
    129133#include <netinet/in.h>
    130 #include <netinet6/in6.h>
    131 #include <netinet6/in6_var.h>
     134#include <netinet/in_var.h>
     135#include <netinet/ip.h>
     136#include <netinet/ip_var.h>
     137#include <netinet/ip_icmp.h>
     138#include <netinet/tcp.h>
     139#include <netinet/tcp_var.h>
     140#include <netinet/udp_var.h>
     141
    132142#include <netinet6/nd6.h>
    133 #include <netinet/ip6.h>
    134 #include <netinet6/ip6_var.h>
    135 #include <netinet/icmp6.h>
    136143#include <netinet6/ah6.h>
    137144#include <netinet6/esp6.h>
    138 #include <netinet/tcp.h>
    139 #include <netinet/tcp_timer.h>
    140 #include <netinet/tcp_var.h>
    141 #include <netinet/udp_var.h>
    142 
    143 #include <net/if6_var.h>
    144 
    145 #ifdef SUPPORT_INET6
     145
     146#include <net/if_var.h>
     147
     148#ifdef _IP6_CFG
    146149
    147150/*
     
    170173        { icmp6_input,  IPPROTO_ICMPV6          },
    171174
    172 #ifdef SUPPORT_UDP
    173 
    174         { udp_input,    IPPROTO_UDP             },
    175 
    176 #endif  /* of #ifdef SUPPORT_UDP */
    177 
    178 #ifdef SUPPORT_TCP
     175#if defined(SUPPORT_TCP)
    179176
    180177        { tcp_input,    IPPROTO_TCP             },
    181178
    182 #endif  /* of #ifdef SUPPORT_TCP */
     179#endif  /* of #if defined(SUPPORT_TCP) */
     180
     181#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
     182
     183        { udp6_input,   IPPROTO_UDP             },
     184
     185#endif  /* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
    183186
    184187        };
     
    640643
    641644        /* 開始オフセットを IP ヘッダに設定する。*/
    642         off = ((uint8_t *)GET_IP_HDR(nbuf)) - nbuf->buf;
     645        off = ((uint8_t *)GET_IP6_HDR(nbuf)) - nbuf->buf;
    643646
    644647        /* 最終ヘッダを探索する。*/
     
    650653                uint_t sdu;
    651654
    652                 sdu = GET_IP_SDU(nbuf) - nbuf->buf;
     655                sdu = GET_IP6_SDU(nbuf) - nbuf->buf;
    653656                if (off > sdu) {
    654657                        memmove(nbuf->buf + sdu, nbuf->buf + off, off - sdu);
    655                         GET_IP_HDR(nbuf)->plen -= off - sdu;
     658                        GET_IP6_HDR(nbuf)->plen -= off - sdu;
    656659                        nbuf->len              -= off - sdu;
    657660                        }
     
    660663        }
    661664
    662 #endif /* of #ifdef SUPPORT_INET6 */
     665#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_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 *
     
    125125#include <net/ppp_ipcp.h>
    126126#include <net/net.h>
     127#include <net/net_endian.h>
    127128#include <net/net_buf.h>
    128129#include <net/net_count.h>
    129130
    130131#include <netinet/in.h>
    131 #include <netinet6/in6.h>
    132 #include <netinet6/in6_var.h>
     132#include <netinet/in_var.h>
     133#include <netinet/ip.h>
     134#include <netinet/ip_var.h>
     135#include <netinet/ip_icmp.h>
     136
    133137#include <netinet6/nd6.h>
    134 #include <netinet/ip6.h>
    135 #include <netinet6/ip6_var.h>
    136 #include <netinet/icmp6.h>
    137 
    138 #include <net/if6_var.h>
    139 
    140 #ifdef SUPPORT_INET6
     138
     139#include <net/if_var.h>
     140
     141#ifdef _IP6_CFG
    141142
    142143/*
     
    165166ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout)
    166167{
    167         T_IP6_HDR       *ip6h;
    168         T_IN6_ADDR      *gw;
    169         T_IFNET         *ifp = IF_GET_IFNET();
    170         ER              error = E_OK;
     168        T_IP6_HDR               *ip6h;
     169        const T_IN6_ADDR        *gw;
     170        T_IFNET                 *ifp = IF_GET_IFNET();
     171        ER                      error = E_OK;
    171172
    172173#ifdef IP6_CFG_FRAGMENT
     
    185186
    186187        NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_OCTETS],
    187                       GET_IP_HDR_SIZE(ip6h) + GET_IP_SDU_SIZE(ip6h));
     188                      GET_IP6_HDR_SIZE(output) + GET_IP6_SDU_SIZE(output));
    188189        NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_PACKETS], 1);
    189190        NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutRequests, 1);
     
    371372        }
    372373
    373 #endif /* of #ifdef SUPPORT_INET6 */
     374#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h

    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 *
     
    102102#define _IP6_VAR_H_
    103103
    104 #ifdef SUPPORT_INET6
    105 
    106104/*
    107105 *  IPv6 ヘッダ・ペイロードアクセスマクロ
     
    114112#define GET_IP6_NEXT_HDR(nbuf)          ((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
    115113
    116 #define GET_IP6_HDR_SIZE(iph)           (get_ip6_hdr_size(iph))
    117 #define GET_IP6_SDU_SIZE(iph)           (ntohs((iph)->plen))
    118 #define GET_IF_IP6_HDR_SIZE(nbuf)       (IF_HDR_SIZE + (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf))))
    119 
    120 #define SET_IP6_SDU_SIZE(iph,slen)      ((iph)->plen=htons(slen))
     114#define GET_IP6_HDR_SIZE(nbuf)          (get_ip6_hdr_size(nbuf))
     115#define GET_IP6_SDU_SIZE(nbuf)          (ntohs(GET_IP6_HDR(nbuf)->plen))
     116#define GET_IF_IP6_HDR_SIZE(nbuf)       (IF_HDR_SIZE + (GET_IP6_HDR_SIZE(nbuf)))
     117
     118#define SET_IP6_CF(nbuf,cf)             (GET_IP6_HDR(nbuf)->vcf=htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(GET_IP6_HDR(nbuf)->vcf)),cf)))
     119#define SET_IP6_SDU_SIZE(nbuf,slen)     (GET_IP6_HDR(nbuf)->plen=htons(slen))
    121120
    122121/* ip6_output のフラグ */
     
    144143
    145144/*
    146  *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
    147  */
    148 
    149 #define T_TCP_IP_Q_HDR                  T_TCP_IP6_Q_HDR
    150 
    151 #define IF_IP_HDR_SIZE                  IF_IP6_HDR_SIZE
    152 
    153 #define GET_IP_HDR(nbuf)                GET_IP6_HDR(nbuf)
    154 #define GET_IP_SDU(nbuf)                GET_IP6_SDU(nbuf)
    155 
    156 #define GET_IP_HDR_SIZE(iph)            GET_IP6_HDR_SIZE(iph)
    157 #define GET_IP_SDU_SIZE(iph)            GET_IP6_SDU_SIZE(iph)
    158 #define GET_IF_IP_HDR_SIZE(nbuf)        GET_IF_IP6_HDR_SIZE(nbuf)
    159 
    160 #define SET_IP_SDU_SIZE(iph,len)        SET_IP6_SDU_SIZE(iph,len)
    161 
    162 #define IP_OUTPUT(nbuf,tmout)           ip6_output(nbuf,0,tmout)
    163 #define IP_INIT()                       ip6_init()
    164 #define IP_REMOVE_OPTIONS(nbuf)         ip6_remove_exthdrs(nbuf)
    165 
    166 /*
    167145 *  IPv6 の MMTU サイズのネットワークバッファ
    168146 */
     147
     148#if defined(IF_HDR_SIZE)
    169149
    170150typedef struct t_net_buf_ipv6_mmtu {
     
    181161                                /* バッファ本体               */
    182162        } T_NET_BUF_IPV6_MMTU;
     163
     164#endif  /* of #if defined(IF_HDR_SIZE) */
    183165
    184166/*
     
    258240 */
    259241
    260 typedef struct t_tcp_ip6_q_hdr {
     242typedef struct t_ip6_tcp_q_hdr {
    261243        uint8_t vc;             /* Version:        4 bit                */
    262244        uint8_t cf;             /* Traffic Class:  8 bit                */
     
    268250        T_IN6_ADDR src; /* Source Address                       */
    269251        T_IN6_ADDR dst; /* Destination Address                  */
    270         } __attribute__((packed, aligned(2)))T_TCP_IP6_Q_HDR;
     252        } __attribute__((packed, aligned(2))) T_IP6_TCP_Q_HDR;
    271253
    272254#ifdef SUPPORT_MIB
     
    304286
    305287/*
     288 *  変数
     289 */
     290
     291extern uint8_t  ip6_defhlim;
     292
     293/*
    306294 *  関数
    307295 */
     
    310298extern void ip6_init (void);
    311299extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
    312 extern uint_t get_ip6_hdr_size (T_IP6_HDR *iph);
     300extern uint_t get_ip6_hdr_size (T_NET_BUF *nbuf);
    313301extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
    314302extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
     
    320308extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
    321309
    322 #endif  /* of #ifdef SUPPORT_INET6 */
    323 
    324310#endif  /* of #ifndef _IP6_VAR_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg

    r321 r331  
    33 *  TINET (TCP/IP Protocol Stack)
    44 *
    5  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
     5 *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
    66 *                   Tomakomai National College of Technology, JAPAN
    77 *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.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 *
     
    9898#include <net/ethernet.h>
    9999#include <net/if_arp.h>
     100#include <net/ppp.h>
    100101#include <net/ppp_ipcp.h>
    101102#include <net/net.h>
     103#include <net/net_endian.h>
    102104#include <net/net_var.h>
    103105#include <net/net_buf.h>
     
    107109#include <netinet/in.h>
    108110#include <netinet/in_var.h>
    109 #include <netinet6/in6.h>
    110 #include <netinet6/in6_var.h>
     111#include <netinet/ip.h>
     112#include <netinet/ip_var.h>
     113#include <netinet/ip_icmp.h>
     114
    111115#include <netinet6/nd6.h>
    112116
    113 #include <netinet/ip6.h>
    114 #include <netinet/icmp6.h>
    115 #include <netinet6/ip6_var.h>
    116 
    117 #include <net/if6_var.h>
    118 
    119 #ifdef SUPPORT_INET6
     117#include <net/if_var.h>
     118
     119#ifdef _IP6_CFG
    120120
    121121/*
     
    328328
    329329T_LLINFO_ND6 *
    330 nd6_lookup (T_IN6_ADDR *addr, bool_t create)
     330nd6_lookup (const T_IN6_ADDR *addr, bool_t create)
    331331{
    332332        SYSTIM  min = 0xffffffff;
     
    370370
    371371T_LLINFO_ND6 *
    372 nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from,
     372nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from,
    373373                  T_IF_ADDR *lladdr, uint8_t type, uint8_t code)
    374374{
     
    487487
    488488bool_t
    489 nd6_is_addr_neighbor (T_IFNET *ifp, T_IN6_ADDR *addr)
     489nd6_is_addr_neighbor (T_IFNET *ifp, const T_IN6_ADDR *addr)
    490490{
    491491        if (IN6_IS_ADDR_LINKLOCAL(addr))
     
    508508
    509509ER
    510 nd6_output (T_IFNET *ifp, T_NET_BUF *output, T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
     510nd6_output (T_IFNET *ifp, T_NET_BUF *output, const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
    511511{
    512512        ER      error = E_OK;
     
    622622
    623623ER
    624 nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa)
     624nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa)
    625625{
    626626        if (IN6_IS_ADDR_MULTICAST(dst)) {
     
    696696        }
    697697
    698 #endif /* of #ifdef SUPPORT_INET6 */
     698#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h

    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 *
     
    6767#define _ND6_H_
    6868
    69 #ifdef SUPPORT_INET6
    70 
    7169/*
    7270 *  ネットワークインタフェース構造体(T_IFNET)のフラグ
     
    118116#define ND6_MAX_UCAST_QUERY             3               /* ユニキャストアドレス要請の再送回数    */
    119117
    120 #define ND6_INFINITE_LIFETIME           0xffffffff
    121 
    122118#define ND6_GCOLLECTION_TIME            (60*60*24*SYSTIM_HZ)
    123119                                                        /* ゴミ拾い周期、1 日                   */
     
    234230extern SYSTIM   nd6_recalc_reachtm_interval;
    235231extern SYSTIM   nd6_retrans_time;
    236 extern uint8_t  ip6_defhlim;
    237232
    238233/*
     
    241236
    242237extern void nd6_ifattach (T_IFNET *ifp);
    243 extern void nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
    244                            T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
    245 extern void nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
    246                            T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
     238extern void nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
     239                           const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
     240extern void nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
     241                           const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
    247242extern void nd6_dad_start (T_IFNET *ifp, T_IN6_IFADDR *ia, int_t *tick);
    248243extern ER nd6_output (T_IFNET *ifp, T_NET_BUF *output,
    249                       T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
     244                      const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
    250245extern void nd6_na_input (T_NET_BUF *input, uint_t off);
    251246extern void nd6_ns_input (T_NET_BUF *input, uint_t off);
    252247extern void nd6_ra_input (T_NET_BUF *input, uint_t off);
    253 extern ER nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa);
     248extern ER nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa);
    254249extern ER nd6_options (uint8_t *opt, void *nh, uint_t len);
    255 extern T_LLINFO_ND6 *nd6_lookup (T_IN6_ADDR *addr, bool_t create);
     250extern T_LLINFO_ND6 *nd6_lookup (const T_IN6_ADDR *addr, bool_t create);
    256251extern ER nd6_output_hold (T_IFNET *ifp, T_LLINFO_ND6 *ln);
    257 extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from,
     252extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from,
    258253                                       T_IF_ADDR *lladdr, uint8_t type, uint8_t code);
    259254extern void nd6_defrtrlist_timer (void);
    260255extern void nd6_prelist_timer (void);
    261256extern void nd6_rtrsol_ctl (void);
    262 extern T_IN6_ADDR *nd6_router_lookup (void);
    263 extern T_DEF_ROUTER *nd6_defrtrlist_lookup (T_IN6_ADDR *src);
     257extern const T_IN6_ADDR *nd6_router_lookup (void);
     258extern T_DEF_ROUTER *nd6_defrtrlist_lookup (const T_IN6_ADDR *src);
    264259extern void nd6_defrtrlist_del (T_DEF_ROUTER *dr);
    265260extern void nd6_timer (void);
     
    269264extern ER nd6_prefix_onlink (T_ND6_PREFIX *pr);
    270265extern ER nd6_prefix_offlink (T_ND6_PREFIX *pr);
    271 extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (T_IN6_ADDR *dst);
    272 
    273 #endif  /* of #ifdef SUPPORT_INET6 */
     266extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst);
    274267
    275268#endif  /* of #ifndef _ND6_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.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 *
     
    9393#include <net/ppp_ipcp.h>
    9494#include <net/net.h>
     95#include <net/net_endian.h>
    9596#include <net/net_var.h>
    9697#include <net/net_buf.h>
     
    100101#include <netinet/in.h>
    101102#include <netinet/in_var.h>
    102 
    103 #include <netinet6/in6.h>
    104 #include <netinet6/in6_var.h>
     103#include <netinet/ip.h>
     104#include <netinet/ip_var.h>
     105#include <netinet/ip_icmp.h>
     106
    105107#include <netinet6/nd6.h>
    106108
    107 #include <netinet/ip6.h>
    108 #include <netinet/icmp6.h>
    109 #include <netinet6/ip6_var.h>
    110 
    111109#include <net/if6_var.h>
    112110
    113 #ifdef SUPPORT_INET6
     111#ifdef _IP6_CFG
    114112
    115113/*
     
    363361
    364362void
    365 nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
    366                T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
     363nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
     364               const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
    367365{
    368366        T_NEIGHBOR_SOLICIT_HDR  *nsh;
     
    429427
    430428                if (saddr && in6_lookup_ifaddr(ifp, saddr))
    431                         ip6h->src = *saddr;
     429                        memcpy(&ip6h->src, saddr, sizeof(T_IN6_ADDR));
    432430                else {
    433431                        /*
     
    441439                                return;
    442440                                }
    443                         ip6h->src = ifa->addr;
     441                        memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
    444442                        }
    445443                }
     
    455453        nsh->hdr.code        = 0;
    456454        nsh->hdr.data.data32 = 0;
    457         nsh->target          = *taddr;
     455        memcpy(&nsh->target, taddr, sizeof(T_IN6_ADDR));
    458456
    459457        if (!dad && (mac = IF_SOFTC_TO_IFADDR(ifp->ic)) != NULL) {
     
    699697
    700698void
    701 nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
    702                T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
     699nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
     700               const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
    703701{
    704702        T_NEIGHBOR_ADVERT_HDR   *nah;
     
    747745                }
    748746        else
    749                 ip6h->dst = *daddr;
     747                memcpy(&ip6h->dst, daddr, sizeof(T_IN6_ADDR));
    750748
    751749        /*
     
    757755                return;
    758756                }
    759         ip6h->src = ifa->addr;
    760 
    761         /* 近隣通知ヘッダを設定する。*/
    762         nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
    763         nah->hdr.type        = ND_NEIGHBOR_ADVERT;
    764         nah->hdr.code        = 0;
    765         nah->target          = *taddr;
     757        memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
     758
     759        /* 近隣通知ヘッダを設定する。*/
     760        nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
     761        nah->hdr.type        = ND_NEIGHBOR_ADVERT;
     762        nah->hdr.code        = 0;
     763        memcpy(&nah->target, taddr, sizeof(T_IN6_ADDR));
    766764
    767765        /* tlladdr が真ならネットワークインタフェースのアドレスを追加する。*/
     
    851849        }
    852850
    853 #endif /* of #ifdef SUPPORT_INET6 */
     851#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.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 *
     
    9393#include <net/ppp_ipcp.h>
    9494#include <net/net.h>
     95#include <net/net_endian.h>
    9596#include <net/net_var.h>
    9697#include <net/net_buf.h>
     
    100101#include <netinet/in.h>
    101102#include <netinet/in_var.h>
    102 #include <netinet6/in6.h>
    103 #include <netinet6/in6_var.h>
     103#include <netinet/ip.h>
     104#include <netinet/ip_var.h>
     105#include <netinet/ip_icmp.h>
     106
    104107#include <netinet6/nd6.h>
    105108#include <netinet6/in6_ifattach.h>
    106 #include <netinet/ip6.h>
    107 #include <netinet/icmp6.h>
    108 #include <netinet6/ip6_var.h>
    109 
    110 #include <net/if6_var.h>
     109
     110#include <net/if_var.h>
    111111
    112112/*
     
    116116extern const char *itron_strerror (ER ercd);
    117117
    118 #ifdef SUPPORT_INET6
     118#ifdef _IP6_CFG
    119119
    120120#if NUM_ND6_DEF_RTR_ENTRY > 0
     
    284284         */
    285285        for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    286                 ia = &ifp->in_ifaddrs[ix];
     286                ia = &ifp->in6_ifaddrs[ix];
    287287                if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
    288288                     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
     
    299299                 */
    300300                for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    301                         ia = &ifp->in_ifaddrs[ix];
     301                        ia = &ifp->in6_ifaddrs[ix];
    302302                        if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
    303303                             ia->prefix_index != ND6_PREFIX_IX_INVALID) {
     
    316316                 */
    317317                for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
    318                         ia = &ifp->in_ifaddrs[ix];
     318                        ia = &ifp->in6_ifaddrs[ix];
    319319                        if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0)
    320320                                ia->flags &= ~IN6_IFF_DETACHED;
     
    448448        /* 各メンバに値を設定する。*/
    449449        fdr->plistmap = 0;
    450         fdr->addr     = *src;
     450        memcpy(&fdr->addr, src, sizeof(T_IN6_ADDR));
    451451        fdr->lifetime = lifetime * SYSTIM_HZ;           /* lifetime の単位は秒 */
    452452        fdr->flags    = flags;
     
    478478        int_t           ix;
    479479
    480         lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
     480        lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
    481481
    482482        /*
     
    585585
    586586        /* リンクローカルアドレスが未登録であれば何もしない。*/
    587         lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
     587        lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
    588588        if ((lla->flags & IN6_IFF_DEFINED) == 0)
    589589                return E_OK;
     
    594594         */
    595595        for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
    596                 ia = &ifp->in_ifaddrs[ix];
     596                ia = &ifp->in6_ifaddrs[ix];
    597597                if (ia->prefix_index == (pr - nd6_prefix))
    598598                        break;
     
    634634         */
    635635        for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
    636                 ia = &ifp->in_ifaddrs[ix];
     636                ia = &ifp->in6_ifaddrs[ix];
    637637                if (ia->prefix_index == (pr - nd6_prefix))
    638638                        break;
     
    692692        T_ND6_PREFIX    *pr = NULL;
    693693        int_t           ix;
    694         ER              error;
    695694
    696695        /* プレフィックスリストから空きのプレフィックスエントリを探索する。*/
     
    723722
    724723        if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) != 0) {
    725                 if ((error = nd6_prefix_onlink(pr)) != E_OK)
     724                if (nd6_prefix_onlink(pr) != E_OK)
    726725                        return NULL;
    727726                }
     
    812811                        }
    813812
     813#if 1           /* プレフィックスが未登録の場合だけ表示する。*/
     814                syslog(LOG_NOTICE, "[ND6 RTR] add prefix: flags[MOH]: %02x, addr: %s\n"
     815                                   "                                      from: %s.",
     816                                   nd6_def_router[router_index].flags,
     817                                   ipv62str(NULL, &pi->prefix),
     818                                   ipv62str(NULL, &nd6_def_router[router_index].addr));
     819#endif
    814820                if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0) {
    815821                        /*
     
    836842         */
    837843        for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
    838                 ia = &ifp->in_ifaddrs[ix];
     844                ia = &ifp->in6_ifaddrs[ix];
    839845                if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
    840846                    ia->prefix_len == pr->prefix_len &&
     
    892898                                }
    893899
    894                         lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
     900                        lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
    895901
    896902                        /* プレフィックスマスクを生成する。*/
     
    922928
    923929                        for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
    924                                 ia = &ifp->in_ifaddrs[ix];
     930                                ia = &ifp->in6_ifaddrs[ix];
    925931                                if ((ia->flags & IN6_IFF_DEFINED) == 0) {
    926932                                        in6_ifadd(pr, ia, router_index);
     
    971977        T_NET_BUF               *output;
    972978        T_IN6_IFADDR            *ifa;
    973         T_IN6_ADDR              *saddr;
     979        const T_IN6_ADDR        *saddr;
    974980        uint16_t                len;
    975981
     
    10171023
    10181024T_DEF_ROUTER *
    1019 nd6_defrtrlist_lookup (T_IN6_ADDR *src)
     1025nd6_defrtrlist_lookup (const T_IN6_ADDR *src)
    10201026{
    10211027        T_DEF_ROUTER    *dr = NULL;
     
    10361042 */
    10371043
    1038 T_IN6_ADDR *
     1044const T_IN6_ADDR *
    10391045nd6_router_lookup (void)
    10401046{
     
    12601266                                syslog(LOG_NOTICE, "[ND6 RTR] preferred(%d) > valid time(%d).", ntohl(pi->preferred), ntohl(pi->valid));
    12611267                        else {
    1262                                 syslog(LOG_NOTICE, "[ND6 RTR] update prefix: %s from %s.",
    1263                                                    ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
     1268#if 0   /* プレフィックスが未登録の場合だけ表示する。*/
     1269                                syslog(LOG_NOTICE, "[ND6 RTR] update prefix: flags[MOH]: %02x, addr: %s\n"
     1270                                                   "                                         from: %s.",
     1271                                                   rah->nd_ra_flags, ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
     1272#endif
    12641273                                if (rix >= 0) {
    12651274                                        /*
     
    13911400
    13921401T_ND6_PREFIX *
    1393 nd6_onlink_prefix_lookup (T_IN6_ADDR *dst)
     1402nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst)
    13941403{
    13951404        SYSTIM          now;
     
    14271436        }
    14281437
    1429 #endif /* of #ifdef SUPPORT_INET6 */
     1438#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.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 *
     
    8282
    8383#include <net/net.h>
     84#include <net/net_endian.h>
    8485#include <net/if.h>
    8586#include <net/if_loop.h>
     
    9293
    9394#include <netinet/in.h>
    94 #include <netinet6/in6.h>
    95 #include <netinet6/in6_var.h>
     95#include <netinet/in_var.h>
     96#include <netinet/ip.h>
     97#include <netinet/ip_var.h>
     98#include <netinet/ip_icmp.h>
    9699#include <netinet6/nd6.h>
    97 #include <netinet/ip6.h>
    98 #include <netinet6/ip6_var.h>
    99 #include <netinet/icmp6.h>
    100 
    101 #ifdef SUPPORT_INET6
     100
     101#ifdef _IP6_CFG
    102102
    103103#if 0
    104         /*
    105         *  通信帯域を食いつぶす攻撃への対応のため、
    106         *  タイプ 0 経路制御ヘッダの処理を行わない。
    107         */
     104/*
     105 *  通信帯域を食いつぶす攻撃への対応のため、
     106 *  タイプ 0 経路制御ヘッダの処理を行わない。
     107 */
    108108
    109109/*
     
    229229        }
    230230
    231 #endif /* of #ifdef SUPPORT_INET6 */
     231#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.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 *
     
    123123#include <net/ethernet.h>
    124124#include <net/net.h>
     125#include <net/net_endian.h>
    125126#include <net/net_buf.h>
     127
     128#include <netinet/in.h>
     129#include <netinet/in_var.h>
    126130
    127131#include <netinet6/in6.h>
    128132#include <netinet6/in6_var.h>
    129133
    130 #ifdef SUPPORT_INET6
     134#ifdef _IP6_CFG
    131135
    132136/*
     
    135139
    136140uint_t
    137 in6_addrscope (T_IN6_ADDR *addr)
     141in6_addrscope (const T_IN6_ADDR *addr)
    138142{
    139143        uint_t scope;
     
    168172        }
    169173
    170 #endif /* of #ifdef SUPPORT_INET6 */
     174#endif /* of #ifdef _IP6_CFG */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def

    • Property svn:keywords deleted
    r279 r331  
    1 TCP_CRE_REP  #tcp4_repid* { .tcp4_repatr { &ipv4addr &portno } }
    2 TCP6_CRE_REP #tcp6_repid* { .tcp6_repatr { &ipv6addr &portno } }
    3 TCP_CRE_CEP  #tcp4_cepid* { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }
    4 TCP6_CRE_CEP #tcp6_cepid* { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }
    5 UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback }
    6 UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback }
    7 VRID_TCP4_REP  #vrid_tcp4_repid*
    8 VRID_TCP4_CEP  #vrid_tcp4_cepid*
    9 VRID_TCP6_REP #vrid_tcp6_repid*
    10 VRID_TCP6_CEP #vrid_tcp6_cepid*
    11 VRID_UDP4_CEP  #vrid_udp4_cepid*
    12 VRID_UDP6_CEP #vrid_udp6_cepid*
     1TCP_CRE_REP  #tcp4_repid* { .tcp4_repatr { &ipv4addr &portno } } 
     2TCP6_CRE_REP #tcp6_repid* { .tcp6_repatr { &ipv6addr &portno } } 
     3TCP_CRE_CEP  #tcp4_cepid* { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback } 
     4TCP6_CRE_CEP #tcp6_cepid* { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback } 
     5UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback } 
     6UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback } 
     7VRID_TCP_REP  #vrid_tcp4_repid* 
     8VRID_TCP_CEP  #vrid_tcp4_cepid* 
     9VRID_TCP6_REP #vrid_tcp6_repid* 
     10VRID_TCP6_CEP #vrid_tcp6_cepid* 
     11VRID_UDP_CEP  #vrid_udp4_cepid* 
     12VRID_UDP6_CEP #vrid_udp6_cepid* 
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def

    • Property svn:keywords deleted
    r270 r331  
    4848TCP_REP_FLG_DYNAMIC
    4949TCP_REP_FLG_VALID
     50TCP_CEP_FLG_IPV4
    5051TCP_CEP_FLG_ACK_NOW
    5152TCP_CEP_FLG_DEL_ACK
     
    7374TCP_CEP_FLG_WBCS_SENT
    7475TCP_CEP_FLG_WBCS_ACKED
     76TCP_CEP_FLG_NOT_CLEAR
    7577TCP_CEP_EVT_ESTABLISHED
    7678TCP_CEP_EVT_CLOSED
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb

    r321 r331  
    4747$tinetCfgH.add()
    4848
    49 $cfgData[:TCP_CRE_REP].each do |key, params|
    50         $tinetCfgH.add("#define #{params[:tcp4_repid]}  #{params[:tcp4_repid].val}")
    51 end
     49$tinetCfgH.add("#define TNUM_TCP6_REPID #{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
     50$tinetCfgH.add("#define TNUM_TCP4_REPID #{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
     51$tinetCfgH.add("#define TNUM_TCP_REPID  #{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size + $cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
     52$tinetCfgH.add()
     53
     54$tinetCfgH.add("#define TNUM_TCP6_CEPID #{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
     55$tinetCfgH.add("#define TNUM_TCP4_CEPID #{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
     56$tinetCfgH.add("#define TNUM_TCP_CEPID  #{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size + $cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
     57$tinetCfgH.add()
     58
     59$tinetCfgH.add("#define TNUM_UDP6_CEPID #{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
     60$tinetCfgH.add("#define TNUM_UDP4_CEPID #{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
     61$tinetCfgH.add("#define TNUM_UDP_CEPID  #{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size + $cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
     62$tinetCfgH.add()
     63
    5264$cfgData[:TCP6_CRE_REP].each do |key, params|
    5365        $tinetCfgH.add("#define #{params[:tcp6_repid]}  #{params[:tcp6_repid].val}")
    5466end
    55 $cfgData[:TCP_CRE_CEP].each do |key, params|
    56         $tinetCfgH.add("#define #{params[:tcp4_cepid]}  #{params[:tcp4_cepid].val}")
    57 end
     67$cfgData[:VRID_TCP6_REP].each do |key, params|
     68        $tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}     #{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
     69end
     70$cfgData[:TCP_CRE_REP].each do |key, params|
     71        $tinetCfgH.add("#define #{params[:tcp4_repid]}  #{params[:tcp4_repid].val + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
     72end
     73$cfgData[:VRID_TCP_REP].each do |key, params|
     74        $tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}     #{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
     75end
     76$tinetCfgH.add()
     77
    5878$cfgData[:TCP6_CRE_CEP].each do |key, params|
    5979        $tinetCfgH.add("#define #{params[:tcp6_cepid]}  #{params[:tcp6_cepid].val}")
    6080end
    61 $cfgData[:UDP_CRE_CEP].each do |key, params|
    62         $tinetCfgH.add("#define #{params[:udp4_cepid]}  #{params[:udp4_cepid].val}")
    63 end
     81$cfgData[:VRID_TCP6_CEP].each do |key, params|
     82        $tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}     #{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
     83end
     84$cfgData[:TCP_CRE_CEP].each do |key, params|
     85        $tinetCfgH.add("#define #{params[:tcp4_cepid]}  #{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
     86end
     87$cfgData[:VRID_TCP_CEP].each do |key, params|
     88        $tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}     #{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
     89end
     90$tinetCfgH.add()
     91
    6492$cfgData[:UDP6_CRE_CEP].each do |key, params|
    6593        $tinetCfgH.add("#define #{params[:udp6_cepid]}  #{params[:udp6_cepid].val}")
    6694end
    67 $cfgData[:VRID_TCP4_REP].each do |key, params|
    68         $tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}     #{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}")
    69 end
    70 $cfgData[:VRID_TCP4_CEP].each do |key, params|
    71         $tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}     #{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}")
    72 end
    73 $cfgData[:VRID_TCP6_REP].each do |key, params|
    74         $tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}     #{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
    75 end
    76 $cfgData[:VRID_TCP6_CEP].each do |key, params|
    77         $tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}     #{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
    78 end
    79 $cfgData[:VRID_UDP4_CEP].each do |key, params|
    80         $tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}     #{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}")
    81 end
    8295$cfgData[:VRID_UDP6_CEP].each do |key, params|
    8396        $tinetCfgH.add("#define #{params[:vrid_udp6_cepid]}     #{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}")
     97end
     98$cfgData[:UDP_CRE_CEP].each do |key, params|
     99        $tinetCfgH.add("#define #{params[:udp4_cepid]}  #{params[:udp4_cepid].val + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
     100end
     101$cfgData[:VRID_UDP_CEP].each do |key, params|
     102        $tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}     #{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
    84103end
    85104$tinetCfgH.add()
     
    110129#include <netinet/in_itron.h>
    111130#include <netinet/ip.h>
    112 #include <netinet/ip6.h>
    113131#include <netinet/tcp.h>
    114 #include <netinet/tcp_timer.h>
    115132#include <netinet/tcp_var.h>
    116 #include <netinet/tcp_fsm.h>
    117133#include <netinet/udp_var.h>
    118134
     
    130146end
    131147
     148$tinetCfgC.add()
     149$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP6_REPID + TNUM_TCP4_REPID - 1);")
     150
     151$tinetCfgC.add()
     152$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
     153$tinetCfgC.add("const ID tmax_tcp6_repid = (TMIN_TCP6_REPID + TNUM_TCP6_REPID - 1);")
     154$tinetCfgC.add("const ID tmax_tcp4_repid = (TMIN_TCP4_REPID + TNUM_TCP4_REPID - 1);")
     155$tinetCfgC.add("#endif")
     156
     157$tinetCfgC.add()
     158$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID + TNUM_TCP4_CEPID - 1);")
     159
     160$tinetCfgC.add()
     161$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
     162$tinetCfgC.add("const ID tmax_tcp6_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID - 1);")
     163$tinetCfgC.add("const ID tmax_tcp4_cepid = (TMIN_TCP_CEPID + TNUM_TCP4_CEPID - 1);")
     164$tinetCfgC.add("#endif")
     165
     166$tinetCfgC.add()
     167$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP6_CEPID + TNUM_UDP4_CEPID - 1);")
     168
     169$tinetCfgC.add()
     170$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
     171$tinetCfgC.add("const ID tmax_udp6_cepid = (TMIN_UDP6_CEPID + TNUM_UDP6_CEPID - 1);")
     172$tinetCfgC.add("const ID tmax_udp4_cepid = (TMIN_UDP4_CEPID + TNUM_UDP4_CEPID - 1);")
     173$tinetCfgC.add("#endif")
     174
     175#       // TCP (IPv6) 受付口
     176$sem_tcp_rep_lock_id = 0
     177if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
     178        $tinetCfgC.add()
     179        $tinetCfgC.add("T_TCP6_REP tcp6_rep[TNUM_TCP6_REPID] = {")
     180        $cfgData[:TCP6_CRE_REP].each do |key, params|
     181                $tinetCfgC.add("\t{")
     182                        $tinetCfgC.add("\t\t#{params[:tcp6_repatr]},")
     183                        $tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
     184                $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
     185                        $tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
     186                        $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
     187                $tinetCfgC.add("#endif")
     188                        $tinetCfgC.add("\t\t},")
     189                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     190        end
     191        $cfgData[:VRID_TCP6_REP].each do |key, params|
     192                $tinetCfgC.add("\t{")
     193                        $tinetCfgC.add("\t\t0,")
     194                        $tinetCfgC.add("\t\t{ IPV6_ADDRANY, TCP_PORTANY },")
     195        $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
     196                        $tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
     197                        $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
     198        $tinetCfgC.add("#endif")
     199                        $tinetCfgC.add("\t\t},")
     200                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     201        end
     202        $tinetCfgC.add("\t};")
     203end
     204
    132205#       // TCP (IPv4) 受付口
    133 if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
     206if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
    134207        $tinetCfgC.add()
    135         $tinetCfgC.add("#define TNUM_TCP_REPID  #{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP4_REP].size}")
    136         $tinetCfgC.add()
    137         $tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);")
    138         $tinetCfgC.add()
    139         $tinetCfgC.add("T_TCP_REP tcp_rep[TNUM_TCP_REPID] = {")
     208        $tinetCfgC.add("T_TCP4_REP tcp4_rep[TNUM_TCP4_REPID] = {")
    140209        $cfgData[:TCP_CRE_REP].each do |key, params|
    141210                $tinetCfgC.add("\t{")
     
    144213        $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
    145214                        $tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
    146                         $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp4_repid].val},")
     215                        $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
    147216        $tinetCfgC.add("#endif")
    148217                        $tinetCfgC.add("\t\t},")
    149         end
    150         $cfgData[:VRID_TCP4_REP].each do |key, params|
     218                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     219        end
     220        $cfgData[:VRID_TCP_REP].each do |key, params|
    151221                $tinetCfgC.add("\t{")
    152222                        $tinetCfgC.add("\t\t0,")
     
    154224        $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
    155225                        $tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
    156                         $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size},")
     226                        $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
    157227        $tinetCfgC.add("#endif")
    158228                        $tinetCfgC.add("\t\t},")
    159         end
    160                 $tinetCfgC.add("\t};")
    161 end
    162 
    163 #       // TCP (IPv6) 受付口
    164 if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
     229                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     230        end
     231        $tinetCfgC.add("\t};")
     232end
     233
     234#       // TCP 通信端点
     235if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0 || $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
    165236        $tinetCfgC.add()
    166         $tinetCfgC.add("#define TNUM_TCP_REPID  #{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
    167         $tinetCfgC.add()
    168         $tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);")
    169         $tinetCfgC.add()
    170         $tinetCfgC.add("T_TCP6_REP tcp_rep[TNUM_TCP_REPID] = {")
    171         $cfgData[:TCP6_CRE_REP].each do |key, params|
    172                 $tinetCfgC.add("\t{")
    173                         $tinetCfgC.add("\t\t#{params[:tcp6_repatr]},")
    174                         $tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
    175         $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
    176                         $tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
    177                         $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp6_repid].val},")
    178         $tinetCfgC.add("#endif")
    179                         $tinetCfgC.add("\t\t},")
    180         end
    181         $cfgData[:VRID_TCP6_REP].each do |key, params|
    182                 $tinetCfgC.add("\t{")
    183                         $tinetCfgC.add("\t\t0,")
    184                         $tinetCfgC.add("\t\t{ IPV6_ADDRANY, TCP_PORTANY },")
    185         $tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
    186                         $tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
    187                         $tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size},")
    188         $tinetCfgC.add("#endif")
    189                         $tinetCfgC.add("\t\t},")
    190         end
    191                 $tinetCfgC.add("\t};")
    192 end
    193 
    194 #       // TCP (IPv4) 通信端点
    195 if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
    196         $tinetCfgC.add()
    197         $tinetCfgC.add("#define TNUM_TCP_CEPID  #{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP4_CEP].size}")
    198         $tinetCfgC.add()
    199         $tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);")
    200         $tinetCfgC.add()
    201         $tinetCfgC.add("T_TCP_CEP tcp_cep[TNUM_TCP_CEPID] = {")
    202         $cfgData[:TCP_CRE_CEP].each do |key, params|
    203                 $tinetCfgC.add("\t{")
    204                         $tinetCfgC.add("\t\t#{params[:tcp4_cepatr]},")
    205                         $tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
    206                         $tinetCfgC.add("\t\t#{params[:sbufsz]},")
    207                         $tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
    208                         $tinetCfgC.add("\t\t#{params[:rbufsz]},")
    209                         $tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
    210                         $tinetCfgC.add("\t\tTCP_CEP_FLG_VALID,")
    211                         $tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val},")
    212                         $tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val},")
    213                         $tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val},")
    214                         $tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val},")
    215                         $tinetCfgC.add("\t\t},")
    216         end
    217         $cfgData[:VRID_TCP4_CEP].each do |key, params|
    218                 $tinetCfgC.add("\t{")
    219                         $tinetCfgC.add("\t\t0,")
    220                         $tinetCfgC.add("\t\t(void*)NULL,")
    221                         $tinetCfgC.add("\t\t0,")
    222                         $tinetCfgC.add("\t\t(void*)NULL,")
    223                         $tinetCfgC.add("\t\t0,")
    224                         $tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
    225                         $tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC,")
    226                         $tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
    227                         $tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
    228                         $tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
    229                         $tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
    230                         $tinetCfgC.add("\t\t},")
    231         end
    232                 $tinetCfgC.add("\t};")
    233 end
    234 
    235 #       // TCP (IPv6) 通信端点
    236 if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0
    237         $tinetCfgC.add()
    238         $tinetCfgC.add("#define TNUM_TCP_CEPID  #{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
    239         $tinetCfgC.add()
    240         $tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);")
    241         $tinetCfgC.add()
    242         $tinetCfgC.add("T_TCP6_CEP tcp_cep[TNUM_TCP_CEPID] = {")
     237        $tinetCfgC.add("T_TCP_CEP tcp_cep[TNUM_TCP6_CEPID + TNUM_TCP4_CEPID] = {")
    243238        $cfgData[:TCP6_CRE_CEP].each do |key, params|
    244239                $tinetCfgC.add("\t{")
     
    271266                        $tinetCfgC.add("\t\t},")
    272267        end
     268        $cfgData[:TCP_CRE_CEP].each do |key, params|
     269                $tinetCfgC.add("\t{")
     270                        $tinetCfgC.add("\t\t#{params[:tcp4_cepatr]},")
     271                        $tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
     272                        $tinetCfgC.add("\t\t#{params[:sbufsz]},")
     273                        $tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
     274                        $tinetCfgC.add("\t\t#{params[:rbufsz]},")
     275                        $tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
     276                        $tinetCfgC.add("\t\tTCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4,")
     277                        $tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     278                        $tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     279                        $tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     280                        $tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     281                        $tinetCfgC.add("\t\t},")
     282        end
     283        $cfgData[:VRID_TCP_CEP].each do |key, params|
     284                $tinetCfgC.add("\t{")
     285                        $tinetCfgC.add("\t\t0,")
     286                        $tinetCfgC.add("\t\t(void*)NULL,")
     287                        $tinetCfgC.add("\t\t0,")
     288                        $tinetCfgC.add("\t\t(void*)NULL,")
     289                        $tinetCfgC.add("\t\t0,")
     290                        $tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
     291                        $tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_IPV4,")
     292                        $tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     293                        $tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     294                        $tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     295                        $tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
     296                        $tinetCfgC.add("\t\t},")
     297        end
    273298                $tinetCfgC.add("\t};")
    274299end
    275300
     301#       // UDP (IPv6) 通信端点
     302if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
     303        $tinetCfgC.add()
     304        $tinetCfgC.add("T_UDP6_CEP udp6_cep[TNUM_UDP6_CEPID] = {")
     305        $cfgData[:UDP6_CRE_CEP].each do |key, params|
     306                $tinetCfgC.add("\t{")
     307                        $tinetCfgC.add("\t\t#{params[:udp6_cepatr]},")
     308                        $tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
     309                        $tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
     310                        $tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
     311                        $tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val},")
     312                        $tinetCfgC.add("\t\tTA_NULL,")
     313                        $tinetCfgC.add("\t\tTA_NULL,")
     314                        $tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:udp6_cepid].val},")
     315                        $tinetCfgC.add("\t\t},")
     316        end
     317        $cfgData[:VRID_UDP6_CEP].each do |key, params|
     318                $tinetCfgC.add("\t{")
     319                        $tinetCfgC.add("\t\t0,")
     320                        $tinetCfgC.add("\t\t{ IPV6_ADDRANY, UDP_PORTANY },")
     321                        $tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
     322                        $tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
     323                        $tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
     324                        $tinetCfgC.add("\t\tTA_NULL,")
     325                        $tinetCfgC.add("\t\tTA_NULL,")
     326                        $tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
     327                        $tinetCfgC.add("\t\t},")
     328        end
     329                $tinetCfgC.add("\t};")
     330end
     331
    276332#       // UDP (IPv4) 通信端点
    277 if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
     333if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
    278334        $tinetCfgC.add()
    279         $tinetCfgC.add("#define TNUM_UDP_CEPID  #{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP4_CEP].size}")
    280         $tinetCfgC.add()
    281         $tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);")
    282         $tinetCfgC.add()
    283         $tinetCfgC.add("T_UDP_CEP udp_cep[TNUM_UDP_CEPID] = {")
     335        $tinetCfgC.add("T_UDP4_CEP udp4_cep[TNUM_UDP4_CEPID] = {")
    284336        $cfgData[:UDP_CRE_CEP].each do |key, params|
    285337                $tinetCfgC.add("\t{")
     
    288340                        $tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
    289341                        $tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
    290                         $tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp4_cepid].val},")
    291                         $tinetCfgC.add("\t\tTA_NULL,")
    292                         $tinetCfgC.add("\t\tTA_NULL,")
    293                         $tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp4_cepid].val},")
    294                         $tinetCfgC.add("\t\t},")
    295         end
    296         $cfgData[:VRID_UDP4_CEP].each do |key, params|
     342                        $tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val},")
     343                        $tinetCfgC.add("\t\tTA_NULL,")
     344                        $tinetCfgC.add("\t\tTA_NULL,")
     345                        $tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:udp4_cepid].val},")
     346                        $tinetCfgC.add("\t\t},")
     347        end
     348        $cfgData[:VRID_UDP_CEP].each do |key, params|
    297349                $tinetCfgC.add("\t{")
    298350                        $tinetCfgC.add("\t\t0,")
     
    300352                        $tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
    301353                        $tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
    302                         $tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
    303                         $tinetCfgC.add("\t\tTA_NULL,")
    304                         $tinetCfgC.add("\t\tTA_NULL,")
    305                         $tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
     354                        $tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
     355                        $tinetCfgC.add("\t\tTA_NULL,")
     356                        $tinetCfgC.add("\t\tTA_NULL,")
     357                        $tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
    306358                        $tinetCfgC.add("\t\t},")
    307359        end
     
    309361end
    310362
    311 #       // UDP (IPv6) 通信端点
    312 if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
    313         $tinetCfgC.add()
    314         $tinetCfgC.add("#define TNUM_UDP_CEPID  #{cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
    315         $tinetCfgC.add()
    316         $tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);")
    317         $tinetCfgC.add()
    318         $tinetCfgC.add("T_UDP6_CEP udp_cep[TNUM_UDP_CEPID] = {")
    319         $cfgData[:UDP6_CRE_CEP].each do |key, params|
    320                 $tinetCfgC.add("\t{")
    321                         $tinetCfgC.add("\t\t#{params[:udp6_cepatr]},")
    322                         $tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
    323                         $tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
    324                         $tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
    325                         $tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp6_cepid].val},")
    326                         $tinetCfgC.add("\t\tTA_NULL,")
    327                         $tinetCfgC.add("\t\tTA_NULL,")
    328                         $tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp6_cepid].val},")
    329                         $tinetCfgC.add("\t\t},")
    330         end
    331         $cfgData[:VRID_UDP6_CEP].each do |key, params|
    332                 $tinetCfgC.add("\t{")
    333                         $tinetCfgC.add("\t\t0,")
    334                         $tinetCfgC.add("\t\t{ IPV6_ADDRANY, UDP_PORTANY },")
    335                         $tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
    336                         $tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
    337                         $tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
    338                         $tinetCfgC.add("\t\tTA_NULL,")
    339                         $tinetCfgC.add("\t\tTA_NULL,")
    340                         $tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
    341                         $tinetCfgC.add("\t\t},")
    342         end
    343                 $tinetCfgC.add("\t};")
    344 end
    345 
    346363# =====================================================================
    347364# tinet_kern.cfg の生成
    348365# =====================================================================
    349366
    350 #       // TCP (IPv4) 受付口
    351 if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
    352         $cfgData[:TCP_CRE_REP].each do |key, params|
    353                 cfgInfo = { APINAME: "CRE_SEM" }
    354                 cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp4_repid].val}"
    355                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    356                 cfgInfo["isemcnt"] = 1
    357                 cfgInfo["maxsem"] = 1
    358                 $cfgFileInfo.push(cfgInfo)
    359         end
    360         $cfgData[:VRID_TCP4_REP].each do |key, params|
    361                 cfgInfo = { APINAME: "CRE_SEM" }
    362                 cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}"
    363                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    364                 cfgInfo["isemcnt"] = 1
    365                 cfgInfo["maxsem"] = 1
    366                 $cfgFileInfo.push(cfgInfo)
    367         end
    368 end
    369 
    370367#       // TCP (IPv6) 受付口
     368$sem_tcp_rep_lock_id = 0
    371369if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
    372370        $cfgData[:TCP6_CRE_REP].each do |key, params|
    373371                cfgInfo = { APINAME: "CRE_SEM" }
    374                 cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp6_repid].val}"
    375                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    376                 cfgInfo["isemcnt"] = 1
    377                 cfgInfo["maxsem"] = 1
    378                 $cfgFileInfo.push(cfgInfo)
     372                cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
     373                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     374                cfgInfo["isemcnt"] = 1
     375                cfgInfo["maxsem"] = 1
     376                $cfgFileInfo.push(cfgInfo)
     377
     378                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
    379379        end
    380380        $cfgData[:VRID_TCP6_REP].each do |key, params|
    381381                cfgInfo = { APINAME: "CRE_SEM" }
    382                 cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}"
    383                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    384                 cfgInfo["isemcnt"] = 1
    385                 cfgInfo["maxsem"] = 1
    386                 $cfgFileInfo.push(cfgInfo)
    387         end
    388 end
    389 
    390 #       // TCP (IPv4) 通信端点
    391 if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
    392         $cfgData[:TCP_CRE_CEP].each do |key, params|
    393                 cfgInfo = { APINAME: "CRE_SEM" }
    394                 cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val}"
    395                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    396                 cfgInfo["isemcnt"] = 1
    397                 cfgInfo["maxsem"] = 1
    398                 $cfgFileInfo.push(cfgInfo)
    399 
    400                 cfgInfo = { APINAME: "CRE_FLG" }
    401                 cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val}"
    402                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    403                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    404                 $cfgFileInfo.push(cfgInfo)
    405 
    406                 cfgInfo = { APINAME: "CRE_FLG" }
    407                 cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val}"
    408                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    409                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    410                 $cfgFileInfo.push(cfgInfo)
    411 
    412                 cfgInfo = { APINAME: "CRE_FLG" }
    413                 cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val}"
    414                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    415                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    416                 $cfgFileInfo.push(cfgInfo)
    417         end
    418         $cfgData[:VRID_TCP4_CEP].each do |key, params|
    419                 cfgInfo = { APINAME: "CRE_SEM" }
    420                 cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
    421                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    422                 cfgInfo["isemcnt"] = 1
    423                 cfgInfo["maxsem"] = 1
    424                 $cfgFileInfo.push(cfgInfo)
    425 
    426                 cfgInfo = { APINAME: "CRE_FLG" }
    427                 cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
    428                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    429                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    430                 $cfgFileInfo.push(cfgInfo)
    431 
    432                 cfgInfo = { APINAME: "CRE_FLG" }
    433                 cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
    434                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    435                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    436                 $cfgFileInfo.push(cfgInfo)
    437 
    438                 cfgInfo = { APINAME: "CRE_FLG" }
    439                 cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
    440                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    441                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    442                 $cfgFileInfo.push(cfgInfo)
     382                cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
     383                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     384                cfgInfo["isemcnt"] = 1
     385                cfgInfo["maxsem"] = 1
     386                $cfgFileInfo.push(cfgInfo)
     387
     388                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     389        end
     390end
     391
     392#       // TCP (IPv4) 受付口
     393if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
     394        $cfgData[:TCP_CRE_REP].each do |key, params|
     395                cfgInfo = { APINAME: "CRE_SEM" }
     396                cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
     397                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     398                cfgInfo["isemcnt"] = 1
     399                cfgInfo["maxsem"] = 1
     400                $cfgFileInfo.push(cfgInfo)
     401
     402                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
     403        end
     404        $cfgData[:VRID_TCP_REP].each do |key, params|
     405                cfgInfo = { APINAME: "CRE_SEM" }
     406                cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
     407                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     408                cfgInfo["isemcnt"] = 1
     409                cfgInfo["maxsem"] = 1
     410                $cfgFileInfo.push(cfgInfo)
     411
     412                $sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
    443413        end
    444414end
     
    463433                cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp6_cepid].val}"
    464434                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     435                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
     436                $cfgFileInfo.push(cfgInfo)
     437
     438                cfgInfo = { APINAME: "CRE_FLG" }
     439                cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val}"
     440                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     441                cfgInfo["iflgptn"] = 0
     442                $cfgFileInfo.push(cfgInfo)
     443        end
     444        $cfgData[:VRID_TCP6_CEP].each do |key, params|
     445                cfgInfo = { APINAME: "CRE_SEM" }
     446                cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
     447                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     448                cfgInfo["isemcnt"] = 1
     449                cfgInfo["maxsem"] = 1
     450                $cfgFileInfo.push(cfgInfo)
     451
     452                cfgInfo = { APINAME: "CRE_FLG" }
     453                cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
     454                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    465455                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    466456                $cfgFileInfo.push(cfgInfo)
    467457
    468458                cfgInfo = { APINAME: "CRE_FLG" }
    469                 cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val}"
     459                cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
     460                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     461                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
     462                $cfgFileInfo.push(cfgInfo)
     463
     464                cfgInfo = { APINAME: "CRE_FLG" }
     465                cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
     466                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     467                cfgInfo["iflgptn"] = 0
     468                $cfgFileInfo.push(cfgInfo)
     469        end
     470end
     471
     472#       // TCP (IPv4) 通信端点
     473if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
     474        $cfgData[:TCP_CRE_CEP].each do |key, params|
     475                cfgInfo = { APINAME: "CRE_SEM" }
     476                cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     477                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     478                cfgInfo["isemcnt"] = 1
     479                cfgInfo["maxsem"] = 1
     480                $cfgFileInfo.push(cfgInfo)
     481
     482                cfgInfo = { APINAME: "CRE_FLG" }
     483                cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
    470484                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    471485                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    472486                $cfgFileInfo.push(cfgInfo)
    473         end
    474         $cfgData[:VRID_TCP6_CEP].each do |key, params|
    475                 cfgInfo = { APINAME: "CRE_SEM" }
    476                 cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
    477                 cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    478                 cfgInfo["isemcnt"] = 1
    479                 cfgInfo["maxsem"] = 1
    480                 $cfgFileInfo.push(cfgInfo)
    481 
    482                 cfgInfo = { APINAME: "CRE_FLG" }
    483                 cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
     487
     488                cfgInfo = { APINAME: "CRE_FLG" }
     489                cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     490                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     491                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
     492                $cfgFileInfo.push(cfgInfo)
     493
     494                cfgInfo = { APINAME: "CRE_FLG" }
     495                cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     496                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     497                cfgInfo["iflgptn"] = 0
     498                $cfgFileInfo.push(cfgInfo)
     499        end
     500        $cfgData[:VRID_TCP_CEP].each do |key, params|
     501                cfgInfo = { APINAME: "CRE_SEM" }
     502                cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     503                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
     504                cfgInfo["isemcnt"] = 1
     505                cfgInfo["maxsem"] = 1
     506                $cfgFileInfo.push(cfgInfo)
     507
     508                cfgInfo = { APINAME: "CRE_FLG" }
     509                cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
    484510                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    485511                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
     
    487513
    488514                cfgInfo = { APINAME: "CRE_FLG" }
    489                 cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
    490                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    491                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    492                 $cfgFileInfo.push(cfgInfo)
    493 
    494                 cfgInfo = { APINAME: "CRE_FLG" }
    495                 cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
    496                 cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
    497                 cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
    498                 $cfgFileInfo.push(cfgInfo)
    499         end
    500 end
    501 
    502 #       // UDP (IPv4) 通信端点
    503 if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
    504         $cfgData[:UDP_CRE_CEP].each do |key, params|
    505                 cfgInfo = { APINAME: "CRE_SEM" }
    506                 cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp4_cepid].val}"
     515                cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     516                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     517                cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
     518                $cfgFileInfo.push(cfgInfo)
     519
     520                cfgInfo = { APINAME: "CRE_FLG" }
     521                cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
     522                cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
     523                cfgInfo["iflgptn"] = 0
     524                $cfgFileInfo.push(cfgInfo)
     525        end
     526end
     527
     528#       // UDP (IPv6) 通信端点
     529if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
     530        $cfgData[:UDP6_CRE_CEP].each do |key, params|
     531                cfgInfo = { APINAME: "CRE_SEM" }
     532                cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val}"
    507533                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    508534                cfgInfo["isemcnt"] = 1
     
    511537
    512538                cfgInfo = { APINAME: "CRE_DTQ" }
    513                 cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp4_cepid].val}"
     539                cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:udp6_cepid].val}"
    514540                cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
    515541                cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
     
    517543                $cfgFileInfo.push(cfgInfo)
    518544        end
    519         $cfgData[:VRID_UDP4_CEP].each do |key, params|
    520                 cfgInfo = { APINAME: "CRE_SEM" }
    521                 cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
     545        $cfgData[:VRID_UDP6_CEP].each do |key, params|
     546                cfgInfo = { APINAME: "CRE_SEM" }
     547                cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
    522548                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    523549                cfgInfo["isemcnt"] = 1
     
    526552
    527553                cfgInfo = { APINAME: "CRE_DTQ" }
    528                 cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
     554                cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
    529555                cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
    530556                cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
     
    534560end
    535561
    536 #       // UDP (IPv6) 通信端点
    537 if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
    538         $cfgData[:UDP6_CRE_CEP].each do |key, params|
    539                 cfgInfo = { APINAME: "CRE_SEM" }
    540                 cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp6_cepid].val}"
     562#       // UDP (IPv4) 通信端点
     563if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
     564        $cfgData[:UDP_CRE_CEP].each do |key, params|
     565                cfgInfo = { APINAME: "CRE_SEM" }
     566                cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val}"
    541567                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    542568                cfgInfo["isemcnt"] = 1
     
    545571
    546572                cfgInfo = { APINAME: "CRE_DTQ" }
    547                 cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp6_cepid].val}"
     573                cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:udp4_cepid].val}"
    548574                cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
    549575                cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
     
    551577                $cfgFileInfo.push(cfgInfo)
    552578        end
    553         $cfgData[:VRID_UDP6_CEP].each do |key, params|
    554                 cfgInfo = { APINAME: "CRE_SEM" }
    555                 cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
     579        $cfgData[:VRID_UDP_CEP].each do |key, params|
     580                cfgInfo = { APINAME: "CRE_SEM" }
     581                cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
    556582                cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
    557583                cfgInfo["isemcnt"] = 1
     
    560586
    561587                cfgInfo = { APINAME: "CRE_DTQ" }
    562                 cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
     588                cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
    563589                cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
    564590                cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg

    r321 r331  
    22 *  TINET (TCP/IP Protocol Stack)
    33 *
    4  *  Copyright (C) 2001-2007 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 *
     
    3636 */
    3737
     38#include "target_sil.h"
     39
    3840#include <itron.h>
    3941
     
    4749#include <net/if_arp.h>
    4850#include <net/net.h>
     51#include <net/net_endian.h>
    4952#include <net/net_buf.h>
    5053#include <net/net_timer.h>
     
    5255#include <net/ether_var.h>
    5356#include <netinet/in.h>
     57#include <netinet/in_var.h>
    5458#include <netinet/ip.h>
    55 #include <netinet/ip6.h>
    5659#include <netinet/ip_var.h>
    5760#include <netinet/tcp.h>
    58 #include <netinet/tcp_timer.h>
    5961#include <netinet/tcp_var.h>
    6062#include <netinet/udp_var.h>
    61 #include <netinet6/in6.h>
    62 #include <netinet6/ip6_var.h>
    6363
    6464/*
     
    6969
    7070INCLUDE("net/net_asp.cfg");
     71INCLUDE("net/ethernet.cfg");
    7172
    72 INCLUDE("net/ethernet.cfg");
    7373INCLUDE("netinet/if_ether.cfg");
    7474INCLUDE("netinet/ip.cfg");
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_config.h

    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 *
     
    3939 */
    4040
    41 /* TCPの受動オープンをサポートする。*/
    42 
     41/* TCPの受動オープンをサポートする【TINET 1.7 以降不要になった】。*/
     42
     43#if 0
    4344#define TCP_CFG_PASSIVE_OPEN
     45#endif
    4446
    4547/* TCPのノンブロッキングコール機能を組込む。*/
     
    104106#endif
    105107 */
     108
     109/*
     110 *  TINET 1.5 との互換性のための定義
     111 */
     112
     113/* ルーティング表のエントリ数の定義 */
     114
     115#define NUM_IN6_ROUTE_ENTRY                     \
     116        (NUM_IN6_STATIC_ROUTE_ENTRY + NUM_IN6_REDIRECT_ROUTE_ENTRY)
     117                                        /* ルーティング表のエントリ数        */
     118
     119#define NUM_IN4_ROUTE_ENTRY             \
     120        (NUM_IN4_STATIC_ROUTE_ENTRY + NUM_IN4_REDIRECT_ROUTE_ENTRY)
     121                                        /* ルーティング表のエントリ数        */
     122
     123#if defined(SUPPORT_INET6)
     124
     125#if defined(SUPPORT_INET4)
     126
     127#else   /* #if defined(SUPPORT_INET4) */
     128
     129#ifndef NUM_IN6_STATIC_ROUTE_ENTRY
     130#define NUM_IN6_STATIC_ROUTE_ENTRY      NUM_STATIC_ROUTE_ENTRY
     131#endif
     132
     133#ifndef NUM_IN6_REDIRECT_ROUTE_ENTRY
     134#define NUM_IN6_REDIRECT_ROUTE_ENTRY    NUM_REDIRECT_ROUTE_ENTRY
     135#endif
     136
     137#ifdef  NUM_ROUTE_ENTRY
     138#undef  NUM_ROUTE_ENTRY
     139#endif
     140#define NUM_ROUTE_ENTRY                 NUM_IN6_ROUTE_ENTRY
     141
     142#endif  /* #if defined(SUPPORT_INET4) */
     143
     144#else   /* of #if defined(SUPPORT_INET6) */
     145
     146#if defined(SUPPORT_INET4)
     147
     148#ifndef NUM_IN4_STATIC_ROUTE_ENTRY
     149#define NUM_IN4_STATIC_ROUTE_ENTRY      NUM_STATIC_ROUTE_ENTRY
     150#endif
     151
     152#ifndef NUM_IN4_REDIRECT_ROUTE_ENTRY
     153#define NUM_IN4_REDIRECT_ROUTE_ENTRY    NUM_REDIRECT_ROUTE_ENTRY
     154#endif
     155
     156#ifdef  NUM_ROUTE_ENTRY
     157#undef  NUM_ROUTE_ENTRY
     158#endif
     159#define NUM_ROUTE_ENTRY                 NUM_IN4_ROUTE_ENTRY
     160
     161#endif  /* of #if defined(SUPPORT_INET4) */
     162
     163#endif  /* of #if defined(SUPPORT_INET6) */
     164
     165/* DHCP の定義 */
     166
     167#ifdef  DHCP4_CLI_CFG
     168#define DHCP_CFG
     169#endif
     170
     171/*
     172 *  IPv6/IPv4 に関する定義
     173 */
     174
     175/*
     176 *  指定されたマクロに対する TINET 内部のマクロの定義
     177 *
     178 *    SUPPORT_INET6              .   .  ON  ON  ON  ON
     179 *    SUPPORT_INET4             ON  ON   .   .  ON  ON
     180 *    API_CFG_IP4MAPPED_ADDR     .  ON   .  ON   .  ON
     181 *    ----------------------    ----------------------
     182 *    _IP6_CFG                   .   .  ON  ON  ON  ON
     183 *    _IP4_CFG                  ON  ON   .  ON  ON  ON
     184 *   
     185 */
     186
     187#if !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
     188#error option selection: !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
     189#endif
     190
     191#if defined(SUPPORT_INET6)
     192#define _IP6_CFG
     193#endif
     194
     195#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
     196#define _IP4_CFG
     197#endif
    106198
    107199/*
     
    211303
    212304#ifndef TMO_IP4_FRAG_GET_NET_BUF
    213 #define TMO_IP4_FRAG_GET_NET_BUF        ULONG_C(1000*1000)      /* [ms]、IPv4 データグラム再構成用ネットワークバッファ獲得タイムアウト       */
     305#define TMO_IP4_FRAG_GET_NET_BUF        ULONG_C(1000000)        /* [us]、IPv4 データグラム再構成用ネットワークバッファ獲得タイムアウト       */
    214306#endif
    215307
    216308#ifndef TMO_IP6_FRAG_GET_NET_BUF
    217 #define TMO_IP6_FRAG_GET_NET_BUF        ULONG_C(1000*1000)      /* [ms]、IPv6 データグラム再構成用ネットワークバッファ獲得タイムアウト       */
     309#define TMO_IP6_FRAG_GET_NET_BUF        ULONG_C(1000000)        /* [us]、IPv6 データグラム再構成用ネットワークバッファ獲得タイムアウト       */
    218310#endif
    219311
    220312#ifndef TMO_PPP_GET_NET_BUF
    221 #define TMO_PPP_GET_NET_BUF             ULONG_C(1000*1000)      /* [ms]、PPP 受信用ネットワークバッファ獲得タイムアウト       */
     313#define TMO_PPP_GET_NET_BUF             ULONG_C(1000000)        /* [us]、PPP 受信用ネットワークバッファ獲得タイムアウト       */
    222314#endif
    223315
    224316#ifndef TMO_ARP_GET_NET_BUF
    225 #define TMO_ARP_GET_NET_BUF             ULONG_C(1000*1000)      /* [ms]、ARP のネットワークバッファ獲得タイムアウト */
     317#define TMO_ARP_GET_NET_BUF             ULONG_C(1000000)        /* [us]、ARP のネットワークバッファ獲得タイムアウト */
    226318#endif
    227319
    228320#ifndef TMO_TCP_GET_NET_BUF
    229 #define TMO_TCP_GET_NET_BUF             ULONG_C(1000*1000)      /* [ms]、TCP のネットワークバッファ獲得タイムアウト */
     321#define TMO_TCP_GET_NET_BUF             ULONG_C(1000000)        /* [us]、TCP のネットワークバッファ獲得タイムアウト */
    230322#endif
    231323
    232324#ifndef TMO_TCP_OUTPUT
    233 #define TMO_TCP_OUTPUT                  ULONG_C(1000*1000)      /* [ms]、TCP 出力タイムアウト                            */
     325#define TMO_TCP_OUTPUT                  ULONG_C(1000000)        /* [us]、TCP 出力タイムアウト                            */
    234326#endif
    235327
    236328#ifndef TMO_UDP_OUTPUT
    237 #define TMO_UDP_OUTPUT                  ULONG_C(1000*1000)      /* [ms]、UDP 出力タイムアウト                            */
     329#define TMO_UDP_OUTPUT                  ULONG_C(1000000)        /* [us]、UDP 出力タイムアウト                            */
    238330#endif
    239331
    240332#ifndef TMO_ICMP_OUTPUT
    241 #define TMO_ICMP_OUTPUT                 ULONG_C(1000*1000)      /* [ms]、ICMP 出力タイムアウト                           */
     333#define TMO_ICMP_OUTPUT                 ULONG_C(1000000)        /* [us]、ICMP 出力タイムアウト                           */
     334#endif
     335
     336#ifndef TMO_IGMP_OUTPUT
     337#define TMO_IGMP_OUTPUT                 ULONG_C(1000000)        /* [us]、IGMP 出力タイムアウト                           */
    242338#endif
    243339
    244340#ifndef TMO_ND6_NS_OUTPUT
    245 #define TMO_ND6_NS_OUTPUT               ULONG_C(1000*1000)      /* [ms]、近隣要請出力タイムアウト                    */
     341#define TMO_ND6_NS_OUTPUT               ULONG_C(1000000)        /* [us]、近隣要請出力タイムアウト                    */
    246342#endif
    247343
    248344#ifndef TMO_ND6_NA_OUTPUT
    249 #define TMO_ND6_NA_OUTPUT               ULONG_C(1000*1000)      /* [ms]、近隣通知出力タイムアウト                    */
     345#define TMO_ND6_NA_OUTPUT               ULONG_C(1000000)        /* [us]、近隣通知出力タイムアウト                    */
    250346#endif
    251347
    252348#ifndef TMO_ND6_RS_OUTPUT
    253 #define TMO_ND6_RS_OUTPUT               ULONG_C(1000*1000)      /* [ms]、ルータ要請出力タイムアウト                   */
     349#define TMO_ND6_RS_OUTPUT               ULONG_C(1000000)        /* [us]、ルータ要請出力タイムアウト                   */
    254350#endif
    255351
    256352#ifndef TMO_ARP_OUTPUT
    257 #define TMO_ARP_OUTPUT                  ULONG_C(1000*1000)      /* [ms]、アドレス解決要求出力タイムアウト                */
     353#define TMO_ARP_OUTPUT                  ULONG_C(1000000)        /* [us]、アドレス解決要求出力タイムアウト                */
    258354#endif
    259355
    260356#ifndef TMO_ND6_RTR_SOL_DELAY
    261 #define TMO_ND6_RTR_SOL_DELAY           ULONG_C(1000*1000)      /* [ms]、ルータ要請出力遅延                               */
     357#define TMO_ND6_RTR_SOL_DELAY           ULONG_C(1000000)        /* [us]、ルータ要請出力遅延                               */
    262358#endif
    263359
    264360#ifndef TMO_ND6_RTR_SOL_INTERVAL
    265 #define TMO_ND6_RTR_SOL_INTERVAL        ULONG_C(4000*1000)      /* [ms]、ルータ要請出力間隔                               */
     361#define TMO_ND6_RTR_SOL_INTERVAL        ULONG_C(4000000)        /* [us]、ルータ要請出力間隔                               */
    266362#endif
    267363
     
    387483#include <net/net_rename.h>
    388484#include <netinet/in_rename.h>
    389 
    390 #ifdef SUPPORT_INET6
    391 
    392485#include <netinet6/in6_rename.h>
    393486
    394 #endif  /* of #ifdef SUPPORT_INET6 */
    395 
    396487#endif /* _TINET_CONFIG_H_ */
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_defs.h

    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 *
  • EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_kernel_defs.h

    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 *
Note: See TracChangeset for help on using the changeset viewer.