152 } |
152 } |
153 } |
153 } |
154 |
154 |
155 /* SCTP_PRIMARY_ADDR */ |
155 /* SCTP_PRIMARY_ADDR */ |
156 void sctpPrimaryAddr() throws IOException { |
156 void sctpPrimaryAddr() throws IOException { |
157 SocketAddress addrToSet = null; |
|
158 ByteBuffer buffer = ByteBuffer.allocate(Util.SMALL_BUFFER); |
157 ByteBuffer buffer = ByteBuffer.allocate(Util.SMALL_BUFFER); |
159 |
158 |
160 System.out.println("TESTING SCTP_PRIMARY_ADDR"); |
159 System.out.println("TESTING SCTP_PRIMARY_ADDR"); |
161 |
160 |
162 /* create listening channel */ |
161 /* create listening channel */ |
187 check(!associations.isEmpty(),"There should be some associations"); |
186 check(!associations.isEmpty(),"There should be some associations"); |
188 Association assoc = associations.iterator().next(); |
187 Association assoc = associations.iterator().next(); |
189 |
188 |
190 SctpChannel peerChannel = ssc.accept(); |
189 SctpChannel peerChannel = ssc.accept(); |
191 ssc.close(); |
190 ssc.close(); |
192 Set<SocketAddress> peerAddrs = peerChannel.getAllLocalAddresses(); |
191 Set<SocketAddress> remoteAddresses = smc.getRemoteAddresses(assoc); |
193 debug("Peer local Addresses: "); |
192 debug("Remote Addresses: "); |
194 for (Iterator<SocketAddress> it = peerAddrs.iterator(); it.hasNext(); ) { |
193 for (Iterator<SocketAddress> it = remoteAddresses.iterator(); it.hasNext(); ) { |
195 InetSocketAddress addr = (InetSocketAddress)it.next(); |
194 InetSocketAddress addr = (InetSocketAddress)it.next(); |
196 debug("\t" + addr); |
195 debug("\t" + addr); |
197 addrToSet = addr; // any of the peer addresses will do! |
|
198 } |
196 } |
199 |
197 |
200 /* retrieval of SCTP_PRIMARY_ADDR is not supported on Solaris */ |
198 /* retrieval of SCTP_PRIMARY_ADDR is not supported on Solaris */ |
201 if ("SunOS".equals(osName)) { |
199 if ("SunOS".equals(osName)) { |
202 /* For now do not set this option. There is a bug on Solaris 10 pre Update 5 |
200 /* For now do not set this option. There is a bug on Solaris 10 pre Update 5 |
205 //smc.setOption(SCTP_PRIMARY_ADDR, addrToSet, assoc); |
203 //smc.setOption(SCTP_PRIMARY_ADDR, addrToSet, assoc); |
206 return; |
204 return; |
207 } else { /* Linux */ |
205 } else { /* Linux */ |
208 SocketAddress primaryAddr = smc.getOption(SCTP_PRIMARY_ADDR, assoc); |
206 SocketAddress primaryAddr = smc.getOption(SCTP_PRIMARY_ADDR, assoc); |
209 System.out.println("SCTP_PRIMARY_ADDR returned: " + primaryAddr); |
207 System.out.println("SCTP_PRIMARY_ADDR returned: " + primaryAddr); |
210 /* Verify that this is one of the peer addresses */ |
208 /* Verify that this is one of the remote addresses */ |
211 boolean found = false; |
209 check(remoteAddresses.contains(primaryAddr), "SCTP_PRIMARY_ADDR returned bogus address!"); |
212 addrToSet = primaryAddr; // may not have more than one addr |
210 |
213 for (Iterator<SocketAddress> it = peerAddrs.iterator(); it.hasNext(); ) { |
211 for (Iterator<SocketAddress> it = remoteAddresses.iterator(); it.hasNext(); ) { |
214 InetSocketAddress addr = (InetSocketAddress)it.next(); |
212 InetSocketAddress addrToSet = (InetSocketAddress) it.next(); |
215 if (addr.equals(primaryAddr)) { |
213 System.out.println("SCTP_PRIMARY_ADDR try set to: " + addrToSet); |
216 found = true; |
214 smc.setOption(SCTP_PRIMARY_ADDR, addrToSet, assoc); |
217 } |
215 System.out.println("SCTP_PRIMARY_ADDR set to : " + addrToSet); |
218 addrToSet = addr; |
216 primaryAddr = smc.getOption(SCTP_PRIMARY_ADDR, assoc); |
219 } |
217 System.out.println("SCTP_PRIMARY_ADDR returned : " + primaryAddr); |
220 check(found, "SCTP_PRIMARY_ADDR returned bogus address!"); |
218 check(addrToSet.equals(primaryAddr), "SCTP_PRIMARY_ADDR not set correctly"); |
221 |
219 } |
222 System.out.println("Try SCTP_PRIMARY_ADDR set to: " + addrToSet); |
220 } |
223 smc.setOption(SCTP_PRIMARY_ADDR, addrToSet, assoc); |
221 smc.close(); |
224 System.out.println("SCTP_PRIMARY_ADDR set to: " + addrToSet); |
222 peerChannel.close(); |
225 primaryAddr = smc.getOption(SCTP_PRIMARY_ADDR, assoc); |
|
226 System.out.println("SCTP_PRIMARY_ADDR returned: " + primaryAddr); |
|
227 check(addrToSet.equals(primaryAddr),"SCTP_PRIMARY_ADDR not set correctly"); |
|
228 } |
|
229 } |
223 } |
230 |
224 |
231 class SOTNotificationHandler extends AbstractNotificationHandler<Object> |
225 class SOTNotificationHandler extends AbstractNotificationHandler<Object> |
232 { |
226 { |
233 boolean receivedCommUp; // false |
227 boolean receivedCommUp; // false |