2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: load_poolnode.c,v 1.3.2.1 2004/03/06 14:33:29 darrenr Exp $
8 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
12 #include <sys/ioctl.h>
14 #include "netinet/ip_lookup.h"
15 #include "netinet/ip_pool.h"
18 static int poolfd
= -1;
21 int load_poolnode(role
, name
, node
, iocfunc
)
31 if ((poolfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
32 poolfd
= open(IPLOOKUP_NAME
, O_RDWR
);
33 if ((poolfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
35 if (setzone(poolfd
) != 0) {
41 op
.iplo_type
= IPLT_POOL
;
44 op
.iplo_size
= sizeof(pn
);
45 strncpy(op
.iplo_name
, name
, sizeof(op
.iplo_name
));
47 bzero((char *)&pn
, sizeof(pn
));
48 bcopy((char *)&node
->ipn_addr
, (char *)&pn
.ipn_addr
,
50 bcopy((char *)&node
->ipn_mask
, (char *)&pn
.ipn_mask
,
52 pn
.ipn_info
= node
->ipn_info
;
53 strncpy(pn
.ipn_name
, node
->ipn_name
, sizeof(pn
.ipn_name
));
55 if ((opts
& OPT_REMOVE
) == 0)
56 err
= (*iocfunc
)(poolfd
, SIOCLOOKUPADDNODE
, &op
);
58 err
= (*iocfunc
)(poolfd
, SIOCLOOKUPDELNODE
, &op
);
61 if ((opts
& OPT_DONOTHING
) == 0) {
62 perror("load_pool:SIOCLOOKUP*NODE");