2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: load_hashnode.c,v 1.2.4.1 2004/03/06 14:33:28 darrenr Exp $
8 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9 * Use is subject to license terms.
11 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
15 #include <sys/ioctl.h>
17 #include "netinet/ip_lookup.h"
18 #include "netinet/ip_htable.h"
21 static int hashfd
= -1;
24 int load_hashnode(unit
, name
, node
, iocfunc
)
34 if ((hashfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
35 hashfd
= open(IPLOOKUP_NAME
, O_RDWR
);
36 if ((hashfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
38 if (setzone(hashfd
) != 0) {
43 op
.iplo_type
= IPLT_HASH
;
46 op
.iplo_size
= sizeof(ipe
);
47 op
.iplo_struct
= &ipe
;
48 strncpy(op
.iplo_name
, name
, sizeof(op
.iplo_name
));
50 bzero((char *)&ipe
, sizeof(ipe
));
51 ipe
.ipe_family
= node
->ipe_family
;
52 bcopy((char *)&node
->ipe_addr
, (char *)&ipe
.ipe_addr
,
53 sizeof(ipe
.ipe_addr
));
54 bcopy((char *)&node
->ipe_mask
, (char *)&ipe
.ipe_mask
,
55 sizeof(ipe
.ipe_mask
));
56 bcopy((char *)&node
->ipe_group
, (char *)&ipe
.ipe_group
,
57 sizeof(ipe
.ipe_group
));
59 if ((opts
& OPT_REMOVE
) == 0)
60 err
= (*iocfunc
)(hashfd
, SIOCLOOKUPADDNODE
, &op
);
62 err
= (*iocfunc
)(hashfd
, SIOCLOOKUPDELNODE
, &op
);
65 if (!(opts
& OPT_DONOTHING
)) {
66 perror("load_hash:SIOCLOOKUP*NODE");