Ignore:
Timestamp:
Apr 5, 2019, 9:26:53 PM (5 years ago)
Author:
coas-nagasima
Message:

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

File:
1 edited

Legend:

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

    r364 r374  
    5959#include <netapp/resolver.h>
    6060#include "core/ntlibc.h"
    61 #include "util/ntstdio.h"
     61#include <stdio.h>
    6262#include "ntp_cli.h"
    6363#include "kernel_cfg.h"
    64 
    65 extern ntstdio_t ntstdio;
    6664
    6765#if defined(SUPPORT_INET6)
     
    280278
    281279        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
    282                 ntstdio_printf(&ntstdio, "[PING] unknown host.\n");
     280                printf("[PING] unknown host.\n");
    283281                return 0;
    284282        }
     
    299297#if defined(SUPPORT_INET4)
    300298        if (apip == API_PROTO_IPV6) {
    301                 ntstdio_printf(&ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     299                printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    302300                ping6(&addr, (uint_t)tmo, (uint_t)size);
    303301        }
    304302        else {
    305303                addr4 = ntohl(addr.s6_addr32[3]);
    306                 ntstdio_printf(&ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
     304                printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
    307305                ping4(&addr4, (uint_t)tmo, (uint_t)size);
    308306        }
    309307#else /* of #if defined(SUPPORT_INET4) */
    310         ntstdio_printf(&ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     308        printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    311309        ping6(&addr, (uint_t)tmo, (uint_t)size);
    312310#endif  /* of #if defined(SUPPORT_INET4) */
    313311#else   /* of #if defined(SUPPORT_INET6) */
    314         ntstdio_printf(&ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
     312        printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
    315313        ping4(&addr, (uint_t)tmo, (uint_t)size);
    316314#endif  /* of #if defined(SUPPORT_INET6) */
     
    331329                pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0);
    332330                temp[pos] = '\0';
    333                 ntstdio_printf(&ntstdio, "DHCPv4 server: %s,\n", temp);
    334                 ntstdio_printf(&ntstdio, "  Renew:       %u:%02u:%02u,\n",
     331                printf("DHCPv4 server: %s,\n", temp);
     332                printf("  Renew:       %u:%02u:%02u,\n",
    335333                        renew / 3600, (renew / 60) % 60, renew % 60);
    336                 ntstdio_printf(&ntstdio, "  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     334                printf("  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
    337335                        rebind / 3600, (rebind / 60) % 60, rebind % 60,
    338336                        expire / 3600, (expire / 60) % 60, expire % 60);
    339337        }
    340338        else if (ret == E_OBJ)
    341                 ntstdio_printf(&ntstdio, "DHCPv4 server: not available.\n");
     339                printf("DHCPv4 server: not available.\n");
    342340}
    343341
     
    351349        if (ntlibc_strcmp(argv[1], "rel") == 0) {
    352350                ret = dhcp4c_rel_info();
    353                 ntstdio_printf(&ntstdio, "dhcp4c_rel_info %d\n", ret);
     351                printf("dhcp4c_rel_info %d\n", ret);
    354352        }
    355353        else if (ntlibc_strcmp(argv[1], "renew") == 0) {
    356354                ret = dhcp4c_renew_info();
    357                 ntstdio_printf(&ntstdio, "dhcp4c_renew_info %d\n", ret);
     355                printf("dhcp4c_renew_info %d\n", ret);
    358356        }
    359357        else {
     
    383381                else {
    384382                        for (c = 1; c <= *ptr; c++)
    385                                 ntstdio_printf(&ntstdio, "%c", *(ptr + c));
     383                                printf("%c", *(ptr + c));
    386384                        ptr += *ptr + 1;
    387385                        if (*ptr)
    388                                 ntstdio_printf(&ntstdio, ".");
     386                                printf(".");
    389387                }
    390388        }
     
    406404                return error;
    407405
    408         ntstdio_printf(&ntstdio, "    mname:   ");
     406        printf("    mname:   ");
    409407        rn_offset = s_show_dns_domain_name(msg, offset);
    410         ntstdio_putc(&ntstdio, '\n');
    411         ntstdio_printf(&ntstdio, "    rname:   ");
     408        putchar('\n');
     409        printf("    rname:   ");
    412410        s_show_dns_domain_name(msg, rn_offset);
    413         ntstdio_putc(&ntstdio, '\n');
    414 
    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        putchar('\n');
     412
     413        printf("    serial:  %d\n", soa.serial);
     414        printf("    refresh: %d\n", soa.refresh);
     415        printf("    retry:   %d\n", soa.retry);
     416        printf("    expirel: %d\n", soa.expire);
     417        printf("    minimum: %d\n", soa.minimum);
    420418
    421419        return E_OK;
     
    433431        int             scount;
    434432
    435         ntstdio_printf(&ntstdio, "question   section: %d\n", rslv->dns_hdr.qdcount);
     433        printf("question   section: %d\n", rslv->dns_hdr.qdcount);
    436434        offset = rslv->qd_offset;
    437435        for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) {
     
    439437                        return error;
    440438
    441                 ntstdio_printf(&ntstdio, "%2d: ", scount);
     439                printf("%2d: ", scount);
    442440                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));
     441                printf("\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
    444442                offset = error;
    445443        }
     
    463461        int pos;
    464462
    465         ntstdio_printf(&ntstdio, "%10s section: %d\n", title, scount);
     463        printf("%10s section: %d\n", title, scount);
    466464        for (count = 1; count <= scount; count++) {
    467465                if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
    468466                        return error;
    469467
    470                 ntstdio_printf(&ntstdio, "%2d: ", count);
     468                printf("%2d: ", count);
    471469                s_show_dns_domain_name(msg, offset);
    472                 ntstdio_printf(&ntstdio, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
     470                printf("\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
    473471                        dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
    474472
     
    479477                        pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    480478                        temp[pos] = '\0';
    481                         ntstdio_printf(&ntstdio, "    IPv4 addr: %s\n", temp);
     479                        printf("    IPv4 addr: %s\n", temp);
    482480                        break;
    483481                case DNS_TYPE_NS:
    484                         ntstdio_printf(&ntstdio, "    host: ");
     482                        printf("    host: ");
    485483                        s_show_dns_domain_name(msg, rr.rdata_offset);
    486                         ntstdio_putc(&ntstdio, '\n');
     484                        putchar('\n');
    487485                        break;
    488486                case DNS_TYPE_CNAME:
    489                         ntstdio_printf(&ntstdio, "    host: ");
     487                        printf("    host: ");
    490488                        s_show_dns_domain_name(msg, rr.rdata_offset);
    491                         ntstdio_putc(&ntstdio, '\n');
     489                        putchar('\n');
    492490                        break;
    493491                case DNS_TYPE_SOA:
     
    495493                        break;
    496494                case DNS_TYPE_PTR:
    497                         ntstdio_printf(&ntstdio, "     PTR: ");
     495                        printf("     PTR: ");
    498496                        s_show_dns_domain_name(msg, rr.rdata_offset);
    499                         ntstdio_putc(&ntstdio, '\n');
     497                        putchar('\n');
    500498                        break;
    501499                case DNS_TYPE_AAAA:
     
    503501                        pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    504502                        temp[pos] = '\0';
    505                         ntstdio_printf(&ntstdio, "    IPv6 addr: %s\n", temp);
     503                        printf("    IPv6 addr: %s\n", temp);
    506504                        break;
    507505                default:
    508                         ntstdio_printf(&ntstdio, "    data: ");
     506                        printf("    data: ");
    509507                        col = 32;
    510508                        for (dcount = 0; dcount < rr.rdlength; dcount++) {
    511                                 ntstdio_printf(&ntstdio, "%02x", *(msg + rr.rdata_offset + dcount));
     509                                printf("%02x", *(msg + rr.rdata_offset + dcount));
    512510                                if (--col == 0) {
    513                                         ntstdio_printf(&ntstdio, "\n          ");
     511                                        printf("\n          ");
    514512                                        col = 32;
    515513                                }
    516514                        }
    517                         ntstdio_putc(&ntstdio, '\n');
     515                        putchar('\n');
    518516                        break;
    519517                }
     
    539537#if defined(SUPPORT_INET6)
    540538
    541         ntstdio_printf(&ntstdio, "domain name:     %s\n", dns_in6_get_dname());
     539        printf("domain name:     %s\n", dns_in6_get_dname());
    542540
    543541#else   /* of #if defined(SUPPORT_INET6) */
    544542
    545         ntstdio_printf(&ntstdio, "domain name:     %s\n", dns_in4_get_dname());
     543        printf("domain name:     %s\n", dns_in4_get_dname());
    546544
    547545#endif  /* of #if defined(SUPPORT_INET6) */
     
    549547#if defined(SUPPORT_INET6)
    550548        dns_in6_get_addr(&in6_addr);
    551         ntstdio_printf(&ntstdio, "IPv6 DNS server: ");
     549        printf("IPv6 DNS server: ");
    552550        if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
    553                 ntstdio_printf(&ntstdio, "not available.\n");
     551                printf("not available.\n");
    554552        else {
    555553                pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    556554                temp[pos] = '\0';
    557                 ntstdio_printf(&ntstdio, "%s.\n", temp);
     555                printf("%s.\n", temp);
    558556        }
    559557#endif  /* of #if defined(SUPPORT_INET6) */
     
    561559#if defined(SUPPORT_INET4)
    562560        dns_in4_get_addr(&in4_addr);
    563         ntstdio_printf(&ntstdio, "IPv4 DNS server: ");
     561        printf("IPv4 DNS server: ");
    564562        if (in4_addr == IPV4_ADDRANY)
    565                 ntstdio_printf(&ntstdio, "not available.\n");
     563                printf("not available.\n");
    566564        else {
    567565                pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    568566                temp[pos] = '\0';
    569                 ntstdio_printf(&ntstdio, "%s.\n", temp);
     567                printf("%s.\n", temp);
    570568        }
    571569#endif  /* of #if defined(SUPPORT_INET4) */
     
    604602        line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
    605603        if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
    606                 ntstdio_printf(&ntstdio, "DNS server not available.\n");
     604                printf("DNS server not available.\n");
    607605                return 0;
    608606        }
     
    620618
    621619        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));
     620                printf("get buffer error: %s.\n", itron_strerror(error));
    623621                return 0;
    624622        }
    625623
    626624        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));
     625                //printf("error: %s.\n", itron_strerror(length));
    628626                goto err_ret;
    629627        }
    630628
    631629        dly_tsk(1 * 1000);
    632         ntstdio_printf(&ntstdio, "DNS header: flags: ");
     630        printf("DNS header: flags: ");
    633631        if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE |
    634632                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",
     633                printf((rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
     634                printf((rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
     635                printf((rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
     636                printf((rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
     637                printf((rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
     638                printf(" ");
     639        }
     640        printf("opcode: ");
     641        printf((rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
     642        printf((rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
     643        printf(", rcode: %s.\n",
    646644                (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
    647645                ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
    648646
    649647        if ((offset = show_dns_qdsection(msg, length, &rslv)) < 0) {
    650                 ntstdio_printf(&ntstdio, "msg error: %s.\n", itron_strerror(offset));
     648                printf("msg error: %s.\n", itron_strerror(offset));
    651649        }
    652650        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));
     651                printf("msg error: %s.\n", itron_strerror(offset));
    654652        }
    655653        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));
     654                printf("msg error: %s.\n", itron_strerror(offset));
    657655        }
    658656        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));
     657                printf("msg error: %s.\n", itron_strerror(offset));
    660658        }
    661659
    662660err_ret:
    663661        if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
    664                 ntstdio_printf(&ntstdio, "release buffer error: %s.\n", itron_strerror(error));
     662                printf("release buffer error: %s.\n", itron_strerror(error));
    665663        return 0;
    666664}
Note: See TracChangeset for help on using the changeset viewer.