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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/asp3_dcre/tinet/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                }
Note: See TracChangeset for help on using the changeset viewer.