don't use direct interface address if it's down
[unix-history] / usr / src / sys / netinet / in_proto.c
index 591d228..311f23d 100644 (file)
@@ -1,27 +1,33 @@
-/*     in_proto.c      5.3     82/11/03        */
+/*
+ * Copyright (c) 1982 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)in_proto.c  6.14 (Berkeley) %G%
+ */
 
 
-#include "../h/param.h"
-#include "../h/socket.h"
-#include "../h/protosw.h"
-#include "../h/domain.h"
-#include "../h/mbuf.h"
+#include "param.h"
+#include "socket.h"
+#include "protosw.h"
+#include "domain.h"
+#include "mbuf.h"
 
 
-#include "../netinet/in.h"
-#include "../netinet/in_systm.h"
+#include "in.h"
+#include "in_systm.h"
 
 /*
  * TCP/IP protocol family: IP, ICMP, UDP, TCP.
  */
 
 /*
  * TCP/IP protocol family: IP, ICMP, UDP, TCP.
  */
-int    ip_output();
+int    ip_output(),ip_ctloutput();
 int    ip_init(),ip_slowtimo(),ip_drain();
 int    icmp_input();
 int    udp_input(),udp_ctlinput();
 int    udp_usrreq();
 int    udp_init();
 int    tcp_input(),tcp_ctlinput();
 int    ip_init(),ip_slowtimo(),ip_drain();
 int    icmp_input();
 int    udp_input(),udp_ctlinput();
 int    udp_usrreq();
 int    udp_init();
 int    tcp_input(),tcp_ctlinput();
-int    tcp_usrreq();
+int    tcp_usrreq(),tcp_ctloutput();
 int    tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain();
 int    tcp_init(),tcp_fasttimo(),tcp_slowtimo(),tcp_drain();
-int    rip_input(),rip_output();
+int    rip_input(),rip_output(),rip_ctloutput();
 extern int raw_usrreq();
 /*
  * IMP protocol family: raw interface.
 extern int raw_usrreq();
 /*
  * IMP protocol family: raw interface.
@@ -33,40 +39,62 @@ extern      int raw_usrreq();
 int    rimp_output(), hostslowtimo();
 #endif
 
 int    rimp_output(), hostslowtimo();
 #endif
 
+#ifdef NSIP
+int    idpip_input(), nsip_ctlinput();
+#endif
+
+extern struct domain inetdomain;
+
 struct protosw inetsw[] = {
 struct protosw inetsw[] = {
-{ 0,           PF_INET,        0,              0,
+{ 0,           &inetdomain,    0,              0,
   0,           ip_output,      0,              0,
   0,
   ip_init,     0,              ip_slowtimo,    ip_drain,
 },
   0,           ip_output,      0,              0,
   0,
   ip_init,     0,              ip_slowtimo,    ip_drain,
 },
-{ 0,           PF_INET,        IPPROTO_ICMP,   0,
-  icmp_input,  0,              0,              0,
-  0,
-  0,           0,              0,              0,
-},
-{ SOCK_DGRAM,  PF_INET,        IPPROTO_UDP,    PR_ATOMIC|PR_ADDR,
-  udp_input,   0,              udp_ctlinput,   0,
+{ SOCK_DGRAM,  &inetdomain,    IPPROTO_UDP,    PR_ATOMIC|PR_ADDR,
+  udp_input,   0,              udp_ctlinput,   ip_ctloutput,
   udp_usrreq,
   udp_init,    0,              0,              0,
 },
   udp_usrreq,
   udp_init,    0,              0,              0,
 },
-{ SOCK_STREAM, PF_INET,        IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD,
-  tcp_input,   0,              tcp_ctlinput,   0,
+{ SOCK_STREAM, &inetdomain,    IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD,
+  tcp_input,   0,              tcp_ctlinput,   tcp_ctloutput,
   tcp_usrreq,
   tcp_init,    tcp_fasttimo,   tcp_slowtimo,   tcp_drain,
 },
   tcp_usrreq,
   tcp_init,    tcp_fasttimo,   tcp_slowtimo,   tcp_drain,
 },
-{ SOCK_RAW,    PF_INET,        IPPROTO_RAW,    PR_ATOMIC|PR_ADDR,
-  rip_input,   rip_output,     0,      0,
+{ SOCK_RAW,    &inetdomain,    IPPROTO_RAW,    PR_ATOMIC|PR_ADDR,
+  rip_input,   rip_output,     0,              rip_ctloutput,
+  raw_usrreq,
+  0,           0,              0,              0,
+},
+{ SOCK_RAW,    &inetdomain,    IPPROTO_ICMP,   PR_ATOMIC|PR_ADDR,
+  icmp_input,  rip_output,     0,              rip_ctloutput,
+  raw_usrreq,
+  0,           0,              0,              0,
+},
+#ifdef NSIP
+{ SOCK_RAW,    &inetdomain,    IPPROTO_IDP,    PR_ATOMIC|PR_ADDR,
+  idpip_input, rip_output,     nsip_ctlinput,  0,
+  raw_usrreq,
+  0,           0,              0,              0,
+},
+#endif
+       /* raw wildcard */
+{ SOCK_RAW,    &inetdomain,    0,              PR_ATOMIC|PR_ADDR,
+  rip_input,   rip_output,     0,              rip_ctloutput,
   raw_usrreq,
   0,           0,              0,              0,
 },
 };
 
 struct domain inetdomain =
   raw_usrreq,
   0,           0,              0,              0,
 },
 };
 
 struct domain inetdomain =
-    { AF_INET, "internet", inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])] };
+    { AF_INET, "internet", 0, 0, 0, 
+      inetsw, &inetsw[sizeof(inetsw)/sizeof(inetsw[0])] };
 
 #if NIMP > 0
 
 #if NIMP > 0
+extern struct domain impdomain;
+
 struct protosw impsw[] = {
 struct protosw impsw[] = {
-{ SOCK_RAW,    PF_IMPLINK,     0,              PR_ATOMIC|PR_ADDR,
+{ SOCK_RAW,    &impdomain,     0,              PR_ATOMIC|PR_ADDR,
   0,           rimp_output,    0,              0,
   raw_usrreq,
   0,           0,              hostslowtimo,   0,
   0,           rimp_output,    0,              0,
   raw_usrreq,
   0,           0,              hostslowtimo,   0,
@@ -74,5 +102,26 @@ struct protosw impsw[] = {
 };
 
 struct domain impdomain =
 };
 
 struct domain impdomain =
-    { AF_IMPLINK, "imp", impsw, &impsw[sizeof (impsw)/sizeof(impsw[0])] };
+    { AF_IMPLINK, "imp", 0, 0, 0,
+      impsw, &impsw[sizeof (impsw)/sizeof(impsw[0])] };
+#endif
+
+#include "hy.h"
+#if NHY > 0
+/*
+ * HYPERchannel protocol family: raw interface.
+ */
+int    rhy_output();
+extern struct domain hydomain;
+
+struct protosw hysw[] = {
+{ SOCK_RAW,    &hydomain,      0,              PR_ATOMIC|PR_ADDR,
+  0,           rhy_output,     0,              0,
+  raw_usrreq,
+  0,           0,              0,              0,
+},
+};
+
+struct domain hydomain =
+    { AF_HYLINK, "hy", 0, 0, 0, hysw, &hysw[sizeof (hysw)/sizeof(hysw[0])] };
 #endif
 #endif