Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Fix thinko of mine in previous. The source route info i...



details:   https://anonhg.NetBSD.org/src/rev/9a4cbc542c4c
branches:  trunk
changeset: 473345:9a4cbc542c4c
user:      bad <bad%NetBSD.org@localhost>
date:      Sun May 30 00:39:07 1999 +0000

description:
Fix thinko of mine in previous.  The source route info is not at m->m_data
after various m_adj()s have been done.  Kludge around this with a cheesy
macro that knows where the drivers put the mac header in the first mbuf.

XXX There should be a better way to do this.

diffstat:

 sys/net/if_token.h     |  13 +++++++++++--
 sys/net/if_tokensubr.c |   4 ++--
 sys/netinet/if_arp.c   |  30 ++++++++++++++++++------------
 3 files changed, 31 insertions(+), 16 deletions(-)

diffs (94 lines):

diff -r 19c8aac29e0c -r 9a4cbc542c4c sys/net/if_token.h
--- a/sys/net/if_token.h        Sun May 30 00:22:59 1999 +0000
+++ b/sys/net/if_token.h        Sun May 30 00:39:07 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_token.h,v 1.4 1999/05/18 23:57:21 thorpej Exp $     */
+/*     $NetBSD: if_token.h,v 1.5 1999/05/30 00:39:07 bad Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -100,10 +100,19 @@
 
 /*
  * This assumes that route information fields are appended to
- * existing structures like llinfo_arp and tr_header
+ * existing structures like llinfo_arp and token_header
  */
 #define TOKEN_RIF(x) ((struct token_rif *) ((x) + 1))
 
+/*
+ * This is a kludge to get at the token ring mac header and the source route
+ * information after m_adj() has been used on the mbuf.
+ * Note that m is always an mbuf with a packet header.
+ */
+#define M_TRHSTART(m) \
+       (ALIGN(((m)->m_flags & M_EXT ? (m)->m_ext.ext_buf : &(m)->m_pktdat[0]) \
+           + sizeof (struct token_header)) - sizeof(struct token_header))
+
 #if defined(_KERNEL)
 /*
  * XXX we need if_ethersubr.c with all these defines
diff -r 19c8aac29e0c -r 9a4cbc542c4c sys/net/if_tokensubr.c
--- a/sys/net/if_tokensubr.c    Sun May 30 00:22:59 1999 +0000
+++ b/sys/net/if_tokensubr.c    Sun May 30 00:39:07 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tokensubr.c,v 1.6 1999/05/29 22:36:07 bad Exp $     */
+/*     $NetBSD: if_tokensubr.c,v 1.7 1999/05/30 00:39:07 bad Exp $     */
 
 /*
  * Copyright (c) 1997-1999
@@ -245,7 +245,7 @@
                }
                else {
                        bcopy((caddr_t)ar_tha(ah), (caddr_t)edst, sizeof(edst));
-                       trh = mtod(m, struct token_header *);
+                       trh = (struct token_header *)M_TRHSTART(m);
                        trh->token_ac = TOKEN_AC;
                        trh->token_fc = TOKEN_FC;
                        if (trh->token_shost[0] & TOKEN_RI_PRESENT) {
diff -r 19c8aac29e0c -r 9a4cbc542c4c sys/netinet/if_arp.c
--- a/sys/netinet/if_arp.c      Sun May 30 00:22:59 1999 +0000
+++ b/sys/netinet/if_arp.c      Sun May 30 00:39:07 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_arp.c,v 1.60 1999/05/29 22:36:08 bad Exp $  */
+/*     $NetBSD: if_arp.c,v 1.61 1999/05/30 00:39:07 bad Exp $  */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -642,19 +642,25 @@
                 * XXX uses m_data and assumes the complete answer including
                 * XXX token-ring headers is in the same buf
                 */
-               if (ifp->if_type == IFT_ISO88025 &&
-                       m->m_data[8] & TOKEN_RI_PRESENT) {
-                       struct token_rif        *rif;
-                       size_t  riflen;
+               if (ifp->if_type == IFT_ISO88025) {
+                       struct token_header *trh;
+
+                       trh = (struct token_header *)M_TRHSTART(m);
+                       if (trh->token_shost[0] & TOKEN_RI_PRESENT) {
+                               struct token_rif        *rif;
+                               size_t  riflen;
 
-                       rif = TOKEN_RIF(mtod(m, struct token_header *));
-                       riflen = (ntohs(rif->tr_rcf) & TOKEN_RCF_LEN_MASK) >> 8;
+                               rif = TOKEN_RIF(trh);
+                               riflen = (ntohs(rif->tr_rcf) &
+                                   TOKEN_RCF_LEN_MASK) >> 8;
 
-                       if (riflen > 2 && riflen < sizeof(struct token_rif) &&
-                               (riflen & 1) == 0) {
-                               rif->tr_rcf ^= htons(TOKEN_RCF_DIRECTION);
-                               rif->tr_rcf &= htons(~TOKEN_RCF_BROADCAST_MASK);
-                               bcopy(rif, TOKEN_RIF(la), riflen);
+                               if (riflen > 2 &&
+                                   riflen < sizeof(struct token_rif) &&
+                                   (riflen & 1) == 0) {
+                                       rif->tr_rcf ^= htons(TOKEN_RCF_DIRECTION);
+                                       rif->tr_rcf &= htons(~TOKEN_RCF_BROADCAST_MASK);
+                                       bcopy(rif, TOKEN_RIF(la), riflen);
+                               }
                        }
                }
 #endif /* NTOKEN > 0 */



Home | Main Index | Thread Index | Old Index