4 * Copyright (C) 2003-2004 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: load_poolnode.c,v 1.3.2.3 2006/06/16 17:21:06 darrenr Exp
12 #include <sys/ioctl.h>
14 #include "netinet/ip_lookup.h"
15 #include "netinet/ip_pool.h"
17 static int poolfd
= -1;
20 int load_poolnode(role
, name
, node
, iocfunc
)
30 if ((poolfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
31 poolfd
= open(IPLOOKUP_NAME
, O_RDWR
);
32 if ((poolfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
36 op
.iplo_type
= IPLT_POOL
;
39 op
.iplo_size
= sizeof(pn
);
40 strncpy(op
.iplo_name
, name
, sizeof(op
.iplo_name
));
42 bzero((char *)&pn
, sizeof(pn
));
43 bcopy((char *)&node
->ipn_addr
, (char *)&pn
.ipn_addr
,
45 bcopy((char *)&node
->ipn_mask
, (char *)&pn
.ipn_mask
,
47 pn
.ipn_info
= node
->ipn_info
;
48 strncpy(pn
.ipn_name
, node
->ipn_name
, sizeof(pn
.ipn_name
));
50 if ((opts
& OPT_REMOVE
) == 0)
51 err
= (*iocfunc
)(poolfd
, SIOCLOOKUPADDNODE
, &op
);
53 err
= (*iocfunc
)(poolfd
, SIOCLOOKUPDELNODE
, &op
);
56 if ((opts
& OPT_DONOTHING
) == 0) {
57 perror("load_poolnode:SIOCLOOKUP*NODE");