2 * Copyright (C) 2007 Alejandro Mery <amery@geeks.cl>
4 * More information can be found in the files COPYING and README.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3 of the License. A copy of the
9 * GNU General Public License can be found in the file COPYING.
14 #include <unistd.h> // close()
15 #include <stdio.h> // perror()
17 int nl_open( link_t
*self
) {
19 memset(self
, 0x00, sizeof(self
));
22 if ( (self
->fd
= socket( AF_NETLINK
, SOCK_RAW
, NETLINK_ROUTE
)) < 0 ) {
27 // bind it to the address
28 self
->sa
.nl_family
= AF_NETLINK
;
29 if ( bind( self
->fd
, (const struct sockaddr
*) &self
->sa
, sizeof( self
->sa
) ) < 0 ) {
37 inline int nl_close( link_t
*self
) {
38 return close( self
->fd
);