mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 22:51:03 +02:00
dev-libs/libdnet: Sync with Gentoo
It's from Gentoo commit 074fdbb1bf93766079e0310c5543088cdd4ed5e8.
This commit is contained in:
parent
884e2f9ed0
commit
9bc579b916
@ -1,5 +1,3 @@
|
|||||||
DIST libdnet-1.14.tar.gz 520833 BLAKE2B 97e241fc374fc9489e70d440db5e19199f4e653650af85e24af56bbbc0167db1c451349c43fcb630a26c61f8ca15c58f5c879e0d82654e275189ca3e140bb22a SHA512 ce8d95228f5175e4d9a8ff71bb99eb1ccc3ccd599a85dd07adbfd9842fc54066235d362c8060828fb3ba8129d0e1e8e071e93d60d69c6d03be310c80e61cea93
|
|
||||||
DIST libdnet-1.16.1.tar.gz 666619 BLAKE2B 74472af1bc97c4771909e926eb9b27193c50d665036672fc89ff21159408daeef090e682c5e76e19f31d04e802fb73edf01d1aa057b543568f534d31f8db375b SHA512 9c6899b42502f3892463f1ec694934cc3b02831222fa15b5a899868229366ed4e9cc728ea2c70ec857ee9d676d763b1e390f6878a597a33f7d1cd5a7bd870586
|
|
||||||
DIST libdnet-1.16.2.tar.gz 675191 BLAKE2B 04e4533dbe45700decec4755c7db608d0ca68be05431bf44e6984b2c6a4aec55888fc0f0159916c8ac4a60ec5f743047d2a0a541786cd13fda61739bd7eef0fb SHA512 4b1902553a57eeb56952968e15be032de92d8106dc6e0ebf8e10470605c9c2ed69cb015f4057a5c119d01509c6795fc0dcda85a311d14124dddefdeb6223f848
|
DIST libdnet-1.16.2.tar.gz 675191 BLAKE2B 04e4533dbe45700decec4755c7db608d0ca68be05431bf44e6984b2c6a4aec55888fc0f0159916c8ac4a60ec5f743047d2a0a541786cd13fda61739bd7eef0fb SHA512 4b1902553a57eeb56952968e15be032de92d8106dc6e0ebf8e10470605c9c2ed69cb015f4057a5c119d01509c6795fc0dcda85a311d14124dddefdeb6223f848
|
||||||
DIST libdnet-1.16.4.tar.gz 684358 BLAKE2B 40be891c9004288329aaee0c79a29ebf0f095dfaaca4da98fd5ecfd759e22b8d10dc6b906200db1ac5b0a8cfbbea8fbe509da393e60cddeb5f875ad179cdc67a SHA512 6c5556e365047afcc5da3f76b1c99aa70723c076a7cf75c03d96a661a583dfa6d0ab605076e68efffe5ddca2d69875e4bc4938e0874b8aa24915fcfbfe3f3ff9
|
DIST libdnet-1.16.4.tar.gz 684358 BLAKE2B 40be891c9004288329aaee0c79a29ebf0f095dfaaca4da98fd5ecfd759e22b8d10dc6b906200db1ac5b0a8cfbbea8fbe509da393e60cddeb5f875ad179cdc67a SHA512 6c5556e365047afcc5da3f76b1c99aa70723c076a7cf75c03d96a661a583dfa6d0ab605076e68efffe5ddca2d69875e4bc4938e0874b8aa24915fcfbfe3f3ff9
|
||||||
DIST libdnet-1.17.0.tar.gz 684645 BLAKE2B b208cb41201145411b1949531cb1ab27b4edc6026b8ca703c24231fdb021f46bfe922eb1da11090c271f439339f5384c93168fad3130ed2f89b3d2eca5c7f89f SHA512 b207b2f61e3759a2b17827eabf37b0eb68cb9fa27418f99ee4efd754b01dfe8504dff465664b14054d54df334195d43963d142c7104dc603b2b8b1491590d2a7
|
DIST libdnet-1.17.0.tar.gz 684645 BLAKE2B b208cb41201145411b1949531cb1ab27b4edc6026b8ca703c24231fdb021f46bfe922eb1da11090c271f439339f5384c93168fad3130ed2f89b3d2eca5c7f89f SHA512 b207b2f61e3759a2b17827eabf37b0eb68cb9fa27418f99ee4efd754b01dfe8504dff465664b14054d54df334195d43963d142c7104dc603b2b8b1491590d2a7
|
||||||
|
@ -1,796 +0,0 @@
|
|||||||
From 1c324828f4c6c64c9340f169bc059152dba1f998 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Stas Grabois <finpushack@gmail.com>
|
|
||||||
Date: Sat, 5 Sep 2020 13:15:32 +0300
|
|
||||||
Subject: [PATCH] IPv6 support
|
|
||||||
|
|
||||||
---
|
|
||||||
configure | 20 ++++
|
|
||||||
configure.ac | 7 ++
|
|
||||||
include/dnet.h | 1 +
|
|
||||||
include/dnet/Makefile.am | 2 +-
|
|
||||||
include/dnet/Makefile.in | 2 +-
|
|
||||||
include/dnet/ip6.h | 3 +
|
|
||||||
include/dnet/ndisc.h | 35 +++++++
|
|
||||||
include/dnet/route.h | 3 +
|
|
||||||
src/Makefile.in | 2 +-
|
|
||||||
src/intf.c | 101 +++++++++++++-------
|
|
||||||
src/ip6.c | 56 +++++++++++
|
|
||||||
src/ndisc-linux.c | 197 +++++++++++++++++++++++++++++++++++++++
|
|
||||||
src/ndisc-none.c | 55 +++++++++++
|
|
||||||
src/route-linux.c | 95 ++++++++++++++++++-
|
|
||||||
14 files changed, 541 insertions(+), 38 deletions(-)
|
|
||||||
create mode 100644 include/dnet/ndisc.h
|
|
||||||
create mode 100644 src/ndisc-linux.c
|
|
||||||
create mode 100644 src/ndisc-none.c
|
|
||||||
|
|
||||||
--- a/configure
|
|
||||||
+++ b/configure
|
|
||||||
@@ -22025,6 +22025,26 @@
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
+if test "$ac_cv_dnet_linux_procfs" = yes ; then
|
|
||||||
+ case $LIBOBJS in
|
|
||||||
+ "ndisc-linux.$ac_objext" | \
|
|
||||||
+ *" ndisc-linux.$ac_objext" | \
|
|
||||||
+ "ndisc-linux.$ac_objext "* | \
|
|
||||||
+ *" ndisc-linux.$ac_objext "* ) ;;
|
|
||||||
+ *) LIBOBJS="$LIBOBJS ndisc-linux.$ac_objext" ;;
|
|
||||||
+esac
|
|
||||||
+
|
|
||||||
+else
|
|
||||||
+ case $LIBOBJS in
|
|
||||||
+ "ndisc-none.$ac_objext" | \
|
|
||||||
+ *" ndisc-none.$ac_objext" | \
|
|
||||||
+ "ndisc-none.$ac_objext "* | \
|
|
||||||
+ *" ndisc-none.$ac_objext "* ) ;;
|
|
||||||
+ *) LIBOBJS="$LIBOBJS ndisc-none.$ac_objext" ;;
|
|
||||||
+esac
|
|
||||||
+
|
|
||||||
+fi
|
|
||||||
+
|
|
||||||
if test "$ac_cv_header_linux_if_tun_h" = yes ; then
|
|
||||||
case $LIBOBJS in
|
|
||||||
"tun-linux.$ac_objext" | \
|
|
||||||
--- a/configure.ac
|
|
||||||
+++ b/configure.ac
|
|
||||||
@@ -303,6 +303,13 @@
|
|
||||||
AC_LIBOBJ([route-none])
|
|
||||||
fi
|
|
||||||
|
|
||||||
+dnl Check for ndisc interface.
|
|
||||||
+if test "$ac_cv_dnet_linux_procfs" = yes ; then
|
|
||||||
+ AC_LIBOBJ([ndisc-linux])
|
|
||||||
+else
|
|
||||||
+ AC_LIBOBJ([ndisc-none])
|
|
||||||
+fi
|
|
||||||
+
|
|
||||||
dnl Check for tun interface.
|
|
||||||
if test "$ac_cv_header_linux_if_tun_h" = yes ; then
|
|
||||||
AC_LIBOBJ([tun-linux])
|
|
||||||
--- a/include/dnet.h
|
|
||||||
+++ b/include/dnet.h
|
|
||||||
@@ -16,6 +16,7 @@
|
|
||||||
#include <dnet/ip6.h>
|
|
||||||
#include <dnet/addr.h>
|
|
||||||
#include <dnet/arp.h>
|
|
||||||
+#include <dnet/ndisc.h>
|
|
||||||
#include <dnet/icmp.h>
|
|
||||||
#include <dnet/tcp.h>
|
|
||||||
#include <dnet/udp.h>
|
|
||||||
--- a/include/dnet/Makefile.am
|
|
||||||
+++ b/include/dnet/Makefile.am
|
|
||||||
@@ -5,4 +5,4 @@
|
|
||||||
dnetincludedir = $(includedir)/dnet
|
|
||||||
|
|
||||||
dnetinclude_HEADERS = addr.h arp.h blob.h eth.h fw.h icmp.h intf.h ip.h \
|
|
||||||
- ip6.h os.h rand.h route.h tcp.h tun.h udp.h sctp.h
|
|
||||||
+ ip6.h os.h rand.h route.h tcp.h tun.h udp.h sctp.h ndisc.h
|
|
||||||
--- a/include/dnet/Makefile.in
|
|
||||||
+++ b/include/dnet/Makefile.in
|
|
||||||
@@ -106,7 +106,7 @@
|
|
||||||
dnetincludedir = $(includedir)/dnet
|
|
||||||
|
|
||||||
dnetinclude_HEADERS = addr.h arp.h blob.h eth.h fw.h icmp.h intf.h ip.h \
|
|
||||||
- ip6.h os.h rand.h route.h tcp.h tun.h udp.h sctp.h
|
|
||||||
+ ip6.h os.h rand.h route.h tcp.h tun.h udp.h sctp.h ndisc.h
|
|
||||||
|
|
||||||
subdir = include/dnet
|
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
|
|
||||||
--- a/include/dnet/ip6.h
|
|
||||||
+++ b/include/dnet/ip6.h
|
|
||||||
@@ -179,6 +179,9 @@
|
|
||||||
char *ip6_ntoa(const ip6_addr_t *ip6);
|
|
||||||
#define ip6_aton ip6_pton
|
|
||||||
|
|
||||||
+ssize_t ip6_add_option(void *buf, size_t len,
|
|
||||||
+ int proto, const void *optbuf, size_t optlen);
|
|
||||||
+
|
|
||||||
void ip6_checksum(void *buf, size_t len);
|
|
||||||
__END_DECLS
|
|
||||||
|
|
||||||
new file mode 100644
|
|
||||||
--- a//dev/null
|
|
||||||
+++ b/include/dnet/ndisc.h
|
|
||||||
@@ -0,0 +1,35 @@
|
|
||||||
+/*
|
|
||||||
+ * ndisc.c
|
|
||||||
+ *
|
|
||||||
+ * Kernel arp/ndisc table operations.
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#ifndef DNET_NDISC_H
|
|
||||||
+#define DNET_NDISC_H
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * NDISC cache entry
|
|
||||||
+ */
|
|
||||||
+struct ndisc_entry {
|
|
||||||
+ int intf_index;
|
|
||||||
+ struct addr ndisc_pa; /* protocol address */
|
|
||||||
+ struct addr ndisc_ha; /* hardware address */
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+typedef struct ndisc_handle ndisc_t;
|
|
||||||
+
|
|
||||||
+typedef int (*ndisc_handler)(const struct ndisc_entry *entry, void *arg);
|
|
||||||
+
|
|
||||||
+__BEGIN_DECLS
|
|
||||||
+ndisc_t *ndisc_open(void);
|
|
||||||
+int ndisc_add(ndisc_t *n, const struct ndisc_entry *entry);
|
|
||||||
+int ndisc_delete(ndisc_t *n, const struct ndisc_entry *entry);
|
|
||||||
+int ndisc_get(ndisc_t *n, struct ndisc_entry *entry);
|
|
||||||
+int ndisc_loop(ndisc_t *n, ndisc_handler callback, void *arg);
|
|
||||||
+ndisc_t *ndisc_close(ndisc_t *r);
|
|
||||||
+__END_DECLS
|
|
||||||
+
|
|
||||||
+#endif /* DNET_NDISC_H */
|
|
||||||
--- a/include/dnet/route.h
|
|
||||||
+++ b/include/dnet/route.h
|
|
||||||
@@ -26,7 +26,10 @@
|
|
||||||
__BEGIN_DECLS
|
|
||||||
route_t *route_open(void);
|
|
||||||
int route_add(route_t *r, const struct route_entry *entry);
|
|
||||||
+int route_add_dev(route_t *r, const struct route_entry *entry, const char* dev);
|
|
||||||
+int route6_add(route_t *r, const struct route_entry *entry, int intf_index);
|
|
||||||
int route_delete(route_t *r, const struct route_entry *entry);
|
|
||||||
+int route6_delete(route_t *r, const struct route_entry *entry, int intf_index);
|
|
||||||
int route_get(route_t *r, struct route_entry *entry);
|
|
||||||
int route_loop(route_t *r, route_handler callback, void *arg);
|
|
||||||
route_t *route_close(route_t *r);
|
|
||||||
--- a/src/Makefile.in
|
|
||||||
+++ b/src/Makefile.in
|
|
||||||
@@ -144,7 +144,7 @@
|
|
||||||
intf-win32.c intf.c ip-cooked.c ip-win32.c ip.c memcmp.c \
|
|
||||||
route-bsd.c route-hpux.c route-linux.c route-none.c \
|
|
||||||
route-win32.c strlcat.c strlcpy.c strsep.c tun-bsd.c \
|
|
||||||
- tun-linux.c tun-none.c tun-solaris.c
|
|
||||||
+ tun-linux.c tun-none.c tun-solaris.c ndisc-linux.c ndisc-none.c
|
|
||||||
SOURCES = $(libdnet_la_SOURCES)
|
|
||||||
|
|
||||||
all: all-am
|
|
||||||
--- a/src/intf.c
|
|
||||||
+++ b/src/intf.c
|
|
||||||
@@ -20,6 +20,9 @@
|
|
||||||
# define IP_MULTICAST
|
|
||||||
#endif
|
|
||||||
#include <net/if.h>
|
|
||||||
+#ifdef HAVE_NET_IF_DL_H
|
|
||||||
+# include <net/if_dl.h>
|
|
||||||
+#endif
|
|
||||||
#ifdef HAVE_NET_IF_VAR_H
|
|
||||||
# include <net/if_var.h>
|
|
||||||
#endif
|
|
||||||
@@ -79,6 +82,21 @@
|
|
||||||
u_char ifcbuf[4192];
|
|
||||||
};
|
|
||||||
|
|
||||||
+/* TODO: move to .h */
|
|
||||||
+union sockunion {
|
|
||||||
+#ifdef HAVE_NET_IF_DL_H
|
|
||||||
+ struct sockaddr_dl sdl;
|
|
||||||
+#endif
|
|
||||||
+ struct sockaddr_in sin;
|
|
||||||
+#ifdef HAVE_SOCKADDR_IN6
|
|
||||||
+ struct sockaddr_in6 sin6;
|
|
||||||
+#endif
|
|
||||||
+ struct sockaddr sa;
|
|
||||||
+#ifdef AF_RAW
|
|
||||||
+ struct sockaddr_raw sr;
|
|
||||||
+#endif
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
intf_flags_to_iff(u_short flags, int iff)
|
|
||||||
{
|
|
||||||
@@ -129,14 +147,10 @@
|
|
||||||
|
|
||||||
setsockopt(intf->fd, SOL_SOCKET, SO_BROADCAST,
|
|
||||||
(const char *) &one, sizeof(one));
|
|
||||||
-#ifdef SIOCGIFNETMASK_IN6
|
|
||||||
if ((intf->fd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
|
|
||||||
-# ifdef EPROTONOSUPPORT
|
|
||||||
if (errno != EPROTONOSUPPORT)
|
|
||||||
-# endif
|
|
||||||
return (intf_close(intf));
|
|
||||||
}
|
|
||||||
-#endif
|
|
||||||
}
|
|
||||||
return (intf);
|
|
||||||
}
|
|
||||||
@@ -586,34 +600,50 @@
|
|
||||||
return (_intf_get_aliases(intf, entry));
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int
|
|
||||||
+get_max_bits(const struct addr *a)
|
|
||||||
+{
|
|
||||||
+ if (a->addr_type == ADDR_TYPE_IP) {
|
|
||||||
+ return IP_ADDR_BITS;
|
|
||||||
+ } else if (a->addr_type == ADDR_TYPE_IP6) {
|
|
||||||
+ return IP6_ADDR_BITS;
|
|
||||||
+ } else {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
_match_intf_src(const struct intf_entry *entry, void *arg)
|
|
||||||
{
|
|
||||||
- int matched = 0;
|
|
||||||
- int cnt;
|
|
||||||
struct intf_entry *save = (struct intf_entry *)arg;
|
|
||||||
-
|
|
||||||
- if (entry->intf_addr.addr_type == ADDR_TYPE_IP &&
|
|
||||||
- entry->intf_addr.addr_ip == save->intf_addr.addr_ip) {
|
|
||||||
- matched = 1;
|
|
||||||
- } else {
|
|
||||||
- for (cnt = 0; !matched && cnt < (int) entry->intf_alias_num; cnt++) {
|
|
||||||
- if (entry->intf_alias_addrs[cnt].addr_type != ADDR_TYPE_IP)
|
|
||||||
- continue;
|
|
||||||
- if (entry->intf_alias_addrs[cnt].addr_ip == save->intf_addr.addr_ip)
|
|
||||||
- matched = 1;
|
|
||||||
- }
|
|
||||||
+ int len = save->intf_len < entry->intf_len ? save->intf_len : entry->intf_len;
|
|
||||||
+ int i;
|
|
||||||
+
|
|
||||||
+ struct addr a, saved_addr;
|
|
||||||
+
|
|
||||||
+ saved_addr = save->intf_addr;
|
|
||||||
+ saved_addr.addr_bits = get_max_bits(&saved_addr);
|
|
||||||
+
|
|
||||||
+ a = entry->intf_addr;
|
|
||||||
+ a.addr_bits = get_max_bits(&a);
|
|
||||||
+
|
|
||||||
+ if (addr_cmp(&a, &saved_addr) == 0) {
|
|
||||||
+ memcpy(save, entry, len);
|
|
||||||
+ return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (matched) {
|
|
||||||
- /* XXX - truncated result if entry is too small. */
|
|
||||||
- if (save->intf_len < entry->intf_len)
|
|
||||||
- memcpy(save, entry, save->intf_len);
|
|
||||||
- else
|
|
||||||
- memcpy(save, entry, entry->intf_len);
|
|
||||||
- return (1);
|
|
||||||
+ for (i = 0; i < (int)entry->intf_alias_num; i++) {
|
|
||||||
+ a = entry->intf_alias_addrs[i];
|
|
||||||
+ a.addr_bits = get_max_bits(&a);
|
|
||||||
+
|
|
||||||
+ if (addr_cmp(&a, &saved_addr) == 0) {
|
|
||||||
+ memcpy(save, entry, len);
|
|
||||||
+ save->intf_addr = entry->intf_alias_addrs[i];
|
|
||||||
+ return 1;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
- return (0);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
@@ -631,24 +661,27 @@
|
|
||||||
int
|
|
||||||
intf_get_dst(intf_t *intf, struct intf_entry *entry, struct addr *dst)
|
|
||||||
{
|
|
||||||
- struct sockaddr_in sin;
|
|
||||||
+ union sockunion sun;
|
|
||||||
socklen_t n;
|
|
||||||
|
|
||||||
- if (dst->addr_type != ADDR_TYPE_IP) {
|
|
||||||
+ int fd;
|
|
||||||
+
|
|
||||||
+ if (dst->addr_type != ADDR_TYPE_IP && dst->addr_type != ADDR_TYPE_IP6) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
- addr_ntos(dst, (struct sockaddr *)&sin);
|
|
||||||
- sin.sin_port = htons(666);
|
|
||||||
-
|
|
||||||
- if (connect(intf->fd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
|
||||||
+ addr_ntos(dst, (struct sockaddr *)&sun);
|
|
||||||
+ sun.sin.sin_port = htons(666);
|
|
||||||
+
|
|
||||||
+ fd = dst->addr_type == ADDR_TYPE_IP6 ? intf->fd6 : intf->fd;
|
|
||||||
+ if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) < 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
- n = sizeof(sin);
|
|
||||||
- if (getsockname(intf->fd, (struct sockaddr *)&sin, &n) < 0)
|
|
||||||
+ n = sizeof(sun);
|
|
||||||
+ if (getsockname(fd, (struct sockaddr *)&sun, &n) < 0)
|
|
||||||
return (-1);
|
|
||||||
|
|
||||||
- addr_ston((struct sockaddr *)&sin, &entry->intf_addr);
|
|
||||||
+ addr_ston((struct sockaddr *)&sun, &entry->intf_addr);
|
|
||||||
|
|
||||||
if (intf_loop(intf, _match_intf_src, entry) != 1)
|
|
||||||
return (-1);
|
|
||||||
--- a/src/ip6.c
|
|
||||||
+++ b/src/ip6.c
|
|
||||||
@@ -9,6 +9,8 @@
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "dnet.h"
|
|
||||||
+#include <string.h>
|
|
||||||
+#include <errno.h>
|
|
||||||
|
|
||||||
#define IP6_IS_EXT(n) \
|
|
||||||
((n) == IP_PROTO_HOPOPTS || (n) == IP_PROTO_DSTOPTS || \
|
|
||||||
@@ -70,3 +72,57 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ssize_t
|
|
||||||
+ip6_add_option(void *buf, size_t len, int proto,
|
|
||||||
+ const void *optbuf, size_t optlen)
|
|
||||||
+{
|
|
||||||
+ struct ip6_hdr *ip6;
|
|
||||||
+ struct tcp_hdr *tcp = NULL;
|
|
||||||
+ u_char *p;
|
|
||||||
+ int hl, datalen, padlen;
|
|
||||||
+
|
|
||||||
+ if (proto != IP_PROTO_TCP) {
|
|
||||||
+ errno = EINVAL;
|
|
||||||
+ return (-1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ip6 = (struct ip6_hdr *)buf;
|
|
||||||
+ p = (u_char *)buf + IP6_HDR_LEN;
|
|
||||||
+
|
|
||||||
+ tcp = (struct tcp_hdr *)p;
|
|
||||||
+ hl = tcp->th_off << 2;
|
|
||||||
+ p = (u_char *)tcp + hl;
|
|
||||||
+
|
|
||||||
+ datalen = ntohs(ip6->ip6_plen) + IP6_HDR_LEN - (p - (u_char *)buf);
|
|
||||||
+
|
|
||||||
+ /* Compute padding to next word boundary. */
|
|
||||||
+ if ((padlen = 4 - (optlen % 4)) == 4)
|
|
||||||
+ padlen = 0;
|
|
||||||
+
|
|
||||||
+ /* XXX - IP_HDR_LEN_MAX == TCP_HDR_LEN_MAX */
|
|
||||||
+ if (hl + optlen + padlen > IP_HDR_LEN_MAX ||
|
|
||||||
+ ntohs(ip6->ip6_plen) + IP6_HDR_LEN + optlen + padlen > len) {
|
|
||||||
+ errno = EINVAL;
|
|
||||||
+ return (-1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /* Shift any existing data. */
|
|
||||||
+ if (datalen) {
|
|
||||||
+ memmove(p + optlen + padlen, p, datalen);
|
|
||||||
+ }
|
|
||||||
+ /* XXX - IP_OPT_NOP == TCP_OPT_NOP */
|
|
||||||
+ if (padlen) {
|
|
||||||
+ memset(p, IP_OPT_NOP, padlen);
|
|
||||||
+ p += padlen;
|
|
||||||
+ }
|
|
||||||
+ memmove(p, optbuf, optlen);
|
|
||||||
+ p += optlen;
|
|
||||||
+ optlen += padlen;
|
|
||||||
+
|
|
||||||
+ tcp->th_off = (p - (u_char *)tcp) >> 2;
|
|
||||||
+
|
|
||||||
+ ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) + optlen);
|
|
||||||
+
|
|
||||||
+ return (optlen);
|
|
||||||
+}
|
|
||||||
new file mode 100644
|
|
||||||
--- a//dev/null
|
|
||||||
+++ b/src/ndisc-linux.c
|
|
||||||
@@ -0,0 +1,197 @@
|
|
||||||
+/*
|
|
||||||
+ * ndisc-linux.c
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "config.h"
|
|
||||||
+
|
|
||||||
+#include <sys/types.h>
|
|
||||||
+#include <sys/ioctl.h>
|
|
||||||
+#include <sys/socket.h>
|
|
||||||
+#include <sys/uio.h>
|
|
||||||
+
|
|
||||||
+#include <asm/types.h>
|
|
||||||
+#include <netinet/in.h>
|
|
||||||
+#include <linux/netlink.h>
|
|
||||||
+#include <linux/rtnetlink.h>
|
|
||||||
+
|
|
||||||
+#include <net/route.h>
|
|
||||||
+
|
|
||||||
+#include <ctype.h>
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <stdio.h>
|
|
||||||
+#include <stdlib.h>
|
|
||||||
+#include <string.h>
|
|
||||||
+#include <unistd.h>
|
|
||||||
+
|
|
||||||
+#include "dnet.h"
|
|
||||||
+
|
|
||||||
+struct ndisc_handle
|
|
||||||
+{
|
|
||||||
+ int nlfd;
|
|
||||||
+ int seq;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+ndisc_t *
|
|
||||||
+ndisc_open(void)
|
|
||||||
+{
|
|
||||||
+ struct sockaddr_nl snl;
|
|
||||||
+ ndisc_t *n;
|
|
||||||
+
|
|
||||||
+ if ((n = calloc(1, sizeof(*n))) != NULL) {
|
|
||||||
+ n->nlfd = -1;
|
|
||||||
+
|
|
||||||
+ if ((n->nlfd = socket(AF_NETLINK, SOCK_RAW,
|
|
||||||
+ NETLINK_ROUTE)) < 0)
|
|
||||||
+ return (ndisc_close(n));
|
|
||||||
+
|
|
||||||
+ memset(&snl, 0, sizeof(snl));
|
|
||||||
+ snl.nl_family = AF_NETLINK;
|
|
||||||
+
|
|
||||||
+ if (bind(n->nlfd, (struct sockaddr *)&snl, sizeof(snl)) < 0)
|
|
||||||
+ return (ndisc_close(n));
|
|
||||||
+ }
|
|
||||||
+ return (n);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static int
|
|
||||||
+netlink_addattr(struct nlmsghdr *n, int type, const void *data, int data_len)
|
|
||||||
+{
|
|
||||||
+ int len = RTA_LENGTH(data_len);
|
|
||||||
+ struct rtattr *rta;
|
|
||||||
+
|
|
||||||
+ rta = (struct rtattr *)((uint8_t*)n + NLMSG_ALIGN(n->nlmsg_len));
|
|
||||||
+ rta->rta_type = type;
|
|
||||||
+ rta->rta_len = len;
|
|
||||||
+ memcpy(RTA_DATA(rta), data, data_len);
|
|
||||||
+ n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len);
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_modify(ndisc_t *n, const struct ndisc_entry *entry, int type, int flags)
|
|
||||||
+{
|
|
||||||
+ struct nlmsghdr *nmsg;
|
|
||||||
+ struct ndmsg *ndm;
|
|
||||||
+ struct rtattr *rta;
|
|
||||||
+ struct sockaddr_nl snl;
|
|
||||||
+ struct iovec iov;
|
|
||||||
+ struct msghdr msg;
|
|
||||||
+ u_char buf[512];
|
|
||||||
+ int i, af, alen;
|
|
||||||
+
|
|
||||||
+ switch (entry->ndisc_pa.addr_type) {
|
|
||||||
+ case ADDR_TYPE_IP:
|
|
||||||
+ af = AF_INET;
|
|
||||||
+ alen = IP_ADDR_LEN;
|
|
||||||
+ break;
|
|
||||||
+ case ADDR_TYPE_IP6:
|
|
||||||
+ af = AF_INET6;
|
|
||||||
+ alen = IP6_ADDR_LEN;
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ errno = EINVAL;
|
|
||||||
+ return (-1);
|
|
||||||
+ }
|
|
||||||
+ memset(buf, 0, sizeof(buf));
|
|
||||||
+
|
|
||||||
+ nmsg = (struct nlmsghdr *)buf;
|
|
||||||
+ nmsg->nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
|
|
||||||
+ nmsg->nlmsg_flags = NLM_F_REQUEST | flags;
|
|
||||||
+ nmsg->nlmsg_type = type;
|
|
||||||
+ nmsg->nlmsg_seq = ++n->seq;
|
|
||||||
+
|
|
||||||
+ nmsg->nlmsg_flags |= NLM_F_ACK;
|
|
||||||
+
|
|
||||||
+ ndm = (struct ndmsg *)(nmsg + 1);
|
|
||||||
+ ndm->ndm_family = af;
|
|
||||||
+ ndm->ndm_state = NUD_PERMANENT;
|
|
||||||
+ ndm->ndm_ifindex = entry->intf_index;
|
|
||||||
+
|
|
||||||
+ netlink_addattr(nmsg, NDA_DST, &entry->ndisc_pa.addr_data8[0],
|
|
||||||
+ alen);
|
|
||||||
+
|
|
||||||
+ if (type == RTM_NEWNEIGH) {
|
|
||||||
+ netlink_addattr(nmsg, NDA_LLADDR,
|
|
||||||
+ &entry->ndisc_ha.addr_data8[0], ETH_ADDR_LEN);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ memset(&snl, 0, sizeof(snl));
|
|
||||||
+ snl.nl_family = AF_NETLINK;
|
|
||||||
+
|
|
||||||
+ iov.iov_base = nmsg;
|
|
||||||
+ iov.iov_len = nmsg->nlmsg_len;
|
|
||||||
+
|
|
||||||
+ memset(&msg, 0, sizeof(msg));
|
|
||||||
+ msg.msg_name = &snl;
|
|
||||||
+ msg.msg_namelen = sizeof(snl);
|
|
||||||
+ msg.msg_iov = &iov;
|
|
||||||
+ msg.msg_iovlen = 1;
|
|
||||||
+
|
|
||||||
+ if (sendmsg(n->nlfd, &msg, 0) < 0)
|
|
||||||
+ return (-1);
|
|
||||||
+
|
|
||||||
+ iov.iov_base = buf;
|
|
||||||
+ iov.iov_len = sizeof(buf);
|
|
||||||
+
|
|
||||||
+ if ((i = recvmsg(n->nlfd, &msg, 0)) <= 0)
|
|
||||||
+ return (-1);
|
|
||||||
+
|
|
||||||
+ if (nmsg->nlmsg_len < (int)sizeof(*nmsg) || nmsg->nlmsg_len > i ||
|
|
||||||
+ nmsg->nlmsg_seq != n->seq) {
|
|
||||||
+ errno = EINVAL;
|
|
||||||
+ return (-1);
|
|
||||||
+ }
|
|
||||||
+ if (nmsg->nlmsg_type == NLMSG_ERROR) {
|
|
||||||
+ struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(nmsg);
|
|
||||||
+ errno = -err->error;
|
|
||||||
+ if (errno == 0) {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return (-1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_add(ndisc_t *n, const struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ return ndisc_modify(n, entry, RTM_NEWNEIGH, NLM_F_CREATE | NLM_F_EXCL);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_delete(ndisc_t *n, const struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ return ndisc_modify(n, entry, RTM_DELNEIGH, 0);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_get(ndisc_t *n, struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ /* TBD */
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+nsidc_loop(ndisc_t *n, ndisc_handler callback, void *arg)
|
|
||||||
+{
|
|
||||||
+ /* TBD */
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ndisc_t *
|
|
||||||
+ndisc_close(ndisc_t *n)
|
|
||||||
+{
|
|
||||||
+ if (n != NULL) {
|
|
||||||
+ if (n->nlfd >= 0)
|
|
||||||
+ close(n->nlfd);
|
|
||||||
+ free(n);
|
|
||||||
+ }
|
|
||||||
+ return (NULL);
|
|
||||||
+}
|
|
||||||
new file mode 100644
|
|
||||||
--- a//dev/null
|
|
||||||
+++ b/src/ndisc-none.c
|
|
||||||
@@ -0,0 +1,55 @@
|
|
||||||
+/*
|
|
||||||
+ * ndisc-linux.c
|
|
||||||
+ *
|
|
||||||
+ * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+#include "config.h"
|
|
||||||
+
|
|
||||||
+#include <errno.h>
|
|
||||||
+#include <stdio.h>
|
|
||||||
+#include <stdlib.h>
|
|
||||||
+
|
|
||||||
+#include "dnet.h"
|
|
||||||
+
|
|
||||||
+ndisc_t *
|
|
||||||
+ndisc_open(void)
|
|
||||||
+{
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (NULL);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_add(ndisc_t *n, const struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_delete(ndisc_t *n, const struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+ndisc_get(ndisc_t *n, struct ndisc_entry *entry)
|
|
||||||
+{
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+nsidc_loop(ndisc_t *n, ndisc_handler callback, void *arg)
|
|
||||||
+{
|
|
||||||
+ errno = ENOSYS;
|
|
||||||
+ return (-1);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+ndisc_t *
|
|
||||||
+ndisc_close(ndisc_t *n)
|
|
||||||
+{
|
|
||||||
+ return (NULL);
|
|
||||||
+}
|
|
||||||
--- a/src/route-linux.c
|
|
||||||
+++ b/src/route-linux.c
|
|
||||||
@@ -39,6 +39,7 @@
|
|
||||||
|
|
||||||
struct route_handle {
|
|
||||||
int fd;
|
|
||||||
+ int fd6;
|
|
||||||
int nlfd;
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -49,10 +50,13 @@
|
|
||||||
route_t *r;
|
|
||||||
|
|
||||||
if ((r = calloc(1, sizeof(*r))) != NULL) {
|
|
||||||
- r->fd = r->nlfd = -1;
|
|
||||||
+ r->fd = r->fd6 = r->nlfd = -1;
|
|
||||||
|
|
||||||
if ((r->fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
|
||||||
return (route_close(r));
|
|
||||||
+
|
|
||||||
+ if ((r->fd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0)
|
|
||||||
+ return (route_close(r));
|
|
||||||
|
|
||||||
if ((r->nlfd = socket(AF_NETLINK, SOCK_RAW,
|
|
||||||
NETLINK_ROUTE)) < 0)
|
|
||||||
@@ -90,6 +94,67 @@
|
|
||||||
return (ioctl(r->fd, SIOCADDRT, &rt));
|
|
||||||
}
|
|
||||||
|
|
||||||
+int
|
|
||||||
+route_add_dev(route_t *r, const struct route_entry *entry, const char* dev)
|
|
||||||
+{
|
|
||||||
+ struct rtentry rt;
|
|
||||||
+ struct addr dst;
|
|
||||||
+
|
|
||||||
+ memset(&rt, 0, sizeof(rt));
|
|
||||||
+ rt.rt_flags = RTF_UP;
|
|
||||||
+ rt.rt_dev = (char*)dev;
|
|
||||||
+
|
|
||||||
+ if (ADDR_ISHOST(&entry->route_dst)) {
|
|
||||||
+ rt.rt_flags |= RTF_HOST;
|
|
||||||
+ memcpy(&dst, &entry->route_dst, sizeof(dst));
|
|
||||||
+ } else
|
|
||||||
+ addr_net(&entry->route_dst, &dst);
|
|
||||||
+
|
|
||||||
+ if (entry->route_gw.addr_ip != 0) {
|
|
||||||
+ rt.rt_flags |= RTF_GATEWAY;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (addr_ntos(&dst, &rt.rt_dst) < 0 ||
|
|
||||||
+ addr_ntos(&entry->route_gw, &rt.rt_gateway) < 0 ||
|
|
||||||
+ addr_btos(entry->route_dst.addr_bits, &rt.rt_genmask) < 0)
|
|
||||||
+ return (-1);
|
|
||||||
+
|
|
||||||
+ int ret = (ioctl(r->fd, SIOCADDRT, &rt));
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+route6_add(route_t *r, const struct route_entry *entry, int intf_index)
|
|
||||||
+{
|
|
||||||
+ struct in6_rtmsg rt;
|
|
||||||
+ struct addr dst;
|
|
||||||
+
|
|
||||||
+ memset(&rt, 0, sizeof(rt));
|
|
||||||
+ rt.rtmsg_flags = RTF_UP;
|
|
||||||
+
|
|
||||||
+ if (ADDR_ISHOST(&entry->route_dst)) {
|
|
||||||
+ rt.rtmsg_flags |= RTF_HOST;
|
|
||||||
+ memcpy(&dst, &entry->route_dst, sizeof(dst));
|
|
||||||
+ } else {
|
|
||||||
+ addr_net(&entry->route_dst, &dst);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ rt.rtmsg_dst_len = entry->route_dst.addr_bits;
|
|
||||||
+ rt.rtmsg_ifindex = intf_index;
|
|
||||||
+ rt.rtmsg_metric = 1;
|
|
||||||
+
|
|
||||||
+ memcpy(&rt.rtmsg_dst, &dst.addr_ip6, sizeof(rt.rtmsg_dst));
|
|
||||||
+
|
|
||||||
+ if (!IN6_IS_ADDR_UNSPECIFIED(&entry->route_gw.addr_ip6)) {
|
|
||||||
+ rt.rtmsg_flags |= RTF_GATEWAY;
|
|
||||||
+ memcpy(&rt.rtmsg_gateway, &entry->route_gw.addr_ip6,
|
|
||||||
+ sizeof(rt.rtmsg_gateway));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ int ret = (ioctl(r->fd6, SIOCADDRT, &rt));
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int
|
|
||||||
route_delete(route_t *r, const struct route_entry *entry)
|
|
||||||
{
|
|
||||||
@@ -112,6 +177,32 @@
|
|
||||||
return (ioctl(r->fd, SIOCDELRT, &rt));
|
|
||||||
}
|
|
||||||
|
|
||||||
+int
|
|
||||||
+route6_delete(route_t *r, const struct route_entry *entry, int intf_index)
|
|
||||||
+{
|
|
||||||
+ struct in6_rtmsg rt;
|
|
||||||
+ struct addr dst;
|
|
||||||
+
|
|
||||||
+ memset(&rt, 0, sizeof(rt));
|
|
||||||
+ rt.rtmsg_flags = RTF_UP;
|
|
||||||
+
|
|
||||||
+ if (ADDR_ISHOST(&entry->route_dst)) {
|
|
||||||
+ rt.rtmsg_flags |= RTF_HOST;
|
|
||||||
+ memcpy(&dst, &entry->route_dst, sizeof(dst));
|
|
||||||
+ } else
|
|
||||||
+ addr_net(&entry->route_dst, &dst);
|
|
||||||
+
|
|
||||||
+ rt.rtmsg_dst_len = entry->route_dst.addr_bits;
|
|
||||||
+ rt.rtmsg_ifindex = intf_index;
|
|
||||||
+ rt.rtmsg_metric = 1;
|
|
||||||
+
|
|
||||||
+ memcpy(&rt.rtmsg_dst, &dst, sizeof(rt.rtmsg_dst));
|
|
||||||
+ memcpy(&rt.rtmsg_gateway, &entry->route_gw, sizeof(rt.rtmsg_gateway));
|
|
||||||
+
|
|
||||||
+ int ret = (ioctl(r->fd6, SIOCDELRT, &rt));
|
|
||||||
+ return ret;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
int
|
|
||||||
route_get(route_t *r, struct route_entry *entry)
|
|
||||||
{
|
|
||||||
@@ -278,6 +369,8 @@
|
|
||||||
if (r != NULL) {
|
|
||||||
if (r->fd >= 0)
|
|
||||||
close(r->fd);
|
|
||||||
+ if (r->fd6 >= 0)
|
|
||||||
+ close(r->fd6);
|
|
||||||
if (r->nlfd >= 0)
|
|
||||||
close(r->nlfd);
|
|
||||||
free(r);
|
|
@ -1,10 +0,0 @@
|
|||||||
--- a/python/dnet.c
|
|
||||||
+++ b/python/dnet.c
|
|
||||||
@@ -22,6 +22,7 @@
|
|
||||||
#endif
|
|
||||||
__PYX_EXTERN_C double pow(double, double);
|
|
||||||
#include "dnet.h"
|
|
||||||
+#include "config.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {const char *s; const void **p;} __Pyx_CApiTabEntry; /*proto*/
|
|
@ -1,84 +0,0 @@
|
|||||||
# Copyright 1999-2023 Gentoo Authors
|
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
|
||||||
|
|
||||||
EAPI=7
|
|
||||||
|
|
||||||
AT_M4DIR="config"
|
|
||||||
PYTHON_COMPAT=( python3_{9..10} )
|
|
||||||
DISTUTILS_OPTIONAL=1
|
|
||||||
inherit autotools distutils-r1
|
|
||||||
|
|
||||||
DESCRIPTION="simplified, portable interface to several low-level networking routines"
|
|
||||||
HOMEPAGE="https://github.com/ofalk/libdnet"
|
|
||||||
SRC_URI="https://github.com/ofalk/${PN}/archive/${P}.tar.gz"
|
|
||||||
S="${WORKDIR}/${PN}-${P}"
|
|
||||||
|
|
||||||
LICENSE="LGPL-2"
|
|
||||||
SLOT="0"
|
|
||||||
KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv sparc x86"
|
|
||||||
IUSE="python test"
|
|
||||||
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
|
|
||||||
RESTRICT="!test? ( test )"
|
|
||||||
|
|
||||||
DEPEND="python? ( ${PYTHON_DEPS} )"
|
|
||||||
RDEPEND="${DEPEND}"
|
|
||||||
BDEPEND="
|
|
||||||
python? (
|
|
||||||
dev-python/cython[${PYTHON_USEDEP}]
|
|
||||||
)
|
|
||||||
"
|
|
||||||
|
|
||||||
DOCS=( README.md THANKS )
|
|
||||||
|
|
||||||
PATCHES=(
|
|
||||||
"${FILESDIR}/${PN}-1.14-ndisc.patch"
|
|
||||||
"${FILESDIR}/${PN}-1.14-strlcpy.patch"
|
|
||||||
)
|
|
||||||
|
|
||||||
src_prepare() {
|
|
||||||
default
|
|
||||||
|
|
||||||
sed -i \
|
|
||||||
-e 's/libcheck.a/libcheck.so/g' \
|
|
||||||
-e 's|AM_CONFIG_HEADER|AC_CONFIG_HEADERS|g' \
|
|
||||||
configure.ac || die
|
|
||||||
sed -i \
|
|
||||||
-e 's|-L$libdir ||g' \
|
|
||||||
dnet-config.in || die
|
|
||||||
sed -i \
|
|
||||||
-e '/^SUBDIRS/s|python||g' \
|
|
||||||
Makefile.am || die
|
|
||||||
|
|
||||||
eautoreconf
|
|
||||||
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
distutils-r1_src_prepare
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
src_configure() {
|
|
||||||
econf \
|
|
||||||
--disable-static \
|
|
||||||
$(use_with python)
|
|
||||||
}
|
|
||||||
|
|
||||||
src_compile() {
|
|
||||||
default
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
distutils-r1_src_compile
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
src_install() {
|
|
||||||
default
|
|
||||||
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
unset DOCS
|
|
||||||
distutils-r1_src_install
|
|
||||||
fi
|
|
||||||
|
|
||||||
find "${ED}" -name '*.la' -delete || die
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
# Copyright 1999-2023 Gentoo Authors
|
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
|
||||||
|
|
||||||
EAPI=8
|
|
||||||
|
|
||||||
PYTHON_COMPAT=( python3_{9..10} )
|
|
||||||
DISTUTILS_OPTIONAL=1
|
|
||||||
inherit autotools distutils-r1
|
|
||||||
|
|
||||||
DESCRIPTION="Simplified, portable interface to several low-level networking routines"
|
|
||||||
HOMEPAGE="https://github.com/ofalk/libdnet"
|
|
||||||
SRC_URI="https://github.com/ofalk/${PN}/archive/${P}.tar.gz"
|
|
||||||
S="${WORKDIR}/${PN}-${P}"
|
|
||||||
|
|
||||||
LICENSE="LGPL-2"
|
|
||||||
SLOT="0"
|
|
||||||
KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv sparc x86"
|
|
||||||
IUSE="python test"
|
|
||||||
RESTRICT="!test? ( test )"
|
|
||||||
|
|
||||||
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
|
|
||||||
|
|
||||||
DEPEND="dev-libs/libbsd
|
|
||||||
python? ( ${PYTHON_DEPS} )"
|
|
||||||
RDEPEND="${DEPEND}"
|
|
||||||
BDEPEND="python? ( dev-python/cython[${PYTHON_USEDEP}] )
|
|
||||||
test? ( dev-libs/check )"
|
|
||||||
|
|
||||||
DOCS=( README.md THANKS )
|
|
||||||
|
|
||||||
src_prepare() {
|
|
||||||
default
|
|
||||||
|
|
||||||
sed -i \
|
|
||||||
-e 's/libcheck.a/libcheck.so/g' \
|
|
||||||
configure.ac || die
|
|
||||||
sed -i \
|
|
||||||
-e 's|-L$libdir ||g' \
|
|
||||||
dnet-config.in || die
|
|
||||||
sed -i \
|
|
||||||
-e '/^SUBDIRS/s|python||g' \
|
|
||||||
Makefile.am || die
|
|
||||||
|
|
||||||
# Stale e.g. pkg-config macros w/ bashisms
|
|
||||||
rm aclocal.m4 {config,m4}/libtool.m4 || die
|
|
||||||
|
|
||||||
AT_M4DIR="config" eautoreconf
|
|
||||||
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
distutils-r1_src_prepare
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
src_configure() {
|
|
||||||
econf \
|
|
||||||
$(use_with python) \
|
|
||||||
$(use_enable test check)
|
|
||||||
}
|
|
||||||
|
|
||||||
src_compile() {
|
|
||||||
default
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
distutils-r1_src_compile
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
src_install() {
|
|
||||||
default
|
|
||||||
|
|
||||||
if use python; then
|
|
||||||
cd python || die
|
|
||||||
unset DOCS
|
|
||||||
distutils-r1_src_install
|
|
||||||
fi
|
|
||||||
|
|
||||||
find "${ED}" -name '*.la' -delete || die
|
|
||||||
}
|
|
@ -1,9 +1,9 @@
|
|||||||
# Copyright 1999-2023 Gentoo Authors
|
# Copyright 1999-2024 Gentoo Authors
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
EAPI=8
|
EAPI=8
|
||||||
|
|
||||||
PYTHON_COMPAT=( python3_{9..11} )
|
PYTHON_COMPAT=( python3_{10..11} )
|
||||||
DISTUTILS_OPTIONAL=1
|
DISTUTILS_OPTIONAL=1
|
||||||
inherit autotools distutils-r1
|
inherit autotools distutils-r1
|
||||||
|
|
||||||
@ -15,16 +15,14 @@ S="${WORKDIR}/${PN}-${P}"
|
|||||||
LICENSE="LGPL-2"
|
LICENSE="LGPL-2"
|
||||||
SLOT="0"
|
SLOT="0"
|
||||||
KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv sparc x86"
|
KEYWORDS="~alpha amd64 arm ~arm64 ~hppa ~ia64 ~mips ppc ppc64 ~riscv sparc x86"
|
||||||
IUSE="python test"
|
IUSE="python"
|
||||||
RESTRICT="!test? ( test )"
|
|
||||||
|
|
||||||
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
|
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
|
||||||
|
|
||||||
DEPEND="dev-libs/libbsd
|
DEPEND="dev-libs/libbsd
|
||||||
python? ( ${PYTHON_DEPS} )"
|
python? ( ${PYTHON_DEPS} )"
|
||||||
RDEPEND="${DEPEND}"
|
RDEPEND="${DEPEND}"
|
||||||
BDEPEND="python? ( dev-python/cython[${PYTHON_USEDEP}] )
|
BDEPEND="python? ( dev-python/cython[${PYTHON_USEDEP}] )"
|
||||||
test? ( dev-libs/check )"
|
|
||||||
|
|
||||||
DOCS=( README.md THANKS )
|
DOCS=( README.md THANKS )
|
||||||
|
|
||||||
@ -55,7 +53,7 @@ src_prepare() {
|
|||||||
src_configure() {
|
src_configure() {
|
||||||
econf \
|
econf \
|
||||||
$(use_with python) \
|
$(use_with python) \
|
||||||
$(use_enable test check)
|
--without-check
|
||||||
}
|
}
|
||||||
|
|
||||||
src_compile() {
|
src_compile() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user