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.Win32NetBIOS; 22 import org.alfresco.filesys.smb.server.win32.Win32NetBIOSSessionSocketHandler; 23 24 32 public class Win32NetBIOSHostAnnouncer extends HostAnnouncer 33 { 34 35 37 Win32NetBIOSSessionSocketHandler m_handler; 38 39 46 public Win32NetBIOSHostAnnouncer(Win32NetBIOSSessionSocketHandler handler, String domain, int intval) 47 { 48 49 51 m_handler = handler; 52 53 55 addHostName(handler.getServerName()); 56 setDomain(domain); 57 setInterval(intval); 58 } 59 60 65 public final int getLana() 66 { 67 return m_handler.getLANANumber(); 68 } 69 70 75 public final int getNameNumber() 76 { 77 return m_handler.getNameNumber(); 78 } 79 80 85 protected void initialize() throws Exception 86 { 87 88 90 setName("Win32HostAnnouncer_L" + getLana()); 91 } 92 93 98 public boolean isNetworkEnabled() 99 { 100 return m_handler.isLANAValid(); 101 } 102 103 111 protected void sendAnnouncement(String hostName, byte[] buf, int offset, int len) throws Exception 112 { 113 114 116 NetBIOSName destNbName = new NetBIOSName(getDomain(), NetBIOSName.MasterBrowser, false); 117 byte[] destName = destNbName.getNetBIOSName(); 118 119 121 int sts = Win32NetBIOS.SendDatagram(getLana(), getNameNumber(), destName, buf, 0, len); 122 if ( sts != NetBIOS.NRC_GoodRet) 123 logger.debug("Win32NetBIOS host announce error " + NetBIOS.getErrorString( -sts)); 124 } 125 } | Popular Tags |