/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
// DAAdvertiser.java: Advertise a DA, also handle incoming DAAdverts.
// Author: James Kempf
// Created On: Tue May 19 15:22:04 1998
// Last Modified By: James Kempf
// Last Modified On: Thu Mar 4 10:39:06 1999
// Update Count: 44
//
/**
* This class supplies a regular interval 'heartbeat' DAAdvertisement.
* Implementation specific subclasses handle incoming DAAdverts and
* forwarding of registrations and deregistrations to other DAs. The
* implementation specific subclasses depend on how the server is
* representing DA information internally.
*
* @author James Kempf, Erik Guttman
*/
// V2 advertising has the same DAAdvert every time.
new Hashtable(); // Existing advertisers
// Initialize the DAAdvertiser on the designated interface.
throws ServiceLocationException {
// If we've got it, return.
return;
}
// Get the config object.
}
// Get the SLPv2 DAADvert to send
false,
(short)0x0,
config);
// Create a new DAAdvertiser for this interface, with SLPv2
// message to send.
// Start thread running.
}
// Used by V1 subclass constructor.
DAAdvertiser() {
}
}
// Create a new DAAdvertiser for the interface for default multicast
// address. Externalize the message and set the instance variable.
throws ServiceLocationException {
// Config may not be initialized if this was called directly from
// slpd.
}
// Externalize the DAAdvert.
// Initialize the networking for default multicast address.
}
// Convert advert to bytes, initialize networking.
protected void
throws ServiceLocationException {
// Set the interface and multicast address on this advertiser.
// Get the socket from the listener object corresponding to this
// interface. The listener will always be started before the
// DAAdvertiser, otherwise, SAs may start sending registrations
// before anybody is listening.
// If the socket is null, then there is no listener. Open a
// new socket. Note that any listener opened *afterwards* will
// not get this socket.
}
}
public void run() {
// Set the thread name.
setName("SLP DA Advertisement");
while (true) {
// Send an advert.
sendAdvert();
// Sleep until next time.
try {
} catch (InterruptedException ie) {
// Somebody interrupted us. If we are to exit, then do so.
synchronized (done) {
if (done.booleanValue()) {
return;
}
}
}
}
}
// Send an unsolicited DAAdvert.
void sendAdvert() {
new DatagramPacket(buf,
try {
} catch (IOException ex) {
// Tell the listener to refresh the socket.
}
}
// Return the buffer for transmission.
protected byte[] getOutbuf() {
return outbuf;
}
// Stop the thread from executing.
void stopThread() {
synchronized (done) {
}
this.interrupt();
}
}