CATMANPAGES = dhcp-options.cat5 dhcp-contrib.cat5 dhcp-eval.cat5
SEDMANPAGES = dhcp-options.man5 dhcp-contrib.man5 dhcp-eval.man5
SRC = raw.c parse.c nit.c icmp.c dispatch.c conflex.c upf.c bpf.c socket.c \
- lpf.c dlpi.c packet.c memory.c print.c options.c inet.c convert.c \
- tree.c tables.c hash.c alloc.c errwarn.c inet_addr.c dns.c \
- resolv.c execute.c discover.c auth.c
+ lpf.c dlpi.c packet.c tr.c ethernet.c memory.c print.c options.c \
+ inet.c convert.c tree.c tables.c hash.c alloc.c errwarn.c \
+ inet_addr.c dns.c resolv.c execute.c discover.c auth.c
OBJ = raw.o parse.o nit.o icmp.o dispatch.o conflex.o upf.o bpf.o socket.o \
- lpf.o dlpi.o packet.o memory.o print.o options.o inet.o convert.o \
- tree.o tables.o hash.o alloc.o errwarn.o inet_addr.o dns.o \
- resolv.o execute.o discover.o auth.o
+ lpf.o dlpi.o packet.o tr.o ethernet.o memory.o print.o options.o \
+ inet.o convert.o tree.o tables.o hash.o alloc.o errwarn.o \
+ inet_addr.o dns.o resolv.o execute.o discover.o auth.o
MAN = dhcp-options.5 dhcp-contrib.5 dhcp-eval.5
DEBUG = -g
#ifndef lint
static char copyright[] =
-"$Id: bpf.c,v 1.26 1999/03/16 06:37:48 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: bpf.c,v 1.27 1999/05/27 17:43:27 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
};
int dhcp_bpf_filter_len = sizeof dhcp_bpf_filter / sizeof (struct bpf_insn);
+struct bpf_insn dhcp_bpf_tr_filter [] = {
+ /* accept all token ring packets due to variable length header */
+ /* if we want to get clever, insert the program here */
+
+ /* If we passed all the tests, ask for the whole packet. */
+ BPF_STMT(BPF_RET+BPF_K, (u_int)-1),
+
+ /* Otherwise, drop it. */
+ BPF_STMT(BPF_RET+BPF_K, 0),
+};
+
+int dhcp_bpf_tr_filter_len = (sizeof dhcp_bpf_tr_filter /
+ sizeof (struct bpf_insn));
#endif
#if defined (USE_BPF_RECEIVE)
#ifndef lint
static char copyright[] =
-"$Id: lpf.c,v 1.11 1999/04/12 21:34:37 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: lpf.c,v 1.12 1999/05/27 17:43:27 mellon Exp $ Copyright (c) 1995, 1996, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
in bpf includes... */
extern struct sock_filter dhcp_bpf_filter [];
extern int dhcp_bpf_filter_len;
+extern struct sock_filter dhcp_bpf_tr_filter [];
+extern int dhcp_bpf_tr_filter_len;
void if_register_receive (info)
struct interface_info *info;
{
- struct sock_fprog p;
-
/* Open a LPF device and hang it on this interface... */
info -> rfdesc = if_register_lpf (info);
+ if (info -> hw_address.htype == HTYPE_IEEE802)
+ lpf_tr_filter_setup (info);
+ else
+ lpf_gen_filter_setup (info);
+
+ if (!quiet_interface_discovery)
+ note ("Listening on LPF/%s/%s%s%s",
+ info -> name,
+ print_hw_addr (info -> hw_address.htype,
+ info -> hw_address.hlen,
+ info -> hw_address.haddr),
+ (info -> shared_network ? "/" : ""),
+ (info -> shared_network ?
+ info -> shared_network -> name : ""));
+}
+
+static void lpf_gen_filter_setup (info)
+ struct interface_info *info;
+{
+ struct sock_fprog p;
+
/* Set up the bpf filter program structure. This is defined in
bpf.c */
p.len = dhcp_bpf_filter_len;
if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
errno == EAFNOSUPPORT)
- log_fatal ("socket: %m - make sure %s %s!",
+ error ("socket: %m - make sure %s %s!",
"CONFIG_PACKET and CONFIG_FILTER are defined",
"in your kernel configuration");
- log_fatal ("Can't install packet filter program: %m");
+ error ("Can't install packet filter program: %m");
+ }
+}
+
+static void lpf_tr_filter_setup (info)
+ struct interface_info *info;
+{
+ struct sock_fprog p;
+
+ /* Set up the bpf filter program structure. This is defined in
+ bpf.c */
+ p.len = dhcp_bpf_tr_filter_len;
+ p.filter = dhcp_bpf_tr_filter;
+
+ /* Patch the server port into the LPF program...
+ XXX changes to filter program may require changes
+ XXX to the insn number(s) used below!
+ XXX Token ring filter is null - when/if we have a filter
+ XXX that's not, we'll need this code.
+ XXX dhcp_bpf_filter [?].k = ntohs (local_port); */
+
+ if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, &p,
+ sizeof p) < 0) {
+ if (errno == ENOPROTOOPT || errno == EPROTONOSUPPORT ||
+ errno == ESOCKTNOSUPPORT || errno == EPFNOSUPPORT ||
+ errno == EAFNOSUPPORT)
+ error ("socket: %m - make sure %s %s!",
+ "CONFIG_PACKET and CONFIG_FILTER are defined",
+ "in your kernel configuration");
+ error ("Can't install packet filter program: %m");
}
- if (!quiet_interface_discovery)
- log_info ("Listening on LPF/%s/%s%s%s",
- info -> name,
- print_hw_addr (info -> hw_address.htype,
- info -> hw_address.hlen,
- info -> hw_address.haddr),
- (info -> shared_network ? "/" : ""),
- (info -> shared_network ?
- info -> shared_network -> name : ""));
}
#endif /* USE_LPF_RECEIVE */
#ifndef lint
static char copyright[] =
-"$Id: packet.c,v 1.26 1999/04/23 22:15:43 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: packet.c,v 1.27 1999/05/27 17:43:27 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
#ifdef PACKET_ASSEMBLY
-/* Assemble an hardware header... */
-/* XXX currently only supports ethernet; doesn't check for other types. */
-
void assemble_hw_header (interface, buf, bufix, to)
struct interface_info *interface;
unsigned char *buf;
int *bufix;
struct hardware *to;
{
- struct ether_header eh;
-
- if (to && to -> hlen == 6) /* XXX */
- memcpy (eh.ether_dhost, to -> haddr, sizeof eh.ether_dhost);
+#if defined (HAVE_TR_SUPPORT)
+ if (info -> hw_address.htype == HTYPE_IEEE802)
+ assemble_tr_header (interface, buf, bufix, to);
else
- memset (eh.ether_dhost, 0xff, sizeof (eh.ether_dhost));
- if (interface -> hw_address.hlen == sizeof (eh.ether_shost))
- memcpy (eh.ether_shost, interface -> hw_address.haddr,
- sizeof (eh.ether_shost));
- else
- memset (eh.ether_shost, 0x00, sizeof (eh.ether_shost));
-
-#ifdef BROKEN_FREEBSD_BPF /* Fixed in FreeBSD 2.2 */
- eh.ether_type = ETHERTYPE_IP;
-#else
- eh.ether_type = htons (ETHERTYPE_IP);
#endif
+ assemble_ethernet_header (interface, buf, bufix, to);
- memcpy (&buf [*bufix], &eh, sizeof eh);
- *bufix += sizeof eh;
}
/* UDP header and IP header assembled together for convenience. */
int bufix;
struct hardware *from;
{
- struct ether_header eh;
-
- memcpy (&eh, buf + bufix, sizeof eh);
-
-#ifdef USERLAND_FILTER
- if (ntohs (eh.ether_type) != ETHERTYPE_IP)
- return -1;
+#if defined (HAVE_TR_SUPPORT)
+ if (info -> hw_address.htype == HTYPE_IEEE802)
+ return decode_tr_header (interface, buf, bufix, from);
+ else
#endif
- memcpy (from -> haddr, eh.ether_shost, sizeof (eh.ether_shost));
- from -> htype = ARPHRD_ETHER;
- from -> hlen = sizeof eh.ether_shost;
-
- return sizeof eh;
+ return decode_ethernet_header (interface, buf, bufix, from);
}
/* UDP header and IP header decoded together for convenience. */
# define LINUX_SLASHPROC_DISCOVERY
# define PROCDEV_DEVICE "/proc/net/dev"
# define HAVE_ARPHRD_TUNNEL
+# define HAVE_TR_SUPPORT
# endif
# define HAVE_ARPHRD_METRICOM
# define HAVE_ARPHRD_IEEE802
int, struct sockaddr_in *,
unsigned char *, int));
+/* ethernet.c */
+void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *,
+ int *, struct hardware *));
+ssize_t decode_ethernet_header PROTO ((struct interface_info *,
+ unsigned char *,
+ int, struct hardware *));
+
+/* tr.c */
+void assemble_tr_header PROTO ((struct interface_info *, unsigned char *,
+ int *, struct hardware *));
+ssize_t decode_tr_header PROTO ((struct interface_info *,
+ unsigned char *,
+ int, struct hardware *));
+
/* dhxpxlt.c */
void convert_statement PROTO ((FILE *));
void convert_host_statement PROTO ((FILE *, jrefproto));