diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2020-09-30 17:27:54 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2020-09-30 17:27:54 +0100 |
commit | f70a1bfc721336d4fc7dfb711c2f518a6b18cf16 (patch) | |
tree | e907cb121b30e3c1df1710719c0ddf4029597a47 /dev-libs/libdnet | |
parent | db063b515939ab15261136b24e4bc44386335c0c (diff) |
gentoo resync : 30.09.2020
Diffstat (limited to 'dev-libs/libdnet')
-rw-r--r-- | dev-libs/libdnet/Manifest | 7 | ||||
-rw-r--r-- | dev-libs/libdnet/files/libdnet-1.14-ndisc.patch | 796 | ||||
-rw-r--r-- | dev-libs/libdnet/files/libdnet-1.14-strlcpy.patch | 10 | ||||
-rw-r--r-- | dev-libs/libdnet/libdnet-1.14-r1.ebuild | 78 | ||||
-rw-r--r-- | dev-libs/libdnet/libdnet-1.14.ebuild | 5 | ||||
-rw-r--r-- | dev-libs/libdnet/libdnet-9999.ebuild | 4 |
6 files changed, 897 insertions, 3 deletions
diff --git a/dev-libs/libdnet/Manifest b/dev-libs/libdnet/Manifest index 4884b0a3d975..da4aeb382362 100644 --- a/dev-libs/libdnet/Manifest +++ b/dev-libs/libdnet/Manifest @@ -1,9 +1,12 @@ +AUX libdnet-1.14-ndisc.patch 18209 BLAKE2B a295d81c247f884293efdf8d4740e2a4fd80c9febd8a5eed02db725151f886ad32e3a52ee7a62cabd31c0a218b23a9acf7d9c52b48c0d9aa597524886e38cfc4 SHA512 6da36c0f421b58819410df9507a973199fcafebb6447765c5de97fde6bdb16607f32dcb8b86da4216656c4d4ad4d21e153f15906a400249a7d44766d0539ecfb +AUX libdnet-1.14-strlcpy.patch 233 BLAKE2B fb35015b16a206e55cbc1dc39c032dd43f74cc17e173252227707bef616df827c0ce0d7a7e4349ebc442a9198ee8953c45739b03b306ddc2af2753e31a15ebbd SHA512 8cabaf75382537755d79b588b629978d47a4b8e7c4bda22d7098bba09b5b1fec8dabeacb1727a821df2d29040a3e420803ebfdc66df5824630fae8da1059d164 DIST libdnet-1.12.ipv6-1.patch.gz 5124 BLAKE2B 674866a441a5907df97942772b1e4b95aee004ddb110204df0580cec6b6bb3ba4074831d83e675e1914f1a29281b02227e95016db6ce6a0e8b99417d1aa6aaab SHA512 fa2380e41548ecdd978722930ecf90dffabd15cf06cbae0e113285072fe98a066f1e686b6d79e2d8b9f8adcf29783f313d61933b9e1e74e71da8dc7d741f815a DIST libdnet-1.12.tar.gz 959945 BLAKE2B a19f8c83425861d02f832330cf0eb5bc317eec157737e0eacd48a7827d423c626b24ce833f66429c9f2a0018502cae5426d5cfc1019aed307d63e4fa6b3845c8 SHA512 a2410a98b76d4bccecf7bcb82ff0b6e9fb809b389f7fea938cc42d94e18622cc5f353d2de737121a1990d9e16e9db8cc2f82677c94f78cd03c9227e815eab9e0 DIST libdnet-1.12.tgz 970125 BLAKE2B 74be00b6fe1c7848010a7044628a6ad8f4b2f2c4f9676066c15e02c7a8b613e26a5e7743df524869fee2eb7d93438bf346f772b8df199b8ec337279dd50d5d77 SHA512 b763d2caa77b8d16b531142a5bce3b862ed20198406a00e1fe7f3b45ce308b97d638b0c7f03bd8593fdd206cc1645952839bc340b77537298a3df88599835bf3 DIST libdnet-1.14.tar.gz 520833 BLAKE2B 97e241fc374fc9489e70d440db5e19199f4e653650af85e24af56bbbc0167db1c451349c43fcb630a26c61f8ca15c58f5c879e0d82654e275189ca3e140bb22a SHA512 ce8d95228f5175e4d9a8ff71bb99eb1ccc3ccd599a85dd07adbfd9842fc54066235d362c8060828fb3ba8129d0e1e8e071e93d60d69c6d03be310c80e61cea93 EBUILD libdnet-1.12-r1.ebuild 1552 BLAKE2B 76c2f623188831fc9cbd7273ce90bb58eb2e35b19f9602a9ada16b533db237401f21bf2fc569a5a785f7d2e13057a78811a3a03d86ff1268237d3f9cc01cc38b SHA512 b8648b062ef377e0431210776add07d00dfd9647b801ad3b4a4d0a32cbdfa3a065706a66be71d137445887ba97d3588790b15b027a96e22596924bf7f01a8de5 EBUILD libdnet-1.12.ebuild 1520 BLAKE2B ce48aaf6543ede9d1db165aee357c37447b1a75e48b23439ad2fb8b848edd003b6a1457b1407cbe6962759fc2ab20a1bf3f3ed9b70fa711b1ad28dad851f91b7 SHA512 7c7392c123fa430c97015eaf6d926a525791f0bcc51bda4c95cadc17267f52f99fd22d747b42060b9307324a601ec1d83b91399233991e87597f5bbc59038afd -EBUILD libdnet-1.14.ebuild 1389 BLAKE2B 115af50d6c17df1bda7923c5468772f0f50ac9f5469ee9323382efd637d1da4d0507b5c8ef6d3621caf7fae00c8c5cbaadf0f35d48062aa3d0c8b88542a6ef12 SHA512 730d4fc6bb732a7f2bb8e9e6039f64ce3f3e900d7dd34580fdd8c752338cad0296f950b771406e063e9ffe4a002e152a5e92cdace2547e97527a0bb86da4e128 -EBUILD libdnet-9999.ebuild 1304 BLAKE2B 42da11f210ae69feadac13950baa8194a817784c0c0e8bb31befc07f20bd842d81348b623137a4b8ca6b857cd45246e23d75db6a807e5710f70574cd4c61484a SHA512 9e432bb2bcee9baef6fbe8428da44455fb02e8e4b14fe3575194f2e1c1f9e5a38f8c57280350c1fc570f03753c5fe121a2e37580812d6e92af1a2e98cbf3513f +EBUILD libdnet-1.14-r1.ebuild 1483 BLAKE2B 8958077ab8b4c04f6b56cbbb19af258d838e0e973728187b37e827b0e96e36a2a131aac66be1524ac4774d8e384067d1a643f9f8874dbccc5f21c201e9927409 SHA512 d44804937d5fdde9198045f6bd2af607819ab9e078270b90955a589c9d4becfa92e497a911e8cccd6f71bfa038a7aa42bdc2eb65d8fe29ade6e84f1d599fe74e +EBUILD libdnet-1.14.ebuild 1438 BLAKE2B 26fea0961643486ddba314b80cc9844c262edcfecdfd17d5b31c7b6781b2322d032572a28282811064026874ee6a41cbe14d14397b11c6737ba099a48cc7b438 SHA512 cfebda19c0867bc45b3050e58f7ff113dfc88a6e4a360b82f03497f355b189b559bd62b2fce98c3d116d9b097d24585dd2fdfe03f85991f7866689d57690cab1 +EBUILD libdnet-9999.ebuild 1376 BLAKE2B 9b8e58f34258ff145a513a3758b458e69cf6dce876b9488648c81c75a5ea074044bdec2494b86f40ca1ee8f4738e4a294530e45d61f56b9b3b1037c118287f2f SHA512 8b59231e80d511ff5bb59bdb750daf2713379358889805625a81e06b3481b031586fa2cb4aa7d959a6e75960edb7a4628c9fc833f1d4814b643cc91d62a5637d MISC metadata.xml 412 BLAKE2B 31f4ab6e16ecdf55347cc83250bc3ce8afc9305f27b1925fe231cc66945725fd33d8239265e6219caf822ef23501014a85219d2a222f5085881b7ca06dffdafc SHA512 ba32dc96871e434caec3a21dea3c5f005c4aacf122312dcd44a228ae92c02c90c02339761ea091fbcad618b02cd5e4d672914c5b6263ef386d49242e19e1febe diff --git a/dev-libs/libdnet/files/libdnet-1.14-ndisc.patch b/dev-libs/libdnet/files/libdnet-1.14-ndisc.patch new file mode 100644 index 000000000000..439ffb7cb927 --- /dev/null +++ b/dev-libs/libdnet/files/libdnet-1.14-ndisc.patch @@ -0,0 +1,796 @@ +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); diff --git a/dev-libs/libdnet/files/libdnet-1.14-strlcpy.patch b/dev-libs/libdnet/files/libdnet-1.14-strlcpy.patch new file mode 100644 index 000000000000..abc3a6b0f2d3 --- /dev/null +++ b/dev-libs/libdnet/files/libdnet-1.14-strlcpy.patch @@ -0,0 +1,10 @@ +--- 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*/ diff --git a/dev-libs/libdnet/libdnet-1.14-r1.ebuild b/dev-libs/libdnet/libdnet-1.14-r1.ebuild new file mode 100644 index 000000000000..a709c3f636c7 --- /dev/null +++ b/dev-libs/libdnet/libdnet-1.14-r1.ebuild @@ -0,0 +1,78 @@ +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +AT_M4DIR="config" +PYTHON_COMPAT=( python3_{6,7,8} ) +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" +LICENSE="LGPL-2" + +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86" +IUSE="python static-libs test" + +DEPEND=" + python? ( ${PYTHON_DEPS} ) +" +RDEPEND=" + ${DEPEND} +" +RESTRICT="test" +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" +DOCS=( README.md THANKS TODO ) +S=${WORKDIR}/${PN}-${P} +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 + distutils-r1_src_prepare + fi +} + +src_configure() { + econf \ + $(use_with python) \ + $(use_enable static-libs static) +} + +src_compile() { + default + if use python; then + cd python + distutils-r1_src_compile + fi +} + +src_install() { + default + if use python; then + cd python + unset DOCS + distutils-r1_src_install + fi + find "${D}" -name '*.la' -delete || die +} diff --git a/dev-libs/libdnet/libdnet-1.14.ebuild b/dev-libs/libdnet/libdnet-1.14.ebuild index d44d1d79a672..3c236abaf8f3 100644 --- a/dev-libs/libdnet/libdnet-1.14.ebuild +++ b/dev-libs/libdnet/libdnet-1.14.ebuild @@ -13,7 +13,7 @@ SRC_URI="https://github.com/ofalk/${PN}/archive/${P}.tar.gz" LICENSE="LGPL-2" SLOT="0" -KEYWORDS="~alpha ~amd64 arm ~hppa ~ia64 ~mips ppc ppc64 sparc ~x86" +KEYWORDS="~alpha amd64 arm hppa ~ia64 ~mips ppc ppc64 sparc x86" IUSE="python static-libs test" DEPEND=" @@ -26,6 +26,9 @@ RESTRICT="test" REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" DOCS=( README.md THANKS TODO ) S=${WORKDIR}/${PN}-${P} +PATCHES=( + "${FILESDIR}"/${PN}-1.14-strlcpy.patch +) src_prepare() { default diff --git a/dev-libs/libdnet/libdnet-9999.ebuild b/dev-libs/libdnet/libdnet-9999.ebuild index 3878f74646eb..c1471b35968c 100644 --- a/dev-libs/libdnet/libdnet-9999.ebuild +++ b/dev-libs/libdnet/libdnet-9999.ebuild @@ -10,6 +10,7 @@ inherit autotools distutils-r1 git-r3 DESCRIPTION="simplified, portable interface to several low-level networking routines" HOMEPAGE="https://github.com/ofalk/libdnet" EGIT_REPO_URI="https://github.com/ofalk/libdnet" +EGIT_BRANCH="devel" LICENSE="LGPL-2" SLOT="0" @@ -25,6 +26,9 @@ RDEPEND=" RESTRICT="test" REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" DOCS=( README.md THANKS TODO ) +PATCHES=( + "${FILESDIR}"/${PN}-1.14-strlcpy.patch +) src_prepare() { default |