10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (C) 2002 by Darren Reed. 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 50Sstevel@tonic-gate * 6*2393Syz155240 * $Id: remove_poolnode.c,v 1.3 2003/11/22 10:14:36 darrenr Exp $ 70Sstevel@tonic-gate */ 80Sstevel@tonic-gate 90Sstevel@tonic-gate #include <fcntl.h> 100Sstevel@tonic-gate #include <sys/ioctl.h> 110Sstevel@tonic-gate #include "ipf.h" 120Sstevel@tonic-gate #include "netinet/ip_lookup.h" 13*2393Syz155240 #include "netinet/ip_pool.h" 140Sstevel@tonic-gate 150Sstevel@tonic-gate static int poolfd = -1; 160Sstevel@tonic-gate 170Sstevel@tonic-gate 180Sstevel@tonic-gate int remove_poolnode(unit, name, node, iocfunc) 190Sstevel@tonic-gate int unit; 200Sstevel@tonic-gate char *name; 210Sstevel@tonic-gate ip_pool_node_t *node; 220Sstevel@tonic-gate ioctlfunc_t iocfunc; 230Sstevel@tonic-gate { 240Sstevel@tonic-gate ip_pool_node_t pn; 250Sstevel@tonic-gate iplookupop_t op; 260Sstevel@tonic-gate 270Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0)) 280Sstevel@tonic-gate poolfd = open(IPLOOKUP_NAME, O_RDWR); 290Sstevel@tonic-gate if ((poolfd == -1) && ((opts & OPT_DONOTHING) == 0)) 300Sstevel@tonic-gate return -1; 310Sstevel@tonic-gate 320Sstevel@tonic-gate op.iplo_unit = unit; 330Sstevel@tonic-gate op.iplo_type = IPLT_POOL; 340Sstevel@tonic-gate op.iplo_arg = 0; 350Sstevel@tonic-gate strncpy(op.iplo_name, name, sizeof(op.iplo_name)); 360Sstevel@tonic-gate op.iplo_struct = &pn; 370Sstevel@tonic-gate op.iplo_size = sizeof(pn); 380Sstevel@tonic-gate 390Sstevel@tonic-gate bzero((char *)&pn, sizeof(pn)); 400Sstevel@tonic-gate bcopy((char *)&node->ipn_addr, (char *)&pn.ipn_addr, 410Sstevel@tonic-gate sizeof(pn.ipn_addr)); 420Sstevel@tonic-gate bcopy((char *)&node->ipn_mask, (char *)&pn.ipn_mask, 430Sstevel@tonic-gate sizeof(pn.ipn_mask)); 440Sstevel@tonic-gate pn.ipn_info = node->ipn_info; 450Sstevel@tonic-gate strncpy(pn.ipn_name, node->ipn_name, sizeof(pn.ipn_name)); 460Sstevel@tonic-gate 470Sstevel@tonic-gate if ((*iocfunc)(poolfd, SIOCLOOKUPDELNODE, &op)) { 480Sstevel@tonic-gate if ((opts & OPT_DONOTHING) == 0) { 490Sstevel@tonic-gate perror("remove_pool:SIOCLOOKUPDELNODE"); 500Sstevel@tonic-gate return -1; 510Sstevel@tonic-gate } 520Sstevel@tonic-gate } 530Sstevel@tonic-gate 540Sstevel@tonic-gate return 0; 550Sstevel@tonic-gate } 56