added:7 methods
authorStefan Vogel <sv@exept.de>
Thu, 12 May 2011 13:54:47 +0200
changeset 2568 4b0180395472
parent 2567 b2820eb56b6a
child 2569 abfbf6f1682b
added:7 methods comment/format in: #hostAddress changed: #isLocal
IPv6SocketAddress.st
--- a/IPv6SocketAddress.st	Thu May 12 13:54:27 2011 +0200
+++ b/IPv6SocketAddress.st	Thu May 12 13:54:47 2011 +0200
@@ -9,9 +9,6 @@
  other person.  No title to or ownership of the software is
  hereby transferred.
 "
-
-
-
 "{ Package: 'stx:libbasic2' }"
 
 IPSocketAddress variableByteSubclass:#IPv6SocketAddress
@@ -156,19 +153,41 @@
 
 !IPv6SocketAddress methodsFor:'accessing'!
 
+flowInfo
+"/    struct sockaddr_in6 {
+"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
+"/  2           __u16                   sin6_port;      /* Transport layer port # */
+"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
+"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
+"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
+"/ 28   };
+    ^ self unsignedLongAt:5 bigEndian:false.
+!
+
 hostAddress
 "/    struct sockaddr_in6 {
-"/            unsigned short int      sin6_family;    /* AF_INET6 */
-"/            __u16                   sin6_port;      /* Transport layer port # */
-"/            __u32                   sin6_flowinfo;  /* IPv6 flow information */
-"/            struct in6_addr         sin6_addr;      /* IPv6 address */
-"/            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
-"/    };
+"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
+"/  2           __u16                   sin6_port;      /* Transport layer port # */
+"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
+"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
+"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
+"/ 28   };
     ^ (ByteArray new:16) replaceFrom:1 to:16 with:self startingAt:9
 !
 
 hostAddress:aByteArray
     ^ self replaceFrom:9 to:9+16-1 with:aByteArray startingAt:1
+!
+
+scopeId
+"/    struct sockaddr_in6 {
+"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
+"/  2           __u16                   sin6_port;      /* Transport layer port # */
+"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
+"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
+"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
+"/ 28   };
+    ^ self unsignedLongAt:25 bigEndian:false.
 ! !
 
 !IPv6SocketAddress methodsFor:'printing & storing'!
@@ -221,16 +240,46 @@
     ^ 16
 ! !
 
+!IPv6SocketAddress methodsFor:'queries'!
+
+networkAddress
+    <resource: #obsolete>
+    ^ self shouldNotImplement
+!
+
+networkClass
+    "IPV6 doesn't know about network classes"
+    <resource: #obsolete>
+
+    ^ self shouldNotImplement
+! !
+
 !IPv6SocketAddress methodsFor:'testing'!
 
+isLinkLocalUnicast
+    "answer true, if this address is a link local unicast address fe80::/10"
+
+    ^ (self at:9) == 16rfe and:[((self at:10) bitAnd:16rc0) == 16r80]
+!
+
 isLocal
     "answer true, if this address adresses a peer on the same host"
 
-    ^ self hostAddress = self class local
+    ^ (self at:9) == 0 and:[self hostAddress = self class local]
+!
+
+isMulticast
+    "answer true, if this address is a link local unicast address ff::/8"
+
+    ^ (self at:9) == 16rff 
 ! !
 
 !IPv6SocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.13 2005-06-28 13:10:47 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.14 2011-05-12 11:54:47 stefan Exp $'
+!
+
+version_CVS
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.14 2011-05-12 11:54:47 stefan Exp $'
 ! !