IPv6SocketAddress.st
author Stefan Vogel <sv@exept.de>
Fri, 28 Nov 2003 12:18:01 +0100
changeset 1366 e01d0f6c102a
parent 1281 6df4f8f211e3
child 1559 609a0707ab22
permissions -rw-r--r--
New method #isLocal returning true for local addresses
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
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    15
"{ Package: 'stx:libbasic2' }"
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    16
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
    17
IPSocketAddress variableByteSubclass:#IPv6SocketAddress
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	instanceVariableNames:''
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	classVariableNames:''
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	poolDictionaries:''
1167
56c172bc5cfe Category change
Stefan Vogel <sv@exept.de>
parents: 1165
diff changeset
    21
	category:'OS-Sockets'
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
!IPv6SocketAddress class methodsFor:'documentation'!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
copyright
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 COPYRIGHT (c) 1999 by eXept Software AG
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
              All Rights Reserved
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 This software is furnished under a license and may be used
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 only in accordance with the terms of that license and with the
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 be provided or otherwise made available to, or used by, any
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 other person.  No title to or ownership of the software is
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
 hereby transferred.
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
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
documentation
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    Instances of IPv6SocketAddress represent v6 IP socket addresses.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    These consist of a 16byte hostId and a port number.
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    47
    Contains
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    48
        2 byte domain AF_INET6  
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    49
        2 byte port
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    50
        4 byte flowInfo
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    51
        16 byte address
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    52
        4 byte scope
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    [author:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
        Claus Gittinger (cg@exept)
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    [see also:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    [instance variables:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    [class variables:]
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
"
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
! !
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
1281
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    65
!IPv6SocketAddress class methodsFor:'addressing'!
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
anyAddress
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    68
    "return the anonymous addresses bytes"
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    69
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    70
    ^ #[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
    71
!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    72
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    73
local
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    74
    "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
    75
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
    76
    ^ #[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
    77
! !
6df4f8f211e3 fixed anyHost
Claus Gittinger <cg@exept.de>
parents: 1262
diff changeset
    78
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    79
!IPv6SocketAddress class methodsFor:'queries'!
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
    80
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    81
domainSymbol
818
2f8331ad12d4 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 815
diff changeset
    82
1226
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
    83
    ^ #'AF_INET6'
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
    84
!
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
    85
0114bd044aa9 vw compatible domainSymbols (afXXX)
Claus Gittinger <cg@exept.de>
parents: 1167
diff changeset
    86
obsoleteDomainSymbol
1162
c8ba14f81f13 Prepare new socketb implementation
Stefan Vogel <sv@exept.de>
parents: 818
diff changeset
    87
    ^ #inet6
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
! !
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
1231
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    90
!IPv6SocketAddress methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    91
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    92
hostAddress
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    93
"/    struct sockaddr_in6 {
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    94
"/            unsigned short int      sin6_family;    /* AF_INET6 */
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    95
"/            __u16                   sin6_port;      /* Transport layer port # */
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    96
"/            __u32                   sin6_flowinfo;  /* IPv6 flow information */
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    97
"/            struct in6_addr         sin6_addr;      /* IPv6 address */
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    98
"/            __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
    99
"/    };
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   100
    ^ (ByteArray new:16) replaceFrom:1 with:self startingAt:9
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   101
!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   102
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   103
hostAddress:aByteArray
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   104
    ^ self replaceFrom:9 to:9+16-1 with:aByteArray startingAt:1
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   105
! !
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   106
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   107
!IPv6SocketAddress methodsFor:'private'!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   108
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   109
adrBytesStart
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   110
    ^ 9
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   111
!
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   112
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   113
numAdrBytes
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   114
    ^ 16
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   115
! !
Claus Gittinger <cg@exept.de>
parents: 1228
diff changeset
   116
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   117
!IPv6SocketAddress methodsFor:'testing'!
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   118
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   119
isLocal
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   120
    "answer true, if this address adresses a peer on the same host"
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   121
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   122
    ^ self hostAddress = self class local
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   123
! !
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   124
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
!IPv6SocketAddress class methodsFor:'documentation'!
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
version
1366
e01d0f6c102a New method #isLocal returning true for local addresses
Stefan Vogel <sv@exept.de>
parents: 1281
diff changeset
   128
    ^ '$Header: /cvs/stx/stx/libbasic2/IPv6SocketAddress.st,v 1.12 2003-11-28 11:17:38 stefan Exp $'
815
cb36489446b2 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
! !