Changeset 374 for asp3_tinet_ecnl_rx/trunk/ntshell/src/netcmd.c
- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/ntshell/src/netcmd.c
r364 r374 59 59 #include <netapp/resolver.h> 60 60 #include "core/ntlibc.h" 61 #include "util/ntstdio.h"61 #include <stdio.h> 62 62 #include "ntp_cli.h" 63 63 #include "kernel_cfg.h" 64 65 extern ntstdio_t ntstdio;66 64 67 65 #if defined(SUPPORT_INET6) … … 280 278 281 279 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 282 ntstdio_printf(&ntstdio,"[PING] unknown host.\n");280 printf("[PING] unknown host.\n"); 283 281 return 0; 284 282 } … … 299 297 #if defined(SUPPORT_INET4) 300 298 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)); 302 300 ping6(&addr, (uint_t)tmo, (uint_t)size); 303 301 } 304 302 else { 305 303 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)); 307 305 ping4(&addr4, (uint_t)tmo, (uint_t)size); 308 306 } 309 307 #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)); 311 309 ping6(&addr, (uint_t)tmo, (uint_t)size); 312 310 #endif /* of #if defined(SUPPORT_INET4) */ 313 311 #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)); 315 313 ping4(&addr, (uint_t)tmo, (uint_t)size); 316 314 #endif /* of #if defined(SUPPORT_INET6) */ … … 331 329 pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0); 332 330 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", 335 333 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", 337 335 rebind / 3600, (rebind / 60) % 60, rebind % 60, 338 336 expire / 3600, (expire / 60) % 60, expire % 60); 339 337 } 340 338 else if (ret == E_OBJ) 341 ntstdio_printf(&ntstdio,"DHCPv4 server: not available.\n");339 printf("DHCPv4 server: not available.\n"); 342 340 } 343 341 … … 351 349 if (ntlibc_strcmp(argv[1], "rel") == 0) { 352 350 ret = dhcp4c_rel_info(); 353 ntstdio_printf(&ntstdio,"dhcp4c_rel_info %d\n", ret);351 printf("dhcp4c_rel_info %d\n", ret); 354 352 } 355 353 else if (ntlibc_strcmp(argv[1], "renew") == 0) { 356 354 ret = dhcp4c_renew_info(); 357 ntstdio_printf(&ntstdio,"dhcp4c_renew_info %d\n", ret);355 printf("dhcp4c_renew_info %d\n", ret); 358 356 } 359 357 else { … … 383 381 else { 384 382 for (c = 1; c <= *ptr; c++) 385 ntstdio_printf(&ntstdio,"%c", *(ptr + c));383 printf("%c", *(ptr + c)); 386 384 ptr += *ptr + 1; 387 385 if (*ptr) 388 ntstdio_printf(&ntstdio,".");386 printf("."); 389 387 } 390 388 } … … 406 404 return error; 407 405 408 ntstdio_printf(&ntstdio," mname: ");406 printf(" mname: "); 409 407 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: "); 412 410 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); 420 418 421 419 return E_OK; … … 433 431 int scount; 434 432 435 ntstdio_printf(&ntstdio,"question section: %d\n", rslv->dns_hdr.qdcount);433 printf("question section: %d\n", rslv->dns_hdr.qdcount); 436 434 offset = rslv->qd_offset; 437 435 for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) { … … 439 437 return error; 440 438 441 ntstdio_printf(&ntstdio,"%2d: ", scount);439 printf("%2d: ", scount); 442 440 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)); 444 442 offset = error; 445 443 } … … 463 461 int pos; 464 462 465 ntstdio_printf(&ntstdio,"%10s section: %d\n", title, scount);463 printf("%10s section: %d\n", title, scount); 466 464 for (count = 1; count <= scount; count++) { 467 465 if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0) 468 466 return error; 469 467 470 ntstdio_printf(&ntstdio,"%2d: ", count);468 printf("%2d: ", count); 471 469 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", 473 471 dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset); 474 472 … … 479 477 pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0); 480 478 temp[pos] = '\0'; 481 ntstdio_printf(&ntstdio," IPv4 addr: %s\n", temp);479 printf(" IPv4 addr: %s\n", temp); 482 480 break; 483 481 case DNS_TYPE_NS: 484 ntstdio_printf(&ntstdio," host: ");482 printf(" host: "); 485 483 s_show_dns_domain_name(msg, rr.rdata_offset); 486 ntstdio_putc(&ntstdio,'\n');484 putchar('\n'); 487 485 break; 488 486 case DNS_TYPE_CNAME: 489 ntstdio_printf(&ntstdio," host: ");487 printf(" host: "); 490 488 s_show_dns_domain_name(msg, rr.rdata_offset); 491 ntstdio_putc(&ntstdio,'\n');489 putchar('\n'); 492 490 break; 493 491 case DNS_TYPE_SOA: … … 495 493 break; 496 494 case DNS_TYPE_PTR: 497 ntstdio_printf(&ntstdio," PTR: ");495 printf(" PTR: "); 498 496 s_show_dns_domain_name(msg, rr.rdata_offset); 499 ntstdio_putc(&ntstdio,'\n');497 putchar('\n'); 500 498 break; 501 499 case DNS_TYPE_AAAA: … … 503 501 pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0); 504 502 temp[pos] = '\0'; 505 ntstdio_printf(&ntstdio," IPv6 addr: %s\n", temp);503 printf(" IPv6 addr: %s\n", temp); 506 504 break; 507 505 default: 508 ntstdio_printf(&ntstdio," data: ");506 printf(" data: "); 509 507 col = 32; 510 508 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)); 512 510 if (--col == 0) { 513 ntstdio_printf(&ntstdio,"\n ");511 printf("\n "); 514 512 col = 32; 515 513 } 516 514 } 517 ntstdio_putc(&ntstdio,'\n');515 putchar('\n'); 518 516 break; 519 517 } … … 539 537 #if defined(SUPPORT_INET6) 540 538 541 ntstdio_printf(&ntstdio,"domain name: %s\n", dns_in6_get_dname());539 printf("domain name: %s\n", dns_in6_get_dname()); 542 540 543 541 #else /* of #if defined(SUPPORT_INET6) */ 544 542 545 ntstdio_printf(&ntstdio,"domain name: %s\n", dns_in4_get_dname());543 printf("domain name: %s\n", dns_in4_get_dname()); 546 544 547 545 #endif /* of #if defined(SUPPORT_INET6) */ … … 549 547 #if defined(SUPPORT_INET6) 550 548 dns_in6_get_addr(&in6_addr); 551 ntstdio_printf(&ntstdio,"IPv6 DNS server: ");549 printf("IPv6 DNS server: "); 552 550 if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr)) 553 ntstdio_printf(&ntstdio,"not available.\n");551 printf("not available.\n"); 554 552 else { 555 553 pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0); 556 554 temp[pos] = '\0'; 557 ntstdio_printf(&ntstdio,"%s.\n", temp);555 printf("%s.\n", temp); 558 556 } 559 557 #endif /* of #if defined(SUPPORT_INET6) */ … … 561 559 #if defined(SUPPORT_INET4) 562 560 dns_in4_get_addr(&in4_addr); 563 ntstdio_printf(&ntstdio,"IPv4 DNS server: ");561 printf("IPv4 DNS server: "); 564 562 if (in4_addr == IPV4_ADDRANY) 565 ntstdio_printf(&ntstdio,"not available.\n");563 printf("not available.\n"); 566 564 else { 567 565 pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0); 568 566 temp[pos] = '\0'; 569 ntstdio_printf(&ntstdio,"%s.\n", temp);567 printf("%s.\n", temp); 570 568 } 571 569 #endif /* of #if defined(SUPPORT_INET4) */ … … 604 602 line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO)); 605 603 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"); 607 605 return 0; 608 606 } … … 620 618 621 619 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)); 623 621 return 0; 624 622 } 625 623 626 624 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)); 628 626 goto err_ret; 629 627 } 630 628 631 629 dly_tsk(1 * 1000); 632 ntstdio_printf(&ntstdio,"DNS header: flags: ");630 printf("DNS header: flags: "); 633 631 if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE | 634 632 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", 646 644 (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED 647 645 ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]); 648 646 649 647 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)); 651 649 } 652 650 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)); 654 652 } 655 653 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)); 657 655 } 658 656 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)); 660 658 } 661 659 662 660 err_ret: 663 661 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)); 665 663 return 0; 666 664 }
Note:
See TracChangeset
for help on using the changeset viewer.