Changeset 442 for EcnlProtoTool/trunk/ntshell/src/netcmd.c
- Timestamp:
- Jul 13, 2020, 8:07:55 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/ntshell/src/netcmd.c
r441 r442 40 40 #include <t_stdlib.h> 41 41 #include <sil.h> 42 #include <string.h>43 42 #include "syssvc/serial.h" 44 43 #include "syssvc/syslog.h" … … 59 58 #include <netapp/resolver.h> 60 59 #include "core/ntlibc.h" 61 #include "util/ntstdio.h"62 #include <stdio.h>63 60 #include "ntp_cli.h" 64 61 #include "kernel_cfg.h" … … 71 68 extern void ping6(T_IN6_ADDR *addr, uint_t tmo, uint_t len); 72 69 extern void ping4(T_IN4_ADDR *addr, uint_t tmo, uint_t len); 73 extern ntstdio_t *ntstdio;74 70 75 71 /* … … 255 251 256 252 if (apip == '1') 257 ntlibc_strcpy(line, i6rlp_pmtu_str1);253 strcpy(line, i6rlp_pmtu_str1); 258 254 else if (apip == '2') 259 ntlibc_strcpy(line, i6rlp_pmtu_str2);255 strcpy(line, i6rlp_pmtu_str2); 260 256 else if (apip == '3') 261 ntlibc_strcpy(line, i6rlp_pmtu_str3);257 strcpy(line, i6rlp_pmtu_str3); 262 258 263 259 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) … … 280 276 281 277 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 282 ntstdio_printf(ntstdio,"[PING] unknown host.\n");278 printf("[PING] unknown host.\n"); 283 279 return 0; 284 280 } … … 299 295 #if defined(SUPPORT_INET4) 300 296 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)); 302 298 ping6(&addr, (uint_t)tmo, (uint_t)size); 303 299 } 304 300 else { 305 301 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)); 307 303 ping4(&addr4, (uint_t)tmo, (uint_t)size); 308 304 } 309 305 #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)); 311 307 ping6(&addr, (uint_t)tmo, (uint_t)size); 312 308 #endif /* of #if defined(SUPPORT_INET4) */ 313 309 #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)); 315 311 ping4(&addr, (uint_t)tmo, (uint_t)size); 316 312 #endif /* of #if defined(SUPPORT_INET6) */ … … 331 327 pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0); 332 328 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", 335 331 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", 337 333 rebind / 3600, (rebind / 60) % 60, rebind % 60, 338 334 expire / 3600, (expire / 60) % 60, expire % 60); 339 335 } 340 336 else if (ret == E_OBJ) 341 ntstdio_printf(ntstdio,"DHCPv4 server: not available.\n");337 printf("DHCPv4 server: not available.\n"); 342 338 } 343 339 … … 349 345 return 0; 350 346 351 if ( ntlibc_strcmp(argv[1], "rel") == 0) {347 if (strcmp(argv[1], "rel") == 0) { 352 348 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) { 356 352 ret = dhcp4c_renew_info(); 357 ntstdio_printf(ntstdio,"dhcp4c_renew_info %d\n", ret);353 printf("dhcp4c_renew_info %d\n", ret); 358 354 } 359 355 else { … … 383 379 else { 384 380 for (c = 1; c <= *ptr; c++) 385 ntstdio_printf(ntstdio,"%c", *(ptr + c));381 printf("%c", *(ptr + c)); 386 382 ptr += *ptr + 1; 387 383 if (*ptr) 388 ntstdio_printf(ntstdio,".");384 printf("."); 389 385 } 390 386 } … … 406 402 return error; 407 403 408 ntstdio_printf(ntstdio," mname: ");404 printf(" mname: "); 409 405 rn_offset = s_show_dns_domain_name(msg, offset); 410 406 putchar('\n'); 411 ntstdio_printf(ntstdio," rname: ");407 printf(" rname: "); 412 408 s_show_dns_domain_name(msg, rn_offset); 413 409 putchar('\n'); 414 410 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); 420 416 421 417 return E_OK; … … 433 429 int scount; 434 430 435 ntstdio_printf(ntstdio,"question section: %d\n", rslv->dns_hdr.qdcount);431 printf("question section: %d\n", rslv->dns_hdr.qdcount); 436 432 offset = rslv->qd_offset; 437 433 for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) { … … 439 435 return error; 440 436 441 ntstdio_printf(ntstdio,"%2d: ", scount);437 printf("%2d: ", scount); 442 438 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)); 444 440 offset = error; 445 441 } … … 463 459 int pos; 464 460 465 ntstdio_printf(ntstdio,"%10s section: %d\n", title, scount);461 printf("%10s section: %d\n", title, scount); 466 462 for (count = 1; count <= scount; count++) { 467 463 if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0) 468 464 return error; 469 465 470 ntstdio_printf(ntstdio,"%2d: ", count);466 printf("%2d: ", count); 471 467 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", 473 469 dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset); 474 470 … … 479 475 pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0); 480 476 temp[pos] = '\0'; 481 ntstdio_printf(ntstdio," IPv4 addr: %s\n", temp);477 printf(" IPv4 addr: %s\n", temp); 482 478 break; 483 479 case DNS_TYPE_NS: 484 ntstdio_printf(ntstdio," host: ");480 printf(" host: "); 485 481 s_show_dns_domain_name(msg, rr.rdata_offset); 486 482 putchar('\n'); 487 483 break; 488 484 case DNS_TYPE_CNAME: 489 ntstdio_printf(ntstdio," host: ");485 printf(" host: "); 490 486 s_show_dns_domain_name(msg, rr.rdata_offset); 491 487 putchar('\n'); … … 495 491 break; 496 492 case DNS_TYPE_PTR: 497 ntstdio_printf(ntstdio," PTR: ");493 printf(" PTR: "); 498 494 s_show_dns_domain_name(msg, rr.rdata_offset); 499 495 putchar('\n'); … … 503 499 pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0); 504 500 temp[pos] = '\0'; 505 ntstdio_printf(ntstdio," IPv6 addr: %s\n", temp);501 printf(" IPv6 addr: %s\n", temp); 506 502 break; 507 503 default: 508 ntstdio_printf(ntstdio," data: ");504 printf(" data: "); 509 505 col = 32; 510 506 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)); 512 508 if (--col == 0) { 513 ntstdio_printf(ntstdio,"\n ");509 printf("\n "); 514 510 col = 32; 515 511 } … … 539 535 #if defined(SUPPORT_INET6) 540 536 541 ntstdio_printf(ntstdio,"domain name: %s\n", dns_in6_get_dname());537 printf("domain name: %s\n", dns_in6_get_dname()); 542 538 543 539 #else /* of #if defined(SUPPORT_INET6) */ 544 540 545 ntstdio_printf(ntstdio,"domain name: %s\n", dns_in4_get_dname());541 printf("domain name: %s\n", dns_in4_get_dname()); 546 542 547 543 #endif /* of #if defined(SUPPORT_INET6) */ … … 549 545 #if defined(SUPPORT_INET6) 550 546 dns_in6_get_addr(&in6_addr); 551 ntstdio_printf(ntstdio,"IPv6 DNS server: ");547 printf("IPv6 DNS server: "); 552 548 if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr)) 553 ntstdio_printf(ntstdio,"not available.\n");549 printf("not available.\n"); 554 550 else { 555 551 pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0); 556 552 temp[pos] = '\0'; 557 ntstdio_printf(ntstdio,"%s.\n", temp);553 printf("%s.\n", temp); 558 554 } 559 555 #endif /* of #if defined(SUPPORT_INET6) */ … … 561 557 #if defined(SUPPORT_INET4) 562 558 dns_in4_get_addr(&in4_addr); 563 ntstdio_printf(ntstdio,"IPv4 DNS server: ");559 printf("IPv4 DNS server: "); 564 560 if (in4_addr == IPV4_ADDRANY) 565 ntstdio_printf(ntstdio,"not available.\n");561 printf("not available.\n"); 566 562 else { 567 563 pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0); 568 564 temp[pos] = '\0'; 569 ntstdio_printf(ntstdio,"%s.\n", temp);565 printf("%s.\n", temp); 570 566 } 571 567 #endif /* of #if defined(SUPPORT_INET4) */ … … 596 592 uint8_t *msg; 597 593 598 if ( ntlibc_strcmp(line, "info") == 0) {594 if (strcmp(line, "info") == 0) { 599 595 dns_info(); 600 596 return 0; … … 604 600 line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO)); 605 601 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"); 607 603 return 0; 608 604 } … … 620 616 621 617 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)); 623 619 return 0; 624 620 } 625 621 626 622 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)); 628 624 goto err_ret; 629 625 } 630 626 631 627 dly_tsk(1 * 1000); 632 ntstdio_printf(ntstdio,"DNS header: flags: ");628 printf("DNS header: flags: "); 633 629 if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE | 634 630 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", 646 642 (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED 647 643 ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]); 648 644 649 645 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)); 651 647 } 652 648 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)); 654 650 } 655 651 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)); 657 653 } 658 654 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)); 660 656 } 661 657 662 658 err_ret: 663 659 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)); 665 661 return 0; 666 662 }
Note:
See TracChangeset
for help on using the changeset viewer.