Merged V2.0 to HEAD

5910: Web Services getUsers
   5913: Web Services admin user password change
   5956: LDAP anon simple bind test
   6133: WCM-486
   6158: Merged V1.4 to V2.0
      5600: Split person bootstrap
      5642: AR-439 NetBIOS adaptor status request
   6160: VersionHistoryPerformance patch with no versionedNodeId


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6166 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-07-04 16:03:31 +00:00
parent 8eeba59f55
commit 25411a888b
7 changed files with 373 additions and 18 deletions

View File

@@ -85,6 +85,10 @@ public class NetBIOSName
public static final String SMBServer = "*SMBSERVER";
public static final String SMBServer2 = "*SMBSERV";
// Adapter status request name
public static final String AdapterStatusName = "*";
// Default time to live for name registrations
public static final int DefaultTTL = 28800; // 8 hours

View File

@@ -114,14 +114,23 @@ public class NetBIOSPacket
public static final int ACT_ERR = 0x06;
public static final int CFT_ERR = 0x07;
// Name flags
public static final int NAME_PERM = 0x02;
public static final int NAME_ACTIVE = 0x04;
public static final int NAME_CONFLICT = 0x08;
public static final int NAME_DEREG = 0x10;
public static final int NAME_GROUP = 0x80;
// Name flags
public static final int NAME_PERM = 0x0200;
public static final int NAME_ACTIVE = 0x0400;
public static final int NAME_CONFLICT = 0x0800;
public static final int NAME_DEREG = 0x1000;
public static final int NAME_GROUP = 0x8000;
public static final int NAME_TYPE_BNODE = 0x0000;
public static final int NAME_TYPE_PNODE = 0x2000;
public static final int NAME_TYPE_MNODE = 0x4000;
public static final int NAME_TYPE_RESVD = 0x6000;
// Adapter status name in encoded format
private static final String AdapterStatusNBName = "CKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
// NetBIOS packet buffer
private byte[] m_nbbuf;
@@ -1252,4 +1261,75 @@ public class NetBIOSPacket
return pos;
}
/**
* Build an adapter status response
*
* @param nameList NetBIOSNameList
* @param int nodeType
* @return int
*/
public final int buildAdapterStatusResponse(NetBIOSNameList nameList, int nodeType) {
// Fill in the header
setOpcode(NetBIOSPacket.RESP_QUERY);
setFlags(NetBIOSPacket.FLG_RECURSDES + NetBIOSPacket.FLG_AUTHANSWER);
setQuestionCount(0);
setAnswerCount(1);
setAdditionalCount(0);
setNameServiceCount(0);
// Pack the encoded adapter status name into the NetBIOS packet
int pos = NB_DATA;
m_nbbuf [ pos++] = ( byte) NAME_LEN;
pos = DataPacker.putString( AdapterStatusNBName, m_nbbuf, pos, true);
// Set the name type and class
DataPacker.putShort (( short) 0x21, m_nbbuf, pos);
pos += 2;
DataPacker.putShort (( short) 0x01, m_nbbuf, pos);
pos += 2;
pos = setTTL(pos, 10000);
pos = setResourceDataLength(pos, (nameList.numberOfNames() * 18) + 42);
// Pack the names
m_nbbuf[pos++] = (byte) nameList.numberOfNames();
for ( int i = 0; i < nameList.numberOfNames(); i++) {
// Get the current name
NetBIOSName nbName = nameList.getName( i);
// Pack the NetBIOS name and flags
System.arraycopy( nbName.getNetBIOSName(), 0, m_nbbuf, pos, NetBIOSName.NameLength);
pos += NetBIOSName.NameLength;
int flags = nodeType + NAME_ACTIVE;
if ( nbName.isGroupName())
flags += NAME_GROUP;
DataPacker.putShort(( short) flags, m_nbbuf, pos);
pos += 2;
}
// Zero out the statistics, MAC address area
for ( int i = 0; i < 42; i++)
m_nbbuf[pos++] = (byte) 0;
// Set the packet length, and return the length
setLength(pos);
return getLength();
}
}

View File

@@ -35,6 +35,7 @@ import java.util.Hashtable;
import java.util.Vector;
import org.alfresco.filesys.netbios.NetBIOSName;
import org.alfresco.filesys.netbios.NetBIOSNameList;
import org.alfresco.filesys.netbios.NetBIOSPacket;
import org.alfresco.filesys.netbios.NetworkSettings;
import org.alfresco.filesys.netbios.RFCNetBIOSProtocol;
@@ -1105,10 +1106,20 @@ public class NetBIOSNameServer extends NetworkServer implements Runnable
char nameType = searchName.charAt(15);
int len = 0;
while (len <= 14 && searchName.charAt(len) != ' ')
len++;
while (len <= 14 && searchName.charAt(len) != ' ' && searchName.charAt(len) != 0)
len++;
searchName = searchName.substring(0, len);
// Check if this is an adapter status request
if ( searchName.equals( NetBIOSName.AdapterStatusName)) {
// Process the adapter status request
processAdapterStatus( pkt, fromAddr, fromPort);
return;
}
// Debug
if (logger.isDebugEnabled())
@@ -1399,6 +1410,50 @@ public class NetBIOSNameServer extends NetworkServer implements Runnable
}
/**
* Process an adapter status request
* @param pkt NetBIOSPacket
* @param fromAddr InetAddress
* @param fromPort int
*/
protected final void processAdapterStatus(NetBIOSPacket pkt, InetAddress fromAddr, int fromPort) {
// Debug
if (logger.isDebugEnabled())
logger.debug("%% Adapter status request");
// Build the local name list
NetBIOSNameList nameList = new NetBIOSNameList();
for ( int i = 0; i < m_localNames.size(); i++)
nameList.addName( m_localNames.get( i));
// Build the name query response
int pktLen = pkt.buildAdapterStatusResponse( nameList, hasPrimaryWINSServer() ? NetBIOSPacket.NAME_TYPE_PNODE : NetBIOSPacket.NAME_TYPE_BNODE);
// Debug
if (logger.isDebugEnabled()) {
logger.debug("%% NetBIOS Reply to " + fromAddr.getHostAddress() + " :-");
pkt.DumpPacket(false);
}
// Send the reply packet
try {
// Send the name query reply
sendPacket(pkt, pktLen, fromAddr, fromPort);
}
catch (java.io.IOException ex) {
if ( logger.isErrorEnabled())
logger.error(ex);
}
}
/**
* Remove a local add name listener from the NetBIOS name server.
*
* @param l AddNameListener