2 * Copyright (C) 2002 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: remove_hashnode.c,v 1.1 2003/04/13 06:40:14 darrenr Exp $
10 #include <sys/ioctl.h>
12 #include "netinet/ip_lookup.h"
13 #include "netinet/ip_htable.h"
15 static int hashfd
= -1;
18 int remove_hashnode(unit
, name
, node
, iocfunc
)
27 if ((hashfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
28 hashfd
= open(IPLOOKUP_NAME
, O_RDWR
);
29 if ((hashfd
== -1) && ((opts
& OPT_DONOTHING
) == 0))
32 op
.iplo_type
= IPLT_HASH
;
34 op
.iplo_size
= sizeof(ipe
);
35 op
.iplo_struct
= &ipe
;
37 strncpy(op
.iplo_name
, name
, sizeof(op
.iplo_name
));
39 bzero((char *)&ipe
, sizeof(ipe
));
40 bcopy((char *)&node
->ipe_addr
, (char *)&ipe
.ipe_addr
,
41 sizeof(ipe
.ipe_addr
));
42 bcopy((char *)&node
->ipe_mask
, (char *)&ipe
.ipe_mask
,
43 sizeof(ipe
.ipe_mask
));
45 if (opts
& OPT_DEBUG
) {
46 printf("\t%s - ", inet_ntoa(ipe
.ipe_addr
.in4
));
47 printf("%s\n", inet_ntoa(ipe
.ipe_mask
.in4
));
50 if ((*iocfunc
)(hashfd
, SIOCLOOKUPDELNODE
, &op
))
51 if (!(opts
& OPT_DONOTHING
)) {
52 perror("remove_hash:SIOCLOOKUPDELNODE");