Ignore:
Timestamp:
Jul 13, 2020, 8:07:55 PM (4 years ago)
Author:
coas-nagasima
Message:

ntshellアプリはnewlibを使うよう変更し、syscallの実装部分と区別がつくよう更新。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/src/netcmd.c

    r441 r442  
    4040#include <t_stdlib.h>
    4141#include <sil.h>
    42 #include <string.h>
    4342#include "syssvc/serial.h"
    4443#include "syssvc/syslog.h"
     
    5958#include <netapp/resolver.h>
    6059#include "core/ntlibc.h"
    61 #include "util/ntstdio.h"
    62 #include <stdio.h>
    6360#include "ntp_cli.h"
    6461#include "kernel_cfg.h"
     
    7168extern void ping6(T_IN6_ADDR *addr, uint_t tmo, uint_t len);
    7269extern void ping4(T_IN4_ADDR *addr, uint_t tmo, uint_t len);
    73 extern ntstdio_t *ntstdio;
    7470
    7571/*
     
    255251
    256252        if (apip == '1')
    257                 ntlibc_strcpy(line, i6rlp_pmtu_str1);
     253                strcpy(line, i6rlp_pmtu_str1);
    258254        else if (apip == '2')
    259                 ntlibc_strcpy(line, i6rlp_pmtu_str2);
     255                strcpy(line, i6rlp_pmtu_str2);
    260256        else if (apip == '3')
    261                 ntlibc_strcpy(line, i6rlp_pmtu_str3);
     257                strcpy(line, i6rlp_pmtu_str3);
    262258
    263259#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     
    280276
    281277        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
    282                 ntstdio_printf(ntstdio, "[PING] unknown host.\n");
     278                printf("[PING] unknown host.\n");
    283279                return 0;
    284280        }
     
    299295#if defined(SUPPORT_INET4)
    300296        if (apip == API_PROTO_IPV6) {
    301                 ntstdio_printf(ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     297                printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    302298                ping6(&addr, (uint_t)tmo, (uint_t)size);
    303299        }
    304300        else {
    305301                addr4 = ntohl(addr.s6_addr32[3]);
    306                 ntstdio_printf(ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
     302                printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
    307303                ping4(&addr4, (uint_t)tmo, (uint_t)size);
    308304        }
    309305#else /* of #if defined(SUPPORT_INET4) */
    310         ntstdio_printf(ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     306        printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    311307        ping6(&addr, (uint_t)tmo, (uint_t)size);
    312308#endif  /* of #if defined(SUPPORT_INET4) */
    313309#else   /* of #if defined(SUPPORT_INET6) */
    314         ntstdio_printf(ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
     310        printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
    315311        ping4(&addr, (uint_t)tmo, (uint_t)size);
    316312#endif  /* of #if defined(SUPPORT_INET6) */
     
    331327                pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0);
    332328                temp[pos] = '\0';
    333                 ntstdio_printf(ntstdio, "DHCPv4 server: %s,\n", temp);
    334                 ntstdio_printf(ntstdio, "  Renew:       %u:%02u:%02u,\n",
     329                printf("DHCPv4 server: %s,\n", temp);
     330                printf("  Renew:       %u:%02u:%02u,\n",
    335331                        renew / 3600, (renew / 60) % 60, renew % 60);
    336                 ntstdio_printf(ntstdio, "  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     332                printf("  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
    337333                        rebind / 3600, (rebind / 60) % 60, rebind % 60,
    338334                        expire / 3600, (expire / 60) % 60, expire % 60);
    339335        }
    340336        else if (ret == E_OBJ)
    341                 ntstdio_printf(ntstdio, "DHCPv4 server: not available.\n");
     337                printf("DHCPv4 server: not available.\n");
    342338}
    343339
     
    349345                return 0;
    350346
    351         if (ntlibc_strcmp(argv[1], "rel") == 0) {
     347        if (strcmp(argv[1], "rel") == 0) {
    352348                ret = dhcp4c_rel_info();
    353                 ntstdio_printf(ntstdio, "dhcp4c_rel_info %d\n", ret);
    354         }
    355         else if (ntlibc_strcmp(argv[1], "renew") == 0) {
     349                printf("dhcp4c_rel_info %d\n", ret);
     350        }
     351        else if (strcmp(argv[1], "renew") == 0) {
    356352                ret = dhcp4c_renew_info();
    357                 ntstdio_printf(ntstdio, "dhcp4c_renew_info %d\n", ret);
     353                printf("dhcp4c_renew_info %d\n", ret);
    358354        }
    359355        else {
     
    383379                else {
    384380                        for (c = 1; c <= *ptr; c++)
    385                                 ntstdio_printf(ntstdio, "%c", *(ptr + c));
     381                                printf("%c", *(ptr + c));
    386382                        ptr += *ptr + 1;
    387383                        if (*ptr)
    388                                 ntstdio_printf(ntstdio, ".");
     384                                printf(".");
    389385                }
    390386        }
     
    406402                return error;
    407403
    408         ntstdio_printf(ntstdio, "    mname:   ");
     404        printf("    mname:   ");
    409405        rn_offset = s_show_dns_domain_name(msg, offset);
    410406        putchar('\n');
    411         ntstdio_printf(ntstdio, "    rname:   ");
     407        printf("    rname:   ");
    412408        s_show_dns_domain_name(msg, rn_offset);
    413409        putchar('\n');
    414410
    415         ntstdio_printf(ntstdio, "    serial:  %d\n", soa.serial);
    416         ntstdio_printf(ntstdio, "    refresh: %d\n", soa.refresh);
    417         ntstdio_printf(ntstdio, "    retry:   %d\n", soa.retry);
    418         ntstdio_printf(ntstdio, "    expirel: %d\n", soa.expire);
    419         ntstdio_printf(ntstdio, "    minimum: %d\n", soa.minimum);
     411        printf("    serial:  %d\n", soa.serial);
     412        printf("    refresh: %d\n", soa.refresh);
     413        printf("    retry:   %d\n", soa.retry);
     414        printf("    expirel: %d\n", soa.expire);
     415        printf("    minimum: %d\n", soa.minimum);
    420416
    421417        return E_OK;
     
    433429        int             scount;
    434430
    435         ntstdio_printf(ntstdio, "question   section: %d\n", rslv->dns_hdr.qdcount);
     431        printf("question   section: %d\n", rslv->dns_hdr.qdcount);
    436432        offset = rslv->qd_offset;
    437433        for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) {
     
    439435                        return error;
    440436
    441                 ntstdio_printf(ntstdio, "%2d: ", scount);
     437                printf("%2d: ", scount);
    442438                s_show_dns_domain_name(msg, offset);
    443                 ntstdio_printf(ntstdio, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
     439                printf("\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
    444440                offset = error;
    445441        }
     
    463459        int pos;
    464460
    465         ntstdio_printf(ntstdio, "%10s section: %d\n", title, scount);
     461        printf("%10s section: %d\n", title, scount);
    466462        for (count = 1; count <= scount; count++) {
    467463                if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
    468464                        return error;
    469465
    470                 ntstdio_printf(ntstdio, "%2d: ", count);
     466                printf("%2d: ", count);
    471467                s_show_dns_domain_name(msg, offset);
    472                 ntstdio_printf(ntstdio, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
     468                printf("\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
    473469                        dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
    474470
     
    479475                        pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    480476                        temp[pos] = '\0';
    481                         ntstdio_printf(ntstdio, "    IPv4 addr: %s\n", temp);
     477                        printf("    IPv4 addr: %s\n", temp);
    482478                        break;
    483479                case DNS_TYPE_NS:
    484                         ntstdio_printf(ntstdio, "    host: ");
     480                        printf("    host: ");
    485481                        s_show_dns_domain_name(msg, rr.rdata_offset);
    486482                        putchar('\n');
    487483                        break;
    488484                case DNS_TYPE_CNAME:
    489                         ntstdio_printf(ntstdio, "    host: ");
     485                        printf("    host: ");
    490486                        s_show_dns_domain_name(msg, rr.rdata_offset);
    491487                        putchar('\n');
     
    495491                        break;
    496492                case DNS_TYPE_PTR:
    497                         ntstdio_printf(ntstdio, "     PTR: ");
     493                        printf("     PTR: ");
    498494                        s_show_dns_domain_name(msg, rr.rdata_offset);
    499495                        putchar('\n');
     
    503499                        pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    504500                        temp[pos] = '\0';
    505                         ntstdio_printf(ntstdio, "    IPv6 addr: %s\n", temp);
     501                        printf("    IPv6 addr: %s\n", temp);
    506502                        break;
    507503                default:
    508                         ntstdio_printf(ntstdio, "    data: ");
     504                        printf("    data: ");
    509505                        col = 32;
    510506                        for (dcount = 0; dcount < rr.rdlength; dcount++) {
    511                                 ntstdio_printf(ntstdio, "%02x", *(msg + rr.rdata_offset + dcount));
     507                                printf("%02x", *(msg + rr.rdata_offset + dcount));
    512508                                if (--col == 0) {
    513                                         ntstdio_printf(ntstdio, "\n          ");
     509                                        printf("\n          ");
    514510                                        col = 32;
    515511                                }
     
    539535#if defined(SUPPORT_INET6)
    540536
    541         ntstdio_printf(ntstdio, "domain name:     %s\n", dns_in6_get_dname());
     537        printf("domain name:     %s\n", dns_in6_get_dname());
    542538
    543539#else   /* of #if defined(SUPPORT_INET6) */
    544540
    545         ntstdio_printf(ntstdio, "domain name:     %s\n", dns_in4_get_dname());
     541        printf("domain name:     %s\n", dns_in4_get_dname());
    546542
    547543#endif  /* of #if defined(SUPPORT_INET6) */
     
    549545#if defined(SUPPORT_INET6)
    550546        dns_in6_get_addr(&in6_addr);
    551         ntstdio_printf(ntstdio, "IPv6 DNS server: ");
     547        printf("IPv6 DNS server: ");
    552548        if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
    553                 ntstdio_printf(ntstdio, "not available.\n");
     549                printf("not available.\n");
    554550        else {
    555551                pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    556552                temp[pos] = '\0';
    557                 ntstdio_printf(ntstdio, "%s.\n", temp);
     553                printf("%s.\n", temp);
    558554        }
    559555#endif  /* of #if defined(SUPPORT_INET6) */
     
    561557#if defined(SUPPORT_INET4)
    562558        dns_in4_get_addr(&in4_addr);
    563         ntstdio_printf(ntstdio, "IPv4 DNS server: ");
     559        printf("IPv4 DNS server: ");
    564560        if (in4_addr == IPV4_ADDRANY)
    565                 ntstdio_printf(ntstdio, "not available.\n");
     561                printf("not available.\n");
    566562        else {
    567563                pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    568564                temp[pos] = '\0';
    569                 ntstdio_printf(ntstdio, "%s.\n", temp);
     565                printf("%s.\n", temp);
    570566        }
    571567#endif  /* of #if defined(SUPPORT_INET4) */
     
    596592        uint8_t         *msg;
    597593
    598         if (ntlibc_strcmp(line, "info") == 0) {
     594        if (strcmp(line, "info") == 0) {
    599595                dns_info();
    600596                return 0;
     
    604600        line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
    605601        if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
    606                 ntstdio_printf(ntstdio, "DNS server not available.\n");
     602                printf("DNS server not available.\n");
    607603                return 0;
    608604        }
     
    620616
    621617        if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
    622                 ntstdio_printf(ntstdio, "get buffer error: %s.\n", itron_strerror(error));
     618                printf("get buffer error: %s.\n", itron_strerror(error));
    623619                return 0;
    624620        }
    625621
    626622        if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
    627                 //ntstdio_printf(ntstdio, "error: %s.\n", itron_strerror(length));
     623                //printf("error: %s.\n", itron_strerror(length));
    628624                goto err_ret;
    629625        }
    630626
    631627        dly_tsk(1 * 1000);
    632         ntstdio_printf(ntstdio, "DNS header: flags: ");
     628        printf("DNS header: flags: ");
    633629        if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE |
    634630                DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
    635                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
    636                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
    637                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
    638                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
    639                 ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
    640                 ntstdio_printf(ntstdio, " ");
    641         }
    642         ntstdio_printf(ntstdio, "opcode: ");
    643         ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
    644         ntstdio_printf(ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
    645         ntstdio_printf(ntstdio, ", rcode: %s.\n",
     631                printf((rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
     632                printf((rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
     633                printf((rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
     634                printf((rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
     635                printf((rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
     636                printf(" ");
     637        }
     638        printf("opcode: ");
     639        printf((rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
     640        printf((rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
     641        printf(", rcode: %s.\n",
    646642                (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
    647643                ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
    648644
    649645        if ((offset = show_dns_qdsection(msg, length, &rslv)) < 0) {
    650                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     646                printf("msg error: %s.\n", itron_strerror(offset));
    651647        }
    652648        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
    653                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     649                printf("msg error: %s.\n", itron_strerror(offset));
    654650        }
    655651        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
    656                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     652                printf("msg error: %s.\n", itron_strerror(offset));
    657653        }
    658654        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
    659                 ntstdio_printf(ntstdio, "msg error: %s.\n", itron_strerror(offset));
     655                printf("msg error: %s.\n", itron_strerror(offset));
    660656        }
    661657
    662658err_ret:
    663659        if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
    664                 ntstdio_printf(ntstdio, "release buffer error: %s.\n", itron_strerror(error));
     660                printf("release buffer error: %s.\n", itron_strerror(error));
    665661        return 0;
    666662}
Note: See TracChangeset for help on using the changeset viewer.