Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
bwmtools
bwmtools
Commits
d56b391d
Commit
d56b391d
authored
Mar 06, 2006
by
Nigel Kukard
Browse files
* Updated ipq interface
parent
a1ecc09c
Changes
3
Hide whitespace changes
Inline
Side-by-side
bwmd/ipq.c
View file @
d56b391d
...
...
@@ -48,7 +48,7 @@ static struct ipq_handle *getIPQHandle()
int
result
;
// Create our ipq socket
h
=
ipq_create_handle
(
0
,
PF_INET
,
1048576
);
h
=
ipq_create_handle
(
0
,
PF_INET
);
if
(
!
h
)
{
fprintf
(
stderr
,
"Failed to create IPQ handle
\n
"
);
...
...
bwmd/libipq.c
View file @
d56b391d
...
...
@@ -57,8 +57,7 @@ enum {
IPQ_ERR_SUPP
,
IPQ_ERR_RECVBUF
,
IPQ_ERR_TIMEOUT
,
IPQ_ERR_PROTOCOL
,
IPQ_ERR_SETSOCKET
IPQ_ERR_PROTOCOL
};
#define IPQ_MAXERR IPQ_ERR_PROTOCOL
...
...
@@ -82,8 +81,7 @@ struct ipq_errmap_t {
{
IPQ_ERR_SUPP
,
"Operation not supported"
},
{
IPQ_ERR_RECVBUF
,
"Receive buffer size invalid"
},
{
IPQ_ERR_TIMEOUT
,
"Timeout"
},
{
IPQ_ERR_PROTOCOL
,
"Invalid protocol specified"
},
{
IPQ_ERR_SETSOCKET
,
"Failed to set socket options"
}
{
IPQ_ERR_PROTOCOL
,
"Invalid protocol specified"
}
};
static
int
ipq_errno
=
IPQ_ERR_NONE
;
...
...
@@ -125,7 +123,8 @@ static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h,
unsigned
char
*
buf
,
size_t
len
,
int
timeout
)
{
int
addrlen
,
status
;
unsigned
int
addrlen
;
int
status
;
struct
nlmsghdr
*
nlh
;
if
(
len
<
sizeof
(
struct
nlmsgerr
))
{
...
...
@@ -174,6 +173,10 @@ static ssize_t ipq_netlink_recvfrom(const struct ipq_handle *h,
ipq_errno
=
IPQ_ERR_RECV
;
return
-
1
;
}
if
(
h
->
peer
.
nl_pid
!=
0
)
{
ipq_errno
=
IPQ_ERR_RECV
;
return
-
1
;
}
if
(
status
==
0
)
{
ipq_errno
=
IPQ_ERR_NLEOF
;
return
-
1
;
...
...
@@ -202,7 +205,7 @@ static char *ipq_strerror(int errcode)
/*
* Create and initialise an ipq handle.
*/
struct
ipq_handle
*
ipq_create_handle
(
u_int32_t
flags
,
u_int32_t
protocol
,
int
recv_buf_size
)
struct
ipq_handle
*
ipq_create_handle
(
u_int32_t
flags
,
u_int32_t
protocol
)
{
int
status
;
struct
ipq_handle
*
h
;
...
...
@@ -224,22 +227,13 @@ struct ipq_handle *ipq_create_handle(u_int32_t flags, u_int32_t protocol, int re
free
(
h
);
return
NULL
;
}
if
(
h
->
fd
==
-
1
)
{
ipq_errno
=
IPQ_ERR_SOCKET
;
close
(
h
->
fd
);
free
(
h
);
return
NULL
;
}
status
=
setsockopt
(
h
->
fd
,
SOL_SOCKET
,
SO_RCVBUF
,
&
recv_buf_size
,
sizeof
(
int
));
if
(
status
==
-
1
)
{
ipq_errno
=
IPQ_ERR_SETSOCKET
;
close
(
h
->
fd
);
free
(
h
);
return
NULL
;
}
memset
(
&
h
->
local
,
0
,
sizeof
(
struct
sockaddr_nl
));
h
->
local
.
nl_family
=
AF_NETLINK
;
h
->
local
.
nl_pid
=
getpid
();
...
...
include/libipq.h
View file @
d56b391d
...
...
@@ -35,7 +35,7 @@
typedef
u_int64_t
ipq_id_t
;
#else
#include
<linux/netfilter_ipv4/ip_queue.h>
typedef
u
_int32_t
ipq_id_t
;
typedef
u
nsigned
long
ipq_id_t
;
#endif
#ifdef DEBUG_LIBIPQ
...
...
@@ -58,7 +58,7 @@ struct ipq_handle
struct
sockaddr_nl
peer
;
};
struct
ipq_handle
*
ipq_create_handle
(
u_int32_t
flags
,
u_int32_t
protocol
,
int
recv_buf_size
);
struct
ipq_handle
*
ipq_create_handle
(
u_int32_t
flags
,
u_int32_t
protocol
);
int
ipq_destroy_handle
(
struct
ipq_handle
*
h
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment