1 17 package org.alfresco.filesys.smb.mailslot; 18 19 import org.alfresco.filesys.netbios.NetBIOSName; 20 import org.alfresco.filesys.netbios.win32.NetBIOS; 21 import org.alfresco.filesys.netbios.win32.NetBIOSSocket; 22 import org.alfresco.filesys.netbios.win32.Win32NetBIOS; 23 import org.alfresco.filesys.smb.server.win32.Win32NetBIOSSessionSocketHandler; 24 25 35 public class WinsockNetBIOSHostAnnouncer extends HostAnnouncer 36 { 37 39 private Win32NetBIOSSessionSocketHandler m_handler; 40 41 43 private NetBIOSSocket m_dgramSocket; 44 45 52 public WinsockNetBIOSHostAnnouncer(Win32NetBIOSSessionSocketHandler handler, String domain, int intval) 53 { 54 55 57 m_handler = handler; 58 59 61 addHostName(handler.getServerName()); 62 setDomain(domain); 63 setInterval(intval); 64 } 65 66 71 public final int getLana() 72 { 73 return m_handler.getLANANumber(); 74 } 75 76 81 protected void initialize() throws Exception 82 { 83 85 setName("WinsockHostAnnouncer_L" + getLana()); 86 87 89 m_dgramSocket = NetBIOSSocket.createDatagramSocket(getLana()); 90 } 91 92 97 public boolean isNetworkEnabled() 98 { 99 return m_handler.isLANAValid(); 100 } 101 102 110 protected void sendAnnouncement(String hostName, byte[] buf, int offset, int len) throws Exception 111 { 112 113 115 NetBIOSName destNbName = new NetBIOSName(getDomain(), NetBIOSName.MasterBrowser, false); 116 117 119 int sts = m_dgramSocket.sendDatagram(destNbName, buf, 0, len); 120 if ( sts != len) 121 logger.debug("WinsockNetBIOS host announce error"); 122 } 123 } | Popular Tags |