patch-2.3.40 linux/include/net/if_inet6.h

Next file: linux/include/pcmcia/cisreg.h
Previous file: linux/include/linux/types.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.39/linux/include/net/if_inet6.h linux/include/net/if_inet6.h
@@ -119,5 +119,59 @@
 
 	memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32));
 }
+
+extern __inline__ void ipv6_tr_mc_map(struct in6_addr *addr, char *buf)
+{
+	/* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */
+
+	if (((addr->s6_addr[0] == 0xFF) &&
+	    ((addr->s6_addr[1] == 0x01) || (addr->s6_addr[1] == 0x02)) &&
+	     (addr->s6_addr16[1] == 0) &&
+	     (addr->s6_addr32[1] == 0) &&
+	     (addr->s6_addr32[2] == 0) &&
+	     (addr->s6_addr16[6] == 0) &&
+	     (addr->s6_addr[15] == 1)) ||
+	    ((addr->s6_addr[0] == 0xFF) &&
+	     (addr->s6_addr[1] == 0x02) &&
+	     (addr->s6_addr16[1] == 0) &&
+	     (addr->s6_addr32[1] == 0) &&
+	     (addr->s6_addr16[4] == 0) &&
+	     (addr->s6_addr[10] == 0) &&
+	     (addr->s6_addr[11] == 1) &&
+	     (addr->s6_addr[12] == 0xff)))
+	{
+		buf[0]=0xC0;
+		buf[1]=0x00;
+		buf[2]=0x01;
+		buf[3]=0x00;
+		buf[4]=0x00;
+		buf[5]=0x00;
+	/* All routers FF0x::2 */
+	} else if ((addr->s6_addr[0] ==0xff) &&
+		((addr->s6_addr[1] & 0xF0) == 0) &&
+		(addr->s6_addr16[1] == 0) &&
+		(addr->s6_addr32[1] == 0) &&
+		(addr->s6_addr32[2] == 0) &&
+		(addr->s6_addr16[6] == 0) &&
+		(addr->s6_addr[15] == 2))
+	{
+		buf[0]=0xC0;
+		buf[1]=0x00;
+		buf[2]=0x02;
+		buf[3]=0x00;
+		buf[4]=0x00;
+		buf[5]=0x00;
+	} else {
+		unsigned char i ; 
+		
+		i = addr->s6_addr[15] & 7 ; 
+		buf[0]=0xC0;
+		buf[1]=0x00;
+		buf[2]=0x00;
+		buf[3]=0x01 << i ; 
+		buf[4]=0x00;
+		buf[5]=0x00;
+	}
+}
 #endif
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)