summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2009-12-11 14:29:11 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2009-12-11 14:29:11 +0100
commitbb705e4324adb87b00f41cc1759167ce9d272345 (patch)
tree35017b7c7cb04f90cbc2e54b36cda6994702347f
parente821a4048033e5d45282e32df8af23cc93a4dc30 (diff)
build with new libnet, patch from OpenSuSE 11
-rw-r--r--package/rarpd/Makefile2
-rw-r--r--package/rarpd/patches/patch-rarpd_c142
2 files changed, 143 insertions, 1 deletions
diff --git a/package/rarpd/Makefile b/package/rarpd/Makefile
index 0121f933c..5e09b743a 100644
--- a/package/rarpd/Makefile
+++ b/package/rarpd/Makefile
@@ -5,7 +5,7 @@ include ${TOPDIR}/rules.mk
PKG_NAME:= rarpd
PKG_VERSION:= 1.1
-PKG_RELEASE:= 10
+PKG_RELEASE:= 11
PKG_MD5SUM:= 04e2ca849e758d0b88c8281775ec3b58
PKG_DESCR:= Reverse ARP Daemon
PKG_SECTION:= net
diff --git a/package/rarpd/patches/patch-rarpd_c b/package/rarpd/patches/patch-rarpd_c
new file mode 100644
index 000000000..92d50bff2
--- /dev/null
+++ b/package/rarpd/patches/patch-rarpd_c
@@ -0,0 +1,142 @@
+--- rarpd-1.1.orig/rarpd.c 1999-11-17 01:51:22.000000000 +0100
++++ rarpd-1.1/rarpd.c 2009-12-11 14:28:32.000000000 +0100
+@@ -65,18 +65,12 @@
+ #define ETHERSTRLEN sizeof("00:00:00:00:00:00")
+ #define IPSTRLEN sizeof(".xxx.xxx.xxx.xxx")
+
+-#ifdef NEW_LIBNET_INTERFACE
+-#define open_link_interface libnet_open_link_interface
+-#define link_int libnet_link_int
+-#define build_arp libnet_build_arp
+-#define get_ipaddr libnet_get_ipaddr
+-#define get_hwaddr libnet_get_hwaddr
+-#define build_ethernet libnet_build_ethernet
+-#define write_link_layer libnet_write_link_layer
+-
+-/* Temporary workaround */
+-#define ARP_H LIBNET_ARP_H
+-#endif
++struct _ipv4_arp_data_ {
++ u_char ar_sha[6]; /* sender hardware address */
++ u_char ar_spa[4]; /* sender protocol address */
++ u_char ar_tha[6]; /* target hardware address */
++ u_char ar_tpa[4]; /* target protocol address */
++};
+
+ extern char pcap_version[];
+ extern int optind;
+@@ -88,7 +82,7 @@ static int vflag; /
+ static char *program_name;
+
+ static pcap_t *pd;
+-static struct link_int *ln;
++static libnet_t *ld;
+ static char *device, *ethers;
+ struct in_addr my_ipaddr;
+ static u_char my_hwaddr[ETHERADDRLEN];
+@@ -285,23 +279,34 @@ void set_arp(struct in_addr *herip, unsi
+ void send_rarpreply(unsigned char *dest_hwaddr,
+ unsigned char *her_hwaddr, struct in_addr *her_ipaddr)
+ {
+- char ebuf[PCAP_ERRBUF_SIZE];
+- u_char buf[ARP_H+ETH_H];
+-
+- memset(buf, 0, ARP_H + ETH_H);
+-
+- /* Ethernet header */
+- build_ethernet(dest_hwaddr, my_hwaddr, ETHERTYPE_REVARP, NULL, 0, buf);
++ int c;
++ libnet_ptag_t t;
+
+ /* ARP header */
+- build_arp(ARPHRD_ETHER, ETHERTYPE_IP,
++ t = libnet_build_arp(ARPHRD_ETHER, ETHERTYPE_IP,
+ ETHERADDRLEN, IPADDRLEN,
+ ARPOP_REVREPLY,
+ my_hwaddr, (u_char *)&(my_ipaddr.s_addr),
+ her_hwaddr, (u_char *)&(her_ipaddr->s_addr),
+- NULL, 0, buf + ETH_H);
++ NULL, 0, ld, 0);
++ if (t == -1) {
++ syslog(LOG_ERR, "%s: Can't build ARP header: %s", program_name, libnet_geterror(ld));
++ exit(1);
++ }
+
+- write_link_layer(ln, (const u_char *)device, buf, ARP_H + ETH_H);
++ /* Ethernet header */
++ t = libnet_build_ethernet(dest_hwaddr, my_hwaddr, ETHERTYPE_REVARP, NULL, 0, ld, 0);
++ if (t == -1) {
++ syslog(LOG_ERR, "%s: Can't build ethernet header: %s", program_name,
++ libnet_geterror(ld));
++ exit(1);
++ }
++
++ c = libnet_write(ld);
++ if (c == -1) {
++ syslog(LOG_ERR, "%s: Write error: %s", program_name, libnet_geterror(ld));
++ exit(1);
++ }
+ }
+
+
+@@ -314,11 +319,13 @@ void process_arp(u_char *user, const str
+ unsigned short pro, hrd, op;
+ struct in_addr her_ipaddr;
+ struct libnet_arp_hdr *ap;
++ struct _ipv4_arp_data_ *ad;
+ struct hostent *hp;
+ char *ipp;
+
+ bp += sizeof(struct libnet_ethernet_hdr);
+ ap = (struct libnet_arp_hdr *)bp;
++ ad = (struct _ipv4_arp_data_ *)(bp + sizeof(*ap));
+
+ pro = EXTRACT_16BITS (&ap->ar_pro);
+ hrd = EXTRACT_16BITS (&ap->ar_hrd);
+@@ -331,10 +338,10 @@ void process_arp(u_char *user, const str
+ /* We only answer RARP requests */
+ if (op != ARPOP_REVREQUEST) return;
+
+- sha = ap->ar_sha;
+- spa = ap->ar_spa;
+- tha = ap->ar_tha;
+- tpa = ap->ar_tpa;
++ sha = ad->ar_sha;
++ spa = ad->ar_spa;
++ tha = ad->ar_tha;
++ tpa = ad->ar_tpa;
+
+ if (my_ether_ntohost(toret, tha)) {
+ if (vflag) {
+@@ -399,6 +406,7 @@ int main(int argc, char **argv)
+ int nofork, op, pid, syslogflags;
+ bpf_u_int32 localnet, netmask;
+ char ebuf[PCAP_ERRBUF_SIZE];
++ char errbuf[LIBNET_ERRBUF_SIZE];
+ char *cmdbuf;
+ struct bpf_program fcode;
+
+@@ -446,9 +454,9 @@ int main(int argc, char **argv)
+ }
+ }
+
+- ln = open_link_interface(device, ebuf);
+- if (ln == NULL) {
+- syslog(LOG_ERR, "%s: %s", program_name, ebuf);
++ ld = libnet_init(LIBNET_LINK, device, errbuf);
++ if (ld == NULL) {
++ syslog(LOG_ERR, "%s: %s", program_name, errbuf);
+ exit(1);
+ }
+
+@@ -465,8 +473,8 @@ int main(int argc, char **argv)
+ }
+
+ memset(&my_ipaddr, 0, sizeof(my_ipaddr));
+- my_ipaddr.s_addr = htonl(get_ipaddr(ln, device, ebuf));
+- memcpy(my_hwaddr, (char *)get_hwaddr(ln, device, ebuf), ETHERADDRLEN);
++ my_ipaddr.s_addr = libnet_get_ipaddr4(ld);
++ memcpy(my_hwaddr, (char *) libnet_get_hwaddr(ld), ETHERADDRLEN);
+
+ setuid(getuid());
+