Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java
32301 views
1
/*
2
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
package sun.nio.ch.sctp;
26
27
import java.net.SocketAddress;
28
import com.sun.nio.sctp.Association;
29
import com.sun.nio.sctp.PeerAddressChangeNotification;
30
import java.lang.annotation.Native;
31
32
/**
33
* An implementation of PeerAddressChangeNotification
34
*/
35
public class PeerAddrChange extends PeerAddressChangeNotification
36
implements SctpNotification
37
{
38
/* static final ints so that they can be referenced from native */
39
@Native private final static int SCTP_ADDR_AVAILABLE = 1;
40
@Native private final static int SCTP_ADDR_UNREACHABLE = 2;
41
@Native private final static int SCTP_ADDR_REMOVED = 3;
42
@Native private final static int SCTP_ADDR_ADDED = 4;
43
@Native private final static int SCTP_ADDR_MADE_PRIM = 5;
44
@Native private final static int SCTP_ADDR_CONFIRMED =6;
45
46
private Association association;
47
48
/* assocId is used to lookup the association before the notification is
49
* returned to user code */
50
private int assocId;
51
private SocketAddress address;
52
private AddressChangeEvent event;
53
54
/* Invoked from native */
55
private PeerAddrChange(int assocId, SocketAddress address, int intEvent) {
56
switch (intEvent) {
57
case SCTP_ADDR_AVAILABLE :
58
this.event = AddressChangeEvent.ADDR_AVAILABLE;
59
break;
60
case SCTP_ADDR_UNREACHABLE :
61
this.event = AddressChangeEvent.ADDR_UNREACHABLE;
62
break;
63
case SCTP_ADDR_REMOVED :
64
this.event = AddressChangeEvent.ADDR_REMOVED;
65
break;
66
case SCTP_ADDR_ADDED :
67
this.event = AddressChangeEvent.ADDR_ADDED;
68
break;
69
case SCTP_ADDR_MADE_PRIM :
70
this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
71
break;
72
case SCTP_ADDR_CONFIRMED :
73
this.event = AddressChangeEvent.ADDR_CONFIRMED;
74
break;
75
default:
76
throw new AssertionError("Unknown event type");
77
}
78
this.assocId = assocId;
79
this.address = address;
80
}
81
82
@Override
83
public int assocId() {
84
return assocId;
85
}
86
87
@Override
88
public void setAssociation(Association association) {
89
this.association = association;
90
}
91
92
@Override
93
public SocketAddress address() {
94
assert address != null;
95
return address;
96
}
97
98
@Override
99
public Association association() {
100
assert association != null;
101
return association;
102
}
103
104
@Override
105
public AddressChangeEvent event() {
106
assert event != null;
107
return event;
108
}
109
110
@Override
111
public String toString() {
112
StringBuilder sb = new StringBuilder();
113
sb.append(super.toString()).append(" [");
114
sb.append("Address: ").append(address);
115
sb.append(", Association:").append(association);
116
sb.append(", Event: ").append(event).append("]");
117
return sb.toString();
118
}
119
}
120
121
122