.TH IPQ_CREATE_HANDLE 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual"
.\"
-\" $Id: ipq_create_handle.3,v 1.1 2000/11/20 14:13:31 jamesm Exp $
+\" $Id: ipq_create_handle.3,v 1.2 2001/10/16 14:41:02 jamesm Exp $
.\"
.\" Copyright (c) 2000-2001 Netfilter Core Team
.\"
.br
.B #include <libipq.h>
.sp
-.BI "struct ipq_handle *ipq_create_handle(u_int32_t " flags );
+.BI "struct ipq_handle *ipq_create_handle(u_int32_t " flags ", u_int32_t " protocol ");"
.br
.BI "int ipq_destroy_handle(struct ipq_handle *" h );
.SH DESCRIPTION
for forward compatibility.
.PP
The
+.I protocol
+parameter is used to specify the protocol of the packets to be queued.
+Valid values are PF_INET for IPv4 and PF_INET6 for IPv6. Currently,
+only one protocol may be queued at a time for a handle.
+.PP
+The
.B ipq_destroy_handle
function frees up resources allocated by
.BR ipq_create_handle ,
.TH LIBIPQ 3 "16 October 2001" "Linux iptables 1.2" "Linux Programmer's Manual"
.\"
-.\" $Id: libipq.3,v 1.3 2001/10/16 14:41:02 jamesm Exp $
+.\" $Id: libipq.3,v 1.4 2001/10/16 16:58:25 jamesm Exp $
.\"
.\" Copyright (c) 2000-2001 Netfilter Core Team
.\"
unsigned char buf[BUFSIZE];
struct ipq_handle *h;
- h = ipq_create_handle(0);
+ h = ipq_create_handle(0, PF_INET);
if (!h)
die(h);
Joost Remijn implemented the
.B ipq_read
timeout feature, which appeared in the 1.2.4 release of iptables.
+.PP
+Fernando Anton added support for IPv6.
.SH SEE ALSO
.BR iptables (8),
.BR ipq_create_handle (3),
*
* Author: James Morris <jmorris@intercode.com.au>
*
+ * 07-11-2001 Modified by Fernando Anton to add support for IPv6.
+ *
* Copyright (c) 2000-2001 Netfilter Core Team
*
* This program is free software; you can redistribute it and/or modify
IPQ_ERR_SEND,
IPQ_ERR_SUPP,
IPQ_ERR_RECVBUF,
- IPQ_ERR_TIMEOUT
+ IPQ_ERR_TIMEOUT,
+ IPQ_ERR_PROTOCOL
};
-#define IPQ_MAXERR IPQ_ERR_TIMEOUT
+#define IPQ_MAXERR IPQ_ERR_PROTOCOL
struct ipq_errmap_t {
int errcode;
{ IPQ_ERR_SEND, "Failed to send netlink message" },
{ IPQ_ERR_SUPP, "Operation not supported" },
{ IPQ_ERR_RECVBUF, "Receive buffer size invalid" },
- { IPQ_ERR_TIMEOUT, "Timeout"}
+ { IPQ_ERR_TIMEOUT, "Timeout"},
+ { IPQ_ERR_PROTOCOL, "Invalid protocol specified" }
};
static int ipq_errno = IPQ_ERR_NONE;
/*
* Create and initialise an ipq handle.
- * FIXME: implement flags.
*/
-struct ipq_handle *ipq_create_handle(u_int32_t flags)
+struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol)
{
int status;
struct ipq_handle *h;
ipq_errno = IPQ_ERR_HANDLE;
return NULL;
}
+
memset(h, 0, sizeof(struct ipq_handle));
- h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_FIREWALL);
+
+ if (protocol == PF_INET)
+ h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_FIREWALL);
+ else if (protocol == PF_INET6)
+ h->fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_IP6_FW);
+ else {
+ ipq_errno = IPQ_ERR_PROTOCOL;
+ free(h);
+ return NULL;
+ }
+
if (h->fd == -1) {
ipq_errno = IPQ_ERR_SOCKET;
close(h->fd);