SCCS-vsn: sys/netinet/in.c 7.5
SCCS-vsn: sys/netinet/in.h 7.3
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)in.c 7.4 (Berkeley) %G%
+ * @(#)in.c 7.5 (Berkeley) %G%
net = i & IN_CLASSA_NET;
else if (IN_CLASSB(i))
net = i & IN_CLASSB_NET;
net = i & IN_CLASSA_NET;
else if (IN_CLASSB(i))
net = i & IN_CLASSB_NET;
/*
* Check whether network is a subnet;
/*
* Check whether network is a subnet;
} else if (IN_CLASSB(i)) {
net = i & IN_CLASSB_NET;
host = i & IN_CLASSB_HOST;
} else if (IN_CLASSB(i)) {
net = i & IN_CLASSB_NET;
host = i & IN_CLASSB_HOST;
+ } else if (IN_CLASSC(i)) {
net = i & IN_CLASSC_NET;
host = i & IN_CLASSC_HOST;
net = i & IN_CLASSC_NET;
host = i & IN_CLASSC_HOST;
/*
* Check whether network is a subnet;
/*
* Check whether network is a subnet;
+/*
+ * Determine whether an IP address is in a reserved set of addresses
+ * that may not be forwarded, or whether datagrams to that destination
+ * may be forwarded.
+ */
+in_canforward(in)
+ struct in_addr in;
+{
+ register u_long i = ntohl(in.s_addr);
+ register u_long net;
+
+ if (IN_EXPERIMENTAL(i))
+ return (0);
+ if (IN_CLASSA(i)) {
+ net = i & IN_CLASSA_NET;
+ if (net == 0 || net == IN_LOOPBACKNET)
+ return (0);
+ }
+ return (1);
+}
+
int in_interfaces; /* number of external internet interfaces */
extern struct ifnet loif;
int in_interfaces; /* number of external internet interfaces */
extern struct ifnet loif;
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)in.h 7.2 (Berkeley) %G%
+ * @(#)in.h 7.3 (Berkeley) %G%
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
#define IN_CLASSB_HOST 0x0000ffff
#define IN_CLASSB_MAX 65536
-#define IN_CLASSC(i) (((long)(i) & 0xc0000000) == 0xc0000000)
+#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST 0x000000ff
+#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
+#define IN_MULTICAST(i) IN_CLASSD(i)
+
+#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000)
+#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
+
#define INADDR_ANY (u_long)0x00000000
#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
#ifndef KERNEL
#define INADDR_NONE 0xffffffff /* -1 return */
#endif
#define INADDR_ANY (u_long)0x00000000
#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
#ifndef KERNEL
#define INADDR_NONE 0xffffffff /* -1 return */
#endif
+#define IN_LOOPBACKNET 127 /* official! */
+
/*
* Socket address, internet style.
*/
/*
* Socket address, internet style.
*/