]> git.ozlabs.org Git - ppp.git/blobdiff - modules/ppp.c
Added IPv6 support so that IPv4 and IPv6 packets can be mux'ed correctly
[ppp.git] / modules / ppp.c
index b3a32a39d3b0a75c586f1e0f5d4a474e983cc296..79f9bac665ff9a90448de75d8e39433688e361ac 100644 (file)
@@ -24,7 +24,7 @@
  * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
  * OR MODIFICATIONS.
  *
- * $Id: ppp.c,v 1.20 1999/09/08 01:11:15 masputra Exp $
+ * $Id: ppp.c,v 1.23 1999/09/30 19:54:44 masputra Exp $
  */
 
 /*
@@ -54,6 +54,7 @@
 #include <sys/ksynch.h>
 #include <sys/kstat.h>
 #include <sys/sunddi.h>
+#include <sys/ethernet.h>
 #else
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #define ETHERTYPE_IP   0x800
 #endif
 
+#if !defined(ETHERTYPE_IP6) && defined(SOL2)
+#define ETHERTYPE_IP6  0x86dd
+#endif /* !defined(ETHERTYPE_IP6) && defined(SOL2) */
+
 extern time_t time;
 
 #ifdef SOL2
@@ -255,7 +260,9 @@ static upperstr_t *find_dest __P((upperstr_t *, int));
 static int putctl2 __P((queue_t *, int, int, int));
 static int putctl4 __P((queue_t *, int, int, int));
 static int pass_packet __P((upperstr_t *ppa, mblk_t *mp, int outbound));
+#ifdef FILTER_PACKETS
 static int ip_hard_filter __P((upperstr_t *ppa, mblk_t *mp, int outbound));
+#endif /* FILTER_PACKETS */
 
 #define PPP_ID 0xb1a6
 static struct module_info ppp_info = {
@@ -556,7 +563,7 @@ pppuwput(q, mp)
     queue_t *q;
     mblk_t *mp;
 {
-    upperstr_t *us, *usnext, *ppa, *os, *nps;
+    upperstr_t *us, *ppa, *nps;
     struct iocblk *iop;
     struct linkblk *lb;
 #ifdef LACHTCP
@@ -567,10 +574,12 @@ pppuwput(q, mp)
     int error, n, sap;
     mblk_t *mq;
     struct ppp_idle *pip;
-    int len;
 #ifdef PRIOQ
     queue_t *tlq;
 #endif /* PRIOQ */
+#ifdef NO_DLPI
+    upperstr_t *os;
+#endif
 
     us = (upperstr_t *) q->q_ptr;
     if (us == 0) {
@@ -833,9 +842,12 @@ pppuwput(q, mp)
                break;
            }
            sap = ((int *)mp->b_cont->b_rptr)[0];
-           for (nps = us->next; nps != 0; nps = nps->next)
+           for (nps = us->next; nps != 0; nps = nps->next) {
+               if (us->flags & US_DBGLOG)
+                   DPRINT2("us = 0x%x, us->next->sap = 0x%x\n", nps, nps->sap);
                if (nps->sap == sap)
                    break;
+           }
            if (nps == 0) {
                if (us->flags & US_DBGLOG)
                    DPRINT2("ppp/%d: no stream for sap %x\n", us->mn, sap);
@@ -1042,9 +1054,13 @@ dlpi_request(q, mp, us)
     int size = mp->b_wptr - mp->b_rptr;
     mblk_t *reply, *np;
     upperstr_t *ppa, *os;
-    int sap, *ip, len;
+    int sap, len;
     dl_info_ack_t *info;
     dl_bind_ack_t *ackp;
+#if DL_CURRENT_VERSION >= 2
+    dl_phys_addr_ack_t *paddrack;
+    static struct ether_addr eaddr = {0};
+#endif
 
     if (us->flags & US_DBGLOG)
        DPRINT3("ppp/%d: dlpi prim %x len=%d\n", us->mn,
@@ -1063,15 +1079,7 @@ dlpi_request(q, mp, us)
        info->dl_max_sdu = us->ppa? us->ppa->mtu: PPP_MAXMTU;
        info->dl_min_sdu = 1;
        info->dl_addr_length = sizeof(uint);
-#if 0
-#ifdef DL_OTHER
-       info->dl_mac_type = DL_OTHER;
-#else
-       info->dl_mac_type = DL_HDLC;    /* a lie */
-#endif
-#else
-       info->dl_mac_type = DL_ETHER;   /* a bigger lie */
-#endif
+       info->dl_mac_type = DL_OTHER;   /* a bigger lie */
        info->dl_current_state = us->state;
        info->dl_service_mode = DL_CLDLS;
        info->dl_provider_style = DL_STYLE2;
@@ -1130,23 +1138,25 @@ dlpi_request(q, mp, us)
        sap = d->bind_req.dl_sap;
        us->req_sap = sap;
 
-#ifdef SOL2
-        /* 
-        * ip will send a sap value of 0 (post-Solaris 7), or
-        * ETHERTYPE_IP (0x800) (pre-Solaris 8) due to how the
-        * ppp DLPI provider declares its characteristics.
-        * <adi.masputra@sun.com>
-        */
-       if (sap == 0)
-            sap = ETHERTYPE_IP;
-#endif /* SOL2 */
-
+#if defined(SOL2)
+       if (us->flags & US_DBGLOG)
+           DPRINT2("DL_BIND_REQ: ip gives sap = 0x%x, us = 0x%x", sap, us);
+       if (sap == ETHERTYPE_IP)
+           sap = PPP_IP;
+       else if (sap == ETHERTYPE_IP6)
+           sap = PPP_IPV6;
+       else {
+           dlpi_error(q, us, DL_BIND_REQ, DL_BADADDR, 0);
+           break;
+       }
+#else
        if (sap == ETHERTYPE_IP)
            sap = PPP_IP;
        if (sap < 0x21 || sap > 0x3fff || (sap & 0x101) != 1) {
            dlpi_error(q, us, DL_BIND_REQ, DL_BADADDR, 0);
            break;
        }
+#endif /* defined(SOL2) */
 
        /* check that no other stream is bound to this sap already. */
        for (os = us->ppa; os != 0; os = os->next)
@@ -1293,14 +1303,38 @@ dlpi_request(q, mp, us)
        return;
 
 #if DL_CURRENT_VERSION >= 2
+    case DL_PHYS_ADDR_REQ:
+       if (size < sizeof(dl_phys_addr_req_t))
+           goto badprim;
+
+       /*
+        * Don't check state because ifconfig sends this one down too
+        */
+
+       if ((reply = allocb(sizeof(dl_phys_addr_ack_t)+ETHERADDRL, 
+                       BPRI_HI)) == 0)
+           break;              /* should do bufcall */
+       reply->b_datap->db_type = M_PCPROTO;
+       paddrack = (dl_phys_addr_ack_t *) reply->b_wptr;
+       reply->b_wptr += sizeof(dl_phys_addr_ack_t);
+       bzero((caddr_t) paddrack, sizeof(dl_phys_addr_ack_t)+ETHERADDRL);
+       paddrack->dl_primitive = DL_PHYS_ADDR_ACK;
+       paddrack->dl_addr_length = ETHERADDRL;
+       paddrack->dl_addr_offset = sizeof(dl_phys_addr_ack_t);
+       bcopy(&eaddr, reply->b_wptr, ETHERADDRL);
+       reply->b_wptr += ETHERADDRL;
+       qreply(q, reply);
+       break;
+#endif
+
+#if DL_CURRENT_VERSION >= 2
+    case DL_SET_PHYS_ADDR_REQ:
     case DL_SUBS_BIND_REQ:
     case DL_SUBS_UNBIND_REQ:
     case DL_ENABMULTI_REQ:
     case DL_DISABMULTI_REQ:
     case DL_PROMISCON_REQ:
     case DL_PROMISCOFF_REQ:
-    case DL_PHYS_ADDR_REQ:
-    case DL_SET_PHYS_ADDR_REQ:
     case DL_XID_REQ:
     case DL_TEST_REQ:
     case DL_REPLY_UPDATE_REQ:
@@ -1435,7 +1469,6 @@ send_data(mp, us)
     mblk_t *mp;
     upperstr_t *us;
 {
-    queue_t *q;
     upperstr_t *ppa;
 
     if ((us->flags & US_BLOCKED) || us->npmode == NPMODE_QUEUE)
@@ -1447,7 +1480,7 @@ send_data(mp, us)
        freemsg(mp);
        return 1;
     }
-    if ((q = ppa->lowerq) == 0) {
+    if (ppa->lowerq == 0) {
        /* try to send it up the control stream */
         if (bcanputnext(ppa->q, mp->b_band)) {
            /*
@@ -1711,9 +1744,7 @@ pppurput(q, mp)
     mblk_t *mp;
 {
     upperstr_t *ppa, *us;
-    queue_t *uq;
     int proto, len;
-    mblk_t *np;
     struct iocblk *iop;
 
     ppa = (upperstr_t *) q->q_ptr;