ippool.c (7c478bd9) ippool.c (7663b816)
1/*
2 * Copyright (C) 2003 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
1/*
2 * Copyright (C) 2003 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 *
6 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
6 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
8 */
9
10#pragma ident "%Z%%M% %I% %E% SMI"
11
12#include <sys/types.h>
13#include <sys/time.h>
14#include <sys/param.h>

--- 315 unchanged lines hidden (view full) ---

330
331int poollist(argc, argv)
332int argc;
333char *argv[];
334{
335 char *kernel, *core, *poolname;
336 int c, role, type, live_kernel;
337 ip_pool_stat_t *plstp, plstat;
7 * Use is subject to license terms.
8 */
9
10#pragma ident "%Z%%M% %I% %E% SMI"
11
12#include <sys/types.h>
13#include <sys/time.h>
14#include <sys/param.h>

--- 315 unchanged lines hidden (view full) ---

330
331int poollist(argc, argv)
332int argc;
333char *argv[];
334{
335 char *kernel, *core, *poolname;
336 int c, role, type, live_kernel;
337 ip_pool_stat_t *plstp, plstat;
338 iphtstat_t *htstp, htstat;
339 iphtable_t *hptr;
338 iplookupop_t op;
339 ip_pool_t *ptr;
340
341 core = NULL;
342 kernel = NULL;
343 live_kernel = 1;
344 type = IPLT_ALL;
345 poolname = NULL;

--- 30 unchanged lines hidden (view full) ---

376 return -1;
377 }
378 break;
379 case 'v' :
380 opts |= OPT_VERBOSE;
381 break;
382 }
383
340 iplookupop_t op;
341 ip_pool_t *ptr;
342
343 core = NULL;
344 kernel = NULL;
345 live_kernel = 1;
346 type = IPLT_ALL;
347 poolname = NULL;

--- 30 unchanged lines hidden (view full) ---

378 return -1;
379 }
380 break;
381 case 'v' :
382 opts |= OPT_VERBOSE;
383 break;
384 }
385
386 if (opts & OPT_DEBUG)
387 fprintf(stderr, "poollist: opts = %#x\n", opts);
388
384 if (!(opts & OPT_DONOTHING) && (fd == -1)) {
385 fd = open(IPLOOKUP_NAME, O_RDWR);
386 if (fd == -1) {
387 perror("open(IPLOOKUP_NAME)");
388 exit(1);
389 }
390 }
391
392 bzero((char *)&op, sizeof(op));
393 if (poolname != NULL) {
394 strncpy(op.iplo_name, poolname, sizeof(op.iplo_name));
395 op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
396 }
389 if (!(opts & OPT_DONOTHING) && (fd == -1)) {
390 fd = open(IPLOOKUP_NAME, O_RDWR);
391 if (fd == -1) {
392 perror("open(IPLOOKUP_NAME)");
393 exit(1);
394 }
395 }
396
397 bzero((char *)&op, sizeof(op));
398 if (poolname != NULL) {
399 strncpy(op.iplo_name, poolname, sizeof(op.iplo_name));
400 op.iplo_name[sizeof(op.iplo_name) - 1] = '\0';
401 }
397 op.iplo_type = type;
398 op.iplo_unit = role;
402 op.iplo_unit = role;
399 op.iplo_size = sizeof(plstat);
400 op.iplo_struct = &plstat;
401 plstp = &plstat;
402
403
403 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
404 if (c == -1) {
405 perror("ioctl(SIOCLOOKUPSTAT)");
406 return -1;
407 }
408
409 if (openkmem(kernel, core) == -1)
410 exit(-1);
411
404 if (openkmem(kernel, core) == -1)
405 exit(-1);
406
412 if (role != IPL_LOGALL) {
413 ptr = plstp->ipls_list[role];
414 while (ptr != NULL) {
415 ptr = printpool(ptr, kmemcpywrap, opts);
407 if (type == IPLT_ALL || type == IPLT_POOL) {
408 plstp = &plstat;
409 op.iplo_type = IPLT_POOL;
410 op.iplo_size = sizeof(plstat);
411 op.iplo_struct = &plstat;
412 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
413 if (c == -1) {
414 perror("ioctl(SIOCLOOKUPSTAT)");
415 return -1;
416 }
416 }
417 } else {
418 for (role = 0; role <= IPL_LOGMAX; role++) {
417
418 if (role != IPL_LOGALL) {
419 ptr = plstp->ipls_list[role];
420 while (ptr != NULL) {
421 ptr = printpool(ptr, kmemcpywrap, opts);
422 }
419 ptr = plstp->ipls_list[role];
420 while (ptr != NULL) {
421 ptr = printpool(ptr, kmemcpywrap, opts);
422 }
423 } else {
424 for (role = 0; role <= IPL_LOGMAX; role++) {
425 ptr = plstp->ipls_list[role];
426 while (ptr != NULL) {
427 ptr = printpool(ptr, kmemcpywrap,
428 opts);
429 }
430 }
431 role = IPL_LOGALL;
423 }
424 }
432 }
433 }
434 if (type == IPLT_ALL || type == IPLT_HASH) {
435 htstp = &htstat;
436 op.iplo_type = IPLT_HASH;
437 op.iplo_size = sizeof(htstat);
438 op.iplo_struct = &htstat;
439 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
440 if (c == -1) {
441 perror("ioctl(SIOCLOOKUPSTAT)");
442 return -1;
443 }
444
445 if (role != IPL_LOGALL) {
446 hptr = htstp->iphs_tables;
447 while (hptr != NULL) {
448 hptr = printhash(hptr, kmemcpywrap, opts);
449 }
450 } else {
451 for (role = 0; role <= IPL_LOGMAX; role++) {
452 hptr = htstp->iphs_tables;
453 while (hptr != NULL) {
454 hptr = printhash(hptr, kmemcpywrap,
455 opts);
456 }
457
458 op.iplo_unit = role;
459 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
460 if (c == -1) {
461 perror("ioctl(SIOCLOOKUPSTAT)");
462 return -1;
463 }
464 }
465 }
466 }
425 return 0;
426}
427
428
429int poolstats(argc, argv)
430int argc;
431char *argv[];
432{
433 int c, type, role, live_kernel;
434 ip_pool_stat_t plstat;
435 char *kernel, *core;
467 return 0;
468}
469
470
471int poolstats(argc, argv)
472int argc;
473char *argv[];
474{
475 int c, type, role, live_kernel;
476 ip_pool_stat_t plstat;
477 char *kernel, *core;
478 iphtstat_t htstat;
436 iplookupop_t op;
437
438 core = NULL;
439 kernel = NULL;
440 live_kernel = 1;
441 type = IPLT_ALL;
442 role = IPL_LOGALL;
443
444 bzero((char *)&op, sizeof(op));
479 iplookupop_t op;
480
481 core = NULL;
482 kernel = NULL;
483 live_kernel = 1;
484 type = IPLT_ALL;
485 role = IPL_LOGALL;
486
487 bzero((char *)&op, sizeof(op));
445 op.iplo_struct = &plstat;
446 op.iplo_size = sizeof(plstat);
447
448 while ((c = getopt(argc, argv, "dM:N:o:t:v")) != -1)
449 switch (c)
450 {
451 case 'd' :
452 opts |= OPT_DEBUG;
453 break;
454 case 'M' :

--- 19 unchanged lines hidden (view full) ---

474 return -1;
475 }
476 break;
477 case 'v' :
478 opts |= OPT_VERBOSE;
479 break;
480 }
481
488
489 while ((c = getopt(argc, argv, "dM:N:o:t:v")) != -1)
490 switch (c)
491 {
492 case 'd' :
493 opts |= OPT_DEBUG;
494 break;
495 case 'M' :

--- 19 unchanged lines hidden (view full) ---

515 return -1;
516 }
517 break;
518 case 'v' :
519 opts |= OPT_VERBOSE;
520 break;
521 }
522
523 if (opts & OPT_DEBUG)
524 fprintf(stderr, "poolstats: opts = %#x\n", opts);
525
482 if (!(opts & OPT_DONOTHING) && (fd == -1)) {
483 fd = open(IPLOOKUP_NAME, O_RDWR);
484 if (fd == -1) {
485 perror("open(IPLOOKUP_NAME)");
486 exit(1);
487 }
488 }
489
526 if (!(opts & OPT_DONOTHING) && (fd == -1)) {
527 fd = open(IPLOOKUP_NAME, O_RDWR);
528 if (fd == -1) {
529 perror("open(IPLOOKUP_NAME)");
530 exit(1);
531 }
532 }
533
490 if (!(opts & OPT_DONOTHING)) {
491 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
492 if (c == -1) {
493 perror("ioctl(SIOCLOOKUPSTAT)");
494 return -1;
534 if (type == IPLT_ALL || type == IPLT_POOL) {
535 op.iplo_type = IPLT_POOL;
536 op.iplo_struct = &plstat;
537 op.iplo_size = sizeof(plstat);
538 if (!(opts & OPT_DONOTHING)) {
539 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
540 if (c == -1) {
541 perror("ioctl(SIOCLOOKUPSTAT)");
542 return -1;
543 }
544 printf("Pools:\t%lu\n", plstat.ipls_pools);
545 printf("Nodes:\t%lu\n", plstat.ipls_nodes);
495 }
546 }
496 printf("Pools:\t%lu\n", plstat.ipls_pools);
497 printf("Hash Tables:\t%lu\n", plstat.ipls_tables);
498 printf("Nodes:\t%lu\n", plstat.ipls_nodes);
499 }
547 }
548
549 if (type == IPLT_ALL || type == IPLT_HASH) {
550 op.iplo_type = IPLT_HASH;
551 op.iplo_struct = &htstat;
552 op.iplo_size = sizeof(htstat);
553 if (!(opts & OPT_DONOTHING)) {
554 c = ioctl(fd, SIOCLOOKUPSTAT, &op);
555 if (c == -1) {
556 perror("ioctl(SIOCLOOKUPSTAT)");
557 return -1;
558 }
559 printf("Hash Tables:\t%lu\n", htstat.iphs_numtables);
560 printf("Nodes:\t%lu\n", htstat.iphs_numnodes);
561 printf("Out of Memory:\t%lu\n", htstat.iphs_nomem);
562 }
563 }
500 return 0;
501}
502
503
504int poolflush(argc, argv)
505int argc;
506char *argv[];
507{

--- 111 unchanged lines hidden ---
564 return 0;
565}
566
567
568int poolflush(argc, argv)
569int argc;
570char *argv[];
571{

--- 111 unchanged lines hidden ---