IPv6SocketAddress.st
author Stefan Vogel <sv@exept.de>
Thu, 11 Jul 2013 13:37:57 +0200
changeset 3050 b60ffb4b201a
parent 3045 7663a852fa0b
child 3053 b5b13e505486
permissions -rw-r--r--
More address type testing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1999 by eXept Software AG
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
              All Rights Reserved
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    13
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
    14
IPSocketAddress variableByteSubclass:#IPv6SocketAddress
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:''
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1165
diff changeset
    18
	category:'OS-Sockets'
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!IPv6SocketAddress class methodsFor:'documentation'!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
copyright
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
 COPYRIGHT (c) 1999 by eXept Software AG
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
              All Rights Reserved
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 This software is furnished under a license and may be used
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 hereby transferred.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
documentation
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    Instances of IPv6SocketAddress represent v6 IP socket addresses.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    These consist of a 16byte hostId and a port number.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    44
    Contains
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    45
        2 byte domain AF_INET6  
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    46
        2 byte port
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    47
        4 byte flowInfo
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    48
        16 byte address
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    49
        4 byte scope
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    [author:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
        Claus Gittinger (cg@exept)
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    [see also:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    [instance variables:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    [class variables:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
! !
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    62
!IPv6SocketAddress class methodsFor:'addressing'!
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    63
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    64
anyAddress
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    65
    "return the anonymous addresses bytes"
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    66
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    67
    ^ #[0 0 0 0  0 0 0 0  0 0 0 0  0 0 0 0]
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    68
!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    69
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    70
broadcastAddress
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    71
    "return the addresses bytes of a broadcast address
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
    72
     (this is the all-nodes link-local address ff02::1.
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    73
     Broadcast is not normally used in IPv6"
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    74
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
    75
    ^ #[16rff 16r02 0 0  0 0 0 0  0 0 0 0  0 0 0 16r01]
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    76
!
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
    77
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    78
local
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    79
    "return the addresses bytes addressing the local host"
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    80
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    81
    ^ #[0 0 0 0  0 0 0 0  0 0 0 0  0 0 0 1]
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    82
! !
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    83
1559
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    84
!IPv6SocketAddress class methodsFor:'conversion'!
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    85
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    86
hostAddressFromString:aString 
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    87
    "convert an address given in a dot notation like 1:2:3:4:5:6:7:8 or ::1 or even ::"
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    88
    
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    89
    |components words bytes prevWord bytesToGenerate i|
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    90
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    91
    components := aString asCollectionOfSubstringsSeparatedBy:$:.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    92
    components size > 8 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    93
        ^ NameLookupError raiseRequestWith:aString
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    94
            errorString:' - bad address string'.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    95
    ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    96
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    97
    (components last occurrencesOf:$.) == 3 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    98
        "IPV4 address embedded"
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
    99
        bytes := IPSocketAddress hostAddressFromString:components removeLast.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   100
        components add:(((bytes at:1) bitShift:8) bitOr:(bytes at:2)).
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   101
        components add:(((bytes at:3) bitShift:8) bitOr:(bytes at:4)) .
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   102
    ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   103
    words := components 
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   104
                collect:[:eachComponent | 
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   105
                    eachComponent size == 0 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   106
                        eachComponent isInteger ifTrue:[eachComponent] ifFalse:[nil].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   107
                    ] ifFalse:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   108
                        Integer 
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   109
                            readFromString:eachComponent
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   110
                            radix:16
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   111
                            onError:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   112
                                ^ NameLookupError raiseRequestWith:aString
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   113
                                    errorString:' - bad address string'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   114
                            ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   115
                    ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   116
                ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   117
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   118
    bytes := ByteArray new:16.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   119
    bytesToGenerate := 2 * (8 - words size).
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   120
    i := 1.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   121
    words do:[:eachWord|
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   122
        eachWord == nil ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   123
            i ~~ 1 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   124
                i := i + bytesToGenerate.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   125
                bytesToGenerate := 0.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   126
            ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   127
        ] ifFalse:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   128
            bytes at:i put:(eachWord digitByteAt:2).
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   129
            bytes at:i+1 put:(eachWord digitByteAt:1).
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   130
        ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   131
        i := i + 2.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   132
        prevWord := eachWord.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   133
    ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   134
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   135
    ^ bytes.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   136
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   137
    "
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   138
        IPv6SocketAddress hostAddressFromString:'::'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   139
        IPv6SocketAddress hostAddressFromString:'::1'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   140
        IPv6SocketAddress hostAddressFromString:':1:2'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   141
        IPv6SocketAddress hostAddressFromString:'1::2'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   142
        IPv6SocketAddress hostAddressFromString:'1:2:3:4:5:6:7:8'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   143
        IPv6SocketAddress hostAddressFromString:'1234:5678:9abc:def1:2345:6789:abcd:ef12'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   144
        IPv6SocketAddress hostAddressFromString:'a:b:c:d:e:f:7:8'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   145
        IPv6SocketAddress hostAddressFromString:'1::2:3:4'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   146
        IPv6SocketAddress hostAddressFromString:'1:2:3::4'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   147
        IPv6SocketAddress hostAddressFromString:'::1.2.3.4'
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   148
    "
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   149
! !
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   150
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   151
!IPv6SocketAddress class methodsFor:'queries'!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
   152
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   153
domainSymbol
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
   154
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   155
    ^ #'AF_INET6'
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   156
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   157
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   158
hostAddressLen
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   159
    "answer the number of bytes of the host address"
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   160
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   161
    ^ 16
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   162
!
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   163
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
   164
obsoleteDomainSymbol
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
   165
    ^ #inet6
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
! !
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   168
!IPv6SocketAddress methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   169
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   170
flowInfo
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   171
"/    struct sockaddr_in6 {
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   172
"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   173
"/  2           __u16                   sin6_port;      /* Transport layer port # */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   174
"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   175
"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   176
"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   177
"/ 28   };
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   178
    ^ self unsignedLongAt:5 bigEndian:false.
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   179
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   180
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   181
hostAddress
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   182
"/    struct sockaddr_in6 {
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   183
"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   184
"/  2           __u16                   sin6_port;      /* Transport layer port # */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   185
"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   186
"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   187
"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   188
"/ 28   };
1559
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   189
    ^ (ByteArray new:16) replaceFrom:1 to:16 with:self startingAt:9
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   190
!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   191
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   192
hostAddress:aByteArray
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   193
    ^ self replaceFrom:9 to:9+16-1 with:aByteArray startingAt:1
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   194
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   195
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   196
scopeId
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   197
"/    struct sockaddr_in6 {
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   198
"/  0           unsigned short int      sin6_family;    /* AF_INET6 */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   199
"/  2           __u16                   sin6_port;      /* Transport layer port # */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   200
"/  4           __u32                   sin6_flowinfo;  /* IPv6 flow information */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   201
"/  8           struct in6_addr         sin6_addr;      /* IPv6 address */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   202
"/ 24            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   203
"/ 28   };
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   204
    ^ self unsignedLongAt:25 bigEndian:false.
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   205
! !
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   206
1559
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   207
!IPv6SocketAddress methodsFor:'printing & storing'!
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   208
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   209
printAddressOn:aStream
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   210
    |i1 i2 colons|
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   211
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   212
    colons := 0.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   213
    i1 := self adrBytesStart.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   214
    i2 := i1 + self numAdrBytes - 1.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   215
    i1 to:i2 by:2 do:[:i | 
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   216
        |word|
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   217
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   218
        word := self wordAt:i MSB:true.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   219
        word == 0 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   220
            (colons <= 1 and:[i ~~ (i2-1)]) ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   221
                colons := colons + 1.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   222
                aStream nextPut:$:
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   223
            ]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   224
        ] ifFalse:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   225
            word printOn:aStream base:16.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   226
            i ~~ (i2-1) ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   227
                aStream nextPut:$:.
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   228
                colons >= 2 ifTrue:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   229
                    colons := -20.       "no more $: may be omitted"
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   230
                ] ifFalse:[
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   231
                    colons positive ifTrue:[colons := 1].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   232
                ]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   233
            ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   234
        ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   235
    ].
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   236
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   237
    "
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   238
       String streamContents:[:s | self localHost printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   239
       String streamContents:[:s |(self hostAddress:#[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]) printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   240
       String streamContents:[:s |(self hostAddress:#[1 2 3 4 5 6 7 8 0 0 0 0 0 0 0 0]) printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   241
       String streamContents:[:s |(self hostAddress:#[0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8]) printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   242
       String streamContents:[:s |(self hostAddress:#[0 0 0 0 1 2 3 4 5 6 7 8 0 0 0 0]) printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   243
       String streamContents:[:s |(self hostAddress:#[16r1a 16r1b 0 0 0 0 0 0  0 0 0 0 0 0 0 0]) printAddressOn:s]
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   244
    "
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   245
! !
609a0707ab22 New: #addressString: to create an instance from a numeric string representation like
Stefan Vogel <sv@exept.de>
parents: 1366
diff changeset
   246
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   247
!IPv6SocketAddress methodsFor:'private'!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   248
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   249
adrBytesStart
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   250
    ^ 9
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   251
!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   252
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   253
numAdrBytes
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   254
    ^ 16
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   255
! !
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   256
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   257
!IPv6SocketAddress methodsFor:'queries'!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   258
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   259
networkAddress
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   260
    <resource: #obsolete>
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   261
    ^ self shouldNotImplement
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   262
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   263
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   264
networkClass
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   265
    "IPV6 doesn't know about network classes"
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   266
    <resource: #obsolete>
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   267
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   268
    ^ self shouldNotImplement
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   269
! !
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   270
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   271
!IPv6SocketAddress methodsFor:'testing'!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   272
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   273
isBroadcast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   274
    "answer true, if this is a broadcast address:
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   275
        all node-local nodes: ff01::1
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   276
        all link-local nodes: ff02::1"
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   277
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   278
    ^ (self at:9) == 16rff 
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   279
        and:[((self at:10) bitAnd:16r03) ~~ 0
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   280
        and:[self sameContentsFrom:11 to:24 as:#[0 0 0 0 0 0 0 0 0 0 0 0 0 1] startingAt:1]]
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   281
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   282
    "
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   283
        (self addressString:'ff01::1') isBroadcast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   284
        (self addressString:'ff02::1') isBroadcast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   285
        (self addressString:'ff01::55') isBroadcast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   286
    "
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   287
!
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   288
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   289
isGlobalUnicast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   290
    "answer true, if this address is a global unicast address 
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   291
     in the range 2000::/3"
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   292
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   293
    ^ (self at:9) between:16r20 and:16r3f
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   294
!
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   295
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   296
isIPv6SocketAddress
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   297
    ^ true
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   298
!
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   299
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   300
isLinkLocalUnicast
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   301
    "answer true, if this address is a link local unicast address fe80::/10"
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   302
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   303
    ^ (self at:9) == 16rfe and:[((self at:10) bitAnd:16rc0) == 16r80]
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   304
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   305
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   306
isLocal
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   307
    "answer true, if this address adresses a peer on the same host: ::1/128"
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   308
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   309
    ^ (self at:9) == 0 and:[self hostAddress = self class local]
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   310
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   311
    "
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   312
        self localHost isLocal
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   313
    "
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   314
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   315
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   316
isMulticast
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   317
    "answer true, if this address is a multicast address ff::/8"
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   318
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   319
    ^ (self at:9) == 16rff 
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   320
!
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   321
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   322
isUniqueLocalUnicast
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   323
    "answer true, if this address is a unique local unicast (e.g. private) address 
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   324
     in the range fc::/8 or fd::/8"
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   325
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   326
    ^ (self at:9) == 16rfc or:[(self at:9) == 16rfd]
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   327
! !
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   328
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
!IPv6SocketAddress class methodsFor:'documentation'!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
version
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   332
    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.16 2013-07-11 11:37:57 stefan Exp $'
2568
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   333
!
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   334
4b0180395472 added:7 methods
Stefan Vogel <sv@exept.de>
parents: 1559
diff changeset
   335
version_CVS
3050
b60ffb4b201a More address type testing
Stefan Vogel <sv@exept.de>
parents: 3045
diff changeset
   336
    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.16 2013-07-11 11:37:57 stefan Exp $'
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
! !
3045
7663a852fa0b My own address checking
Stefan Vogel <sv@exept.de>
parents: 2568
diff changeset
   338