Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dropwatch patch to work with libnl3
# Dependencies sudo apt-get install -y libnl-3-dev libnl-genl-3-dev binutils-dev libreadline6-dev
odintsov@fastnetdev:/tmp/DropWatch/src$ git diff
diff --git a/src/Makefile b/src/Makefile
index cfbf2c6..d50ecec 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -5,7 +5,7 @@ OBJFILES := main.o lookup.o\
lookup_bfd.o lookup_kas.o
dropwatch: $(OBJFILES)
- gcc -g -o dropwatch $(OBJFILES) $(LDFLAGS)
+ gcc -I/usr/include/libnl3/ -g -o dropwatch $(OBJFILES) $(LDFLAGS)
%.o: %.c
gcc $(CFLAGS) $<
dintsov@fastnetdev:/tmp/DropWatch/src$ git diff|cat
diff --git a/src/Makefile b/src/Makefile
index cfbf2c6..b1144cd 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,14 +1,14 @@
all: dropwatch
CFLAGS+=-c -g -D_GNU_SOURCE -Wall -Werror
-LDFLAGS=-lbfd -lreadline -lnl
+LDFLAGS=-lbfd -lreadline -lnl-3 -lnl-genl-3
OBJFILES := main.o lookup.o\
lookup_bfd.o lookup_kas.o
dropwatch: $(OBJFILES)
- gcc -g -o dropwatch $(OBJFILES) $(LDFLAGS)
+ gcc -I/usr/include/libnl3/ -g -o dropwatch $(OBJFILES) $(LDFLAGS)
%.o: %.c
- gcc $(CFLAGS) $<
+ gcc -I/usr/include/libnl3/ $(CFLAGS) $<
clean:
rm -f dropwatch *.o
diff --git a/src/main.c b/src/main.c
index 7d83ada..2d058f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -80,7 +80,7 @@ static void(*type_cb[_NET_DM_CMD_MAX])(struct netlink_message *, int err) = {
NULL
};
-static struct nl_handle *nsd;
+static struct nl_sock *nsd;
static int nsf;
enum {
@@ -108,13 +108,12 @@ void sigint_handler(int signum)
return;
}
-struct nl_handle *setup_netlink_socket()
+struct nl_sock *setup_netlink_socket()
{
- struct nl_handle *sd;
+ struct nl_sock *sd;
int family;
-
- sd = nl_handle_alloc();
+ sd = nl_socket_alloc();
genl_connect(sd);
@@ -128,9 +127,9 @@ struct nl_handle *setup_netlink_socket()
nsf = family;
nl_close(sd);
- nl_handle_destroy(sd);
+ nl_socket_free(sd);
- sd = nl_handle_alloc();
+ sd = nl_socket_alloc();
nl_join_groups(sd, NET_DM_GRP_ALERT);
nl_connect(sd, NETLINK_GENERIC);
@@ -139,7 +138,7 @@ struct nl_handle *setup_netlink_socket()
out_close:
nl_close(sd);
- nl_handle_destroy(sd);
+ nl_socket_free(sd);
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.