Re: CONFIG_INET_RARP

David Wragg (dpw@doc.ic.ac.uk)
29 Sep 1999 20:33:40 +0000


ekka Pietikainen <pp@netppl.fi> writes:
> There is a userspace rarpd that works in
> ftp://ftp.funet.fi/pub/mirrors/ftp.inr.ac.ru/ip-routing/dhcp.bootp.rarp/
> There is just one problem with it, it doesn't really compile on a
> 2.3.x/glibc2.1 based system, and making it compile doesn't seem to be
> a trivial job either.

I got it to build on glibc-2.1. Patch below. I only needed to run it
once to install Linux on a Sun machine, so it would need a bit more
work before it could be merged into Alexey's rarpd. But it shows what
needs to be done; most of it renames struct ifaddr to ifaddress to
avoid a clash with something in the glibc headers.

Regards,
David Wragg

(Against rarpd-ss981107)

diff -rua rarpd/rarpd.c rarpd.mod/rarpd.c
--- rarpd/rarpd.c Sat Nov 7 14:48:40 1998
+++ rarpd.mod/rarpd.c Mon Sep 13 23:13:31 1999
@@ -25,10 +25,17 @@
#include <sys/signal.h>
#include <net/if.h>
#include <net/if_arp.h>
+#include <net/ethernet.h>
#include <netinet/in.h>
+
+#include <linux/types.h>
#include <linux/if_packet.h>
#include <linux/filter.h>

+#ifndef MSG_DONTWAIT
+#define MSG_DONTWAIT 0x40 /* Nonblocking io */
+#endif
+
int do_reload = 1;

int debug;
@@ -51,12 +58,12 @@
int hatype;
unsigned char lladdr[16];
unsigned char name[IFNAMSIZ];
- struct ifaddr *ifa_list;
+ struct ifaddress *ifa_list;
} *ifl_list;

-struct ifaddr
+struct ifaddress
{
- struct ifaddr *next;
+ struct ifaddress *next;
__u32 prefix;
__u32 mask;
__u32 local;
@@ -88,7 +95,7 @@
int fd;
struct ifreq *ifrp, *ifend;
struct iflink *ifl;
- struct ifaddr *ifa;
+ struct ifaddress *ifa;
struct ifconf ifc;
struct ifreq ibuf[256];

@@ -179,7 +186,7 @@
if (ifa == NULL) {
if (mask == 0 || prefix == 0)
continue;
- ifa = (struct ifaddr*)malloc(sizeof(*ifa));
+ ifa = (struct ifaddress*)malloc(sizeof(*ifa));
memset(ifa, 0, sizeof(*ifa));
ifa->local = addr;
ifa->prefix = prefix;
@@ -235,10 +242,10 @@
return dent != NULL;
}

-struct ifaddr *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist)
+struct ifaddress *select_ipaddr(int ifindex, __u32 *sel_addr, __u32 **alist)
{
struct iflink *ifl;
- struct ifaddr *ifa;
+ struct ifaddress *ifa;
int retry = 0;
int i;

@@ -294,7 +301,7 @@

if (r == NULL) {
if (hatype == ARPHRD_ETHER && halen == 6) {
- struct ifaddr *ifa;
+ struct ifaddress *ifa;
struct hostent *hp;
char ename[256];
static struct rarp_map emap = {
@@ -363,7 +370,7 @@
{
__u32 laddr = 0;
struct iflink *ifl;
- struct ifaddr *ifa;
+ struct ifaddress *ifa;

for (ifl=ifl_list; ifl; ifl = ifl->next)
if (ifl->index == ifindex)
@@ -470,7 +477,7 @@
return;
}
/* 2. ARP protocol must be IP */
- if (a->ar_pro != htons(ETH_P_IP)) {
+ if (a->ar_pro != htons(ETHERTYPE_IP)) {
syslog(LOG_ERR, "rarp protocol is not IP %04x", ntohs(a->ar_pro));
return;
}
@@ -634,7 +641,7 @@
struct sockaddr_ll sll;
memset(&sll, 0, sizeof(sll));
sll.sll_family = AF_PACKET;
- sll.sll_protocol = htons(ETH_P_ARP);
+ sll.sll_protocol = htons(ETHERTYPE_ARP);
sll.sll_ifindex = all_ifaces ? 0 : ifidx;
if (bind(pset[1].fd, (struct sockaddr*)&sll, sizeof(sll)) < 0) {
close(pset[1].fd);
@@ -646,7 +653,7 @@
struct sockaddr_ll sll;
memset(&sll, 0, sizeof(sll));
sll.sll_family = AF_PACKET;
- sll.sll_protocol = htons(ETH_P_RARP);
+ sll.sll_protocol = htons(ETHERTYPE_REVARP);
sll.sll_ifindex = all_ifaces ? 0 : ifidx;
if (bind(pset[0].fd, (struct sockaddr*)&sll, sizeof(sll)) < 0) {
close(pset[0].fd);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/