1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 5*0Sstevel@tonic-gate * 6*0Sstevel@tonic-gate * $Id: remove_poolnode.c,v 1.1 2003/04/13 06:40:14 darrenr Exp $ 7*0Sstevel@tonic-gate */ 8*0Sstevel@tonic-gate 9*0Sstevel@tonic-gate #include <fcntl.h> 10*0Sstevel@tonic-gate #include <sys/ioctl.h> 11*0Sstevel@tonic-gate #include "ipf.h" 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gate #if SOLARIS2 >= 10 14*0Sstevel@tonic-gate #include "ip_lookup.h" 15*0Sstevel@tonic-gate #include "ip_htable.h" 16*0Sstevel@tonic-gate #else 17*0Sstevel@tonic-gate #include "netinet/ip_lookup.h" 18*0Sstevel@tonic-gate #include "netinet/ip_htable.h" 19*0Sstevel@tonic-gate #endif 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate static int poolfd = -1; 22*0Sstevel@tonic-gate 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate int remove_poolnode(unit, name, node, iocfunc) 25*0Sstevel@tonic-gate int unit; 26*0Sstevel@tonic-gate char *name; 27*0Sstevel@tonic-gate ip_pool_node_t *node; 28*0Sstevel@tonic-gate ioctlfunc_t iocfunc; 29*0Sstevel@tonic-gate { 30*0Sstevel@tonic-gate ip_pool_node_t pn; 31*0Sstevel@tonic-gate iplookupop_t op; 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0)) 34*0Sstevel@tonic-gate poolfd = open(IPLOOKUP_NAME, O_RDWR); 35*0Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0)) 36*0Sstevel@tonic-gate return -1; 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate op.iplo_unit = unit; 39*0Sstevel@tonic-gate op.iplo_type = IPLT_POOL; 40*0Sstevel@tonic-gate op.iplo_arg = 0; 41*0Sstevel@tonic-gate strncpy(op.iplo_name, name, sizeof(op.iplo_name)); 42*0Sstevel@tonic-gate op.iplo_struct = &pn; 43*0Sstevel@tonic-gate op.iplo_size = sizeof(pn); 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate bzero((char *)&pn, sizeof(pn)); 46*0Sstevel@tonic-gate bcopy((char *)&node->ipn_addr, (char *)&pn.ipn_addr, 47*0Sstevel@tonic-gate sizeof(pn.ipn_addr)); 48*0Sstevel@tonic-gate bcopy((char *)&node->ipn_mask, (char *)&pn.ipn_mask, 49*0Sstevel@tonic-gate sizeof(pn.ipn_mask)); 50*0Sstevel@tonic-gate pn.ipn_info = node->ipn_info; 51*0Sstevel@tonic-gate strncpy(pn.ipn_name, node->ipn_name, sizeof(pn.ipn_name)); 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate if ((*iocfunc)(poolfd, SIOCLOOKUPDELNODE, &op)) { 54*0Sstevel@tonic-gate if ((opts & OPT_DONOTHING) == 0) { 55*0Sstevel@tonic-gate perror("remove_pool:SIOCLOOKUPDELNODE"); 56*0Sstevel@tonic-gate return -1; 57*0Sstevel@tonic-gate } 58*0Sstevel@tonic-gate } 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate return 0; 61*0Sstevel@tonic-gate } 62