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/netapp
Files:
59 added
9 deleted
37 edited

Legend:

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