Print this page
8485 Remove set but unused variables in usr/src/cmd
   1 /*
   2  * Copyright (C) 2003 by Darren Reed.
   3  *
   4  * See the IPFILTER.LICENCE file for details on licencing.
   5  *
   6  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
   7  * Use is subject to license terms.
   8  *
   9  * Copyright (c) 2014, Joyent, Inc.  All rights reserved.

  10  */
  11 
  12 #include <sys/types.h>
  13 #include <sys/time.h>
  14 #include <sys/param.h>
  15 #include <sys/socket.h>
  16 #if defined(BSD) && (BSD >= 199306)
  17 # include <sys/cdefs.h>
  18 #endif
  19 #include <sys/ioctl.h>
  20 
  21 #include <net/if.h>
  22 #if __FreeBSD_version >= 300000
  23 # include <net/if_var.h>
  24 #endif
  25 #include <netinet/in.h>
  26 
  27 #include <arpa/inet.h>
  28 
  29 #include <stdio.h>


 365                 }
 366 
 367                 if (setzone(fd) != 0) {
 368                         close(fd);
 369                         exit(1);
 370                 }
 371         }
 372 
 373         if (ippool_parsefile(fd, infile, ioctl) != 0)
 374                 return -1;
 375         return 0;
 376 }
 377 
 378 
 379 int poollist(argc, argv)
 380 int argc;
 381 char *argv[];
 382 {
 383         char *kernel, *core, *poolname;
 384         int c, role, type, live_kernel;
 385         ip_pool_stat_t *plstp, plstat;
 386         iphtstat_t *htstp, htstat;
 387         iphtable_t *hptr;
 388         iplookupop_t op;
 389         ip_pool_t *ptr;
 390 
 391         core = NULL;
 392         kernel = NULL;
 393         live_kernel = 1;
 394         type = IPLT_ALL;
 395         poolname = NULL;
 396         role = IPL_LOGALL;
 397 
 398         while ((c = getopt(argc, argv, "dG:m:M:N:o:Rt:vz:")) != -1)
 399                 switch (c)
 400                 {
 401                 case 'd' :
 402                         opts |= OPT_DEBUG;
 403                         break;
 404                 case 'G' :
 405                         setzonename_global(optarg);
 406                         break;


 452 
 453                 if (setzone(fd) != 0) {
 454                         close(fd);
 455                         exit(1);
 456                 }
 457         }
 458 
 459         bzero((char *)&op, sizeof(op));
 460         if (poolname != NULL) {
 461                 strncpy(op.iplo_name, poolname, sizeof(op.iplo_name));
 462                 op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
 463         }
 464         op.iplo_unit = role;
 465 
 466         if (live_kernel == 0) {
 467                 poollist_dead(role, poolname, type, kernel, core);
 468                 return (0);
 469         }
 470 
 471         if (type == IPLT_ALL || type == IPLT_POOL) {
 472                 plstp = &plstat;
 473                 op.iplo_type = IPLT_POOL;
 474                 op.iplo_size = sizeof(plstat);
 475                 op.iplo_struct = &plstat;
 476                 op.iplo_name[0] = '\0';
 477                 op.iplo_arg = 0;
 478 
 479                 if (role != IPL_LOGALL) {
 480                         op.iplo_unit = role;
 481 
 482                         c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 483                         if (c == -1) {
 484                                 perror("ioctl(SIOCLOOKUPSTAT)");
 485                                 return -1;
 486                         }
 487 
 488                         showpools_live(fd, role, &plstat, poolname, opts);
 489                 } else {
 490                         for (role = 0; role <= IPL_LOGMAX; role++) {
 491                                 op.iplo_unit = role;
 492 
 493                                 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 494                                 if (c == -1) {
 495                                         perror("ioctl(SIOCLOOKUPSTAT)");
 496                                         return -1;
 497                                 }
 498 
 499                                 showpools_live(fd, role, &plstat, poolname, opts);
 500                         }
 501 
 502                         role = IPL_LOGALL;
 503                 }
 504         }
 505         if (type == IPLT_ALL || type == IPLT_HASH) {
 506                 htstp = &htstat;
 507                 op.iplo_type = IPLT_HASH;
 508                 op.iplo_size = sizeof(htstat);
 509                 op.iplo_struct = &htstat;
 510                 op.iplo_name[0] = '\0';
 511                 op.iplo_arg = 0;
 512 
 513                 if (role != IPL_LOGALL) {
 514                         op.iplo_unit = role;
 515 
 516                         c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 517                         if (c == -1) {
 518                                 perror("ioctl(SIOCLOOKUPSTAT)");
 519                                 return -1;
 520                         }
 521                         showhashs_live(fd, role, &htstat, poolname, opts);
 522                 } else {
 523                         for (role = 0; role <= IPL_LOGMAX; role++) {
 524 
 525                                 op.iplo_unit = role;
 526                                 c = ioctl(fd, SIOCLOOKUPSTAT, &op);


 625         iter.ili_ival = IPFGENITER_LOOKUP;
 626         iter.ili_data = &pool;
 627         iter.ili_unit = role;
 628         *iter.ili_name = '\0';
 629 
 630         while (plstp->ipls_list[role] != NULL) {
 631                 if (ioctl(fd, SIOCLOOKUPITER, &obj)) {
 632                         perror("ioctl(SIOCLOOKUPITER)");
 633                         break;
 634                 }
 635                 (void) printpool_live(&pool, fd, poolname, opts);
 636 
 637                 plstp->ipls_list[role] = pool.ipo_next;
 638         }
 639 }
 640 
 641 int poolstats(argc, argv)
 642 int argc;
 643 char *argv[];
 644 {
 645         int c, type, role, live_kernel;
 646         ip_pool_stat_t plstat;
 647         char *kernel, *core;
 648         iphtstat_t htstat;
 649         iplookupop_t op;
 650 
 651         core = NULL;
 652         kernel = NULL;
 653         live_kernel = 1;
 654         type = IPLT_ALL;
 655         role = IPL_LOGALL;
 656 
 657         bzero((char *)&op, sizeof(op));
 658 
 659         while ((c = getopt(argc, argv, "dG:M:N:o:t:vz:")) != -1)
 660                 switch (c)
 661                 {
 662                 case 'd' :
 663                         opts |= OPT_DEBUG;
 664                         break;
 665                 case 'G' :
 666                         setzonename_global(optarg);
 667                         break;
 668                 case 'M' :
 669                         live_kernel = 0;
 670                         core = optarg;
 671                         break;
 672                 case 'N' :
 673                         live_kernel = 0;
 674                         kernel = optarg;
 675                         break;
 676                 case 'o' :
 677                         role = getrole(optarg);
 678                         if (role == IPL_LOGNONE) {
 679                                 fprintf(stderr, "unknown role '%s'\n", optarg);
 680                                 return -1;
 681                         }
 682                         break;
 683                 case 't' :
 684                         type = gettype(optarg, NULL);
 685                         if (type != IPLT_POOL) {
 686                                 fprintf(stderr,
 687                                         "-s not supported for this type yet\n");
 688                                 return -1;
 689                         }
 690                         break;
 691                 case 'v' :
 692                         opts |= OPT_VERBOSE;
 693                         break;
 694                 case 'z' :


   1 /*
   2  * Copyright (C) 2003 by Darren Reed.
   3  *
   4  * See the IPFILTER.LICENCE file for details on licencing.
   5  *
   6  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
   7  * Use is subject to license terms.
   8  *
   9  * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  10  * Copyright 2017 Gary Mills
  11  */
  12 
  13 #include <sys/types.h>
  14 #include <sys/time.h>
  15 #include <sys/param.h>
  16 #include <sys/socket.h>
  17 #if defined(BSD) && (BSD >= 199306)
  18 # include <sys/cdefs.h>
  19 #endif
  20 #include <sys/ioctl.h>
  21 
  22 #include <net/if.h>
  23 #if __FreeBSD_version >= 300000
  24 # include <net/if_var.h>
  25 #endif
  26 #include <netinet/in.h>
  27 
  28 #include <arpa/inet.h>
  29 
  30 #include <stdio.h>


 366                 }
 367 
 368                 if (setzone(fd) != 0) {
 369                         close(fd);
 370                         exit(1);
 371                 }
 372         }
 373 
 374         if (ippool_parsefile(fd, infile, ioctl) != 0)
 375                 return -1;
 376         return 0;
 377 }
 378 
 379 
 380 int poollist(argc, argv)
 381 int argc;
 382 char *argv[];
 383 {
 384         char *kernel, *core, *poolname;
 385         int c, role, type, live_kernel;
 386         ip_pool_stat_t  plstat;
 387         iphtstat_t  htstat;
 388         iphtable_t *hptr;
 389         iplookupop_t op;
 390         ip_pool_t *ptr;
 391 
 392         core = NULL;
 393         kernel = NULL;
 394         live_kernel = 1;
 395         type = IPLT_ALL;
 396         poolname = NULL;
 397         role = IPL_LOGALL;
 398 
 399         while ((c = getopt(argc, argv, "dG:m:M:N:o:Rt:vz:")) != -1)
 400                 switch (c)
 401                 {
 402                 case 'd' :
 403                         opts |= OPT_DEBUG;
 404                         break;
 405                 case 'G' :
 406                         setzonename_global(optarg);
 407                         break;


 453 
 454                 if (setzone(fd) != 0) {
 455                         close(fd);
 456                         exit(1);
 457                 }
 458         }
 459 
 460         bzero((char *)&op, sizeof(op));
 461         if (poolname != NULL) {
 462                 strncpy(op.iplo_name, poolname, sizeof(op.iplo_name));
 463                 op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
 464         }
 465         op.iplo_unit = role;
 466 
 467         if (live_kernel == 0) {
 468                 poollist_dead(role, poolname, type, kernel, core);
 469                 return (0);
 470         }
 471 
 472         if (type == IPLT_ALL || type == IPLT_POOL) {

 473                 op.iplo_type = IPLT_POOL;
 474                 op.iplo_size = sizeof(plstat);
 475                 op.iplo_struct = &plstat;
 476                 op.iplo_name[0] = '\0';
 477                 op.iplo_arg = 0;
 478 
 479                 if (role != IPL_LOGALL) {
 480                         op.iplo_unit = role;
 481 
 482                         c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 483                         if (c == -1) {
 484                                 perror("ioctl(SIOCLOOKUPSTAT)");
 485                                 return -1;
 486                         }
 487 
 488                         showpools_live(fd, role, &plstat, poolname, opts);
 489                 } else {
 490                         for (role = 0; role <= IPL_LOGMAX; role++) {
 491                                 op.iplo_unit = role;
 492 
 493                                 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 494                                 if (c == -1) {
 495                                         perror("ioctl(SIOCLOOKUPSTAT)");
 496                                         return -1;
 497                                 }
 498 
 499                                 showpools_live(fd, role, &plstat, poolname, opts);
 500                         }
 501 
 502                         role = IPL_LOGALL;
 503                 }
 504         }
 505         if (type == IPLT_ALL || type == IPLT_HASH) {

 506                 op.iplo_type = IPLT_HASH;
 507                 op.iplo_size = sizeof(htstat);
 508                 op.iplo_struct = &htstat;
 509                 op.iplo_name[0] = '\0';
 510                 op.iplo_arg = 0;
 511 
 512                 if (role != IPL_LOGALL) {
 513                         op.iplo_unit = role;
 514 
 515                         c = ioctl(fd, SIOCLOOKUPSTAT, &op);
 516                         if (c == -1) {
 517                                 perror("ioctl(SIOCLOOKUPSTAT)");
 518                                 return -1;
 519                         }
 520                         showhashs_live(fd, role, &htstat, poolname, opts);
 521                 } else {
 522                         for (role = 0; role <= IPL_LOGMAX; role++) {
 523 
 524                                 op.iplo_unit = role;
 525                                 c = ioctl(fd, SIOCLOOKUPSTAT, &op);


 624         iter.ili_ival = IPFGENITER_LOOKUP;
 625         iter.ili_data = &pool;
 626         iter.ili_unit = role;
 627         *iter.ili_name = '\0';
 628 
 629         while (plstp->ipls_list[role] != NULL) {
 630                 if (ioctl(fd, SIOCLOOKUPITER, &obj)) {
 631                         perror("ioctl(SIOCLOOKUPITER)");
 632                         break;
 633                 }
 634                 (void) printpool_live(&pool, fd, poolname, opts);
 635 
 636                 plstp->ipls_list[role] = pool.ipo_next;
 637         }
 638 }
 639 
 640 int poolstats(argc, argv)
 641 int argc;
 642 char *argv[];
 643 {
 644         int c, type, role;
 645         ip_pool_stat_t plstat;

 646         iphtstat_t htstat;
 647         iplookupop_t op;
 648 



 649         type = IPLT_ALL;
 650         role = IPL_LOGALL;
 651 
 652         bzero((char *)&op, sizeof(op));
 653 
 654         while ((c = getopt(argc, argv, "dG:M:N:o:t:vz:")) != -1)
 655                 switch (c)
 656                 {
 657                 case 'd' :
 658                         opts |= OPT_DEBUG;
 659                         break;
 660                 case 'G' :
 661                         setzonename_global(optarg);
 662                         break;
 663                 case 'M' :


 664                         break;
 665                 case 'N' :


 666                         break;
 667                 case 'o' :
 668                         role = getrole(optarg);
 669                         if (role == IPL_LOGNONE) {
 670                                 fprintf(stderr, "unknown role '%s'\n", optarg);
 671                                 return -1;
 672                         }
 673                         break;
 674                 case 't' :
 675                         type = gettype(optarg, NULL);
 676                         if (type != IPLT_POOL) {
 677                                 fprintf(stderr,
 678                                         "-s not supported for this type yet\n");
 679                                 return -1;
 680                         }
 681                         break;
 682                 case 'v' :
 683                         opts |= OPT_VERBOSE;
 684                         break;
 685                 case 'z' :