public class NetBIOSDatagram extends Object
Used for sending/receiving NetBIOS broadcast datagrams that are used for name lookups and registration.
Modifier and Type | Field and Description |
---|---|
static int |
BROADCAST |
static int |
DATAGRAM_ERROR |
static int |
DATAGRAM_QUERY |
static int |
DEFBUFSIZE |
static int |
DIRECT_GROUP |
static int |
DIRECT_UNIQUE |
static int |
FLG_FIRSTPKT |
static int |
FLG_MOREFRAGMENTS |
protected byte[] |
m_buf |
static int |
NB_DATAGRAMID |
static int |
NB_DATAGRAMLEN |
static int |
NB_FLAGS |
static int |
NB_FROMNAME |
static int |
NB_MINLENGTH |
static int |
NB_MINSMBLEN |
static int |
NB_MSGTYPE |
static int |
NB_PKTOFFSET |
static int |
NB_SOURCEIP |
static int |
NB_SOURCEPORT |
static int |
NB_TONAME |
static int |
NB_USERDATA |
static int |
NEGATIVE_RESP |
static int |
POSITIVE_RESP |
Constructor and Description |
---|
NetBIOSDatagram()
NetBIOS Datagram constructor
|
NetBIOSDatagram(byte[] pkt)
Create a new NetBIOS datagram using the specified packet buffer.
|
NetBIOSDatagram(int bufSize)
Create a new NetBIOS datagram with the specified buffer size.
|
Modifier and Type | Method and Description |
---|---|
protected void |
CommonInit()
Common constructor initialization code.
|
byte[] |
getBuffer()
Return the NetBIOS buffer.
|
int |
getDatagramId()
Get the datagram id.
|
int |
getDataLength()
Return the user data length
|
NetBIOSName |
getDestinationName()
Get the datagram destination name.
|
int |
getFlags()
Return the datagram flags value.
|
int |
getLength()
Return the datagram length.
|
int |
getMessageType()
Get the NetBIOS datagram message type.
|
String |
getMessageTypeString()
Return the message type as a string
|
static int |
getNextDatagramId()
Return the next available datagram id.
|
String |
getSourceAddress()
Return the datagram source IP address, as a string
|
byte[] |
getSourceIPAddress()
Return the datagram source IP address.
|
NetBIOSName |
getSourceName()
Get the source NetBIOS name.
|
int |
getSourcePort()
Get the source port/socket for the datagram.
|
boolean |
isSMBData()
Check if the user data is an SMB packet
|
void |
SendDatagram(int dgramTyp,
DatagramSocket sock,
String fromName,
char fromNameType,
String toName,
char toNameType,
byte[] userData,
int userLen,
int userOff)
Send a datagram to the specified NetBIOS name using the supplised datagram socket.
|
void |
SendDatagram(int dgramTyp,
DatagramSocket sock,
String fromName,
String toName,
byte[] userData,
int userLen)
Send a datagram to the specified NetBIOS name using the supplied datagram socket.
|
void |
SendDatagram(int dgramTyp,
String fromName,
char fromNameType,
String toName,
char toNameType,
byte[] userData,
int userLen,
int userOff)
Send a datagram to the specified NetBIOS name using the global NetBIOS datagram socket
|
void |
SendDatagram(int dgramTyp,
String fromName,
char fromNameType,
String toName,
char toNameType,
byte[] userData,
int userLen,
int userOff,
InetAddress addr,
int port)
Send a datagram to the specified NetBIOS name using the global NetBIOS datagram socket
|
void |
SendDatagram(int dgramTyp,
String fromName,
String toName,
byte[] userData,
int userLen)
Send a datagram to the specified NetBIOS name using the global NetBIOS datagram socket
|
void |
setDatagramId(int id)
Set the datagram id.
|
void |
setDestinationName(String name)
Set the datagram destination name.
|
void |
setDestinationName(String name,
char typ)
Set the datagram destination name.
|
void |
setFlags(int flg)
Set the datagram flags value.
|
void |
setLength(int len)
Set the datagram length.
|
void |
setMessageType(int msg)
Set the NetBIOS datagram message type.
|
void |
setSourceIPAddress(byte[] ipaddr)
Set the source IP address for the datagram.
|
void |
setSourceName(String name)
Set the datagram source NetBIOS name.
|
void |
setSourceName(String name,
char typ)
Set the datagram source NetBIOS name.
|
void |
setSourcePort(int port)
Set the source port/socket for the datagram.
|
void |
setUserData(byte[] buf,
int len)
Set the user data portion of the datagram.
|
void |
setUserData(byte[] buf,
int len,
int off)
Set the user data portion of the datagram.
|
public static final int DIRECT_UNIQUE
public static final int DIRECT_GROUP
public static final int BROADCAST
public static final int DATAGRAM_ERROR
public static final int DATAGRAM_QUERY
public static final int POSITIVE_RESP
public static final int NEGATIVE_RESP
public static final int FLG_MOREFRAGMENTS
public static final int FLG_FIRSTPKT
public static final int DEFBUFSIZE
public static final int NB_MSGTYPE
public static final int NB_FLAGS
public static final int NB_DATAGRAMID
public static final int NB_SOURCEIP
public static final int NB_SOURCEPORT
public static final int NB_DATAGRAMLEN
public static final int NB_PKTOFFSET
public static final int NB_FROMNAME
public static final int NB_TONAME
public static final int NB_USERDATA
public static final int NB_MINLENGTH
public static final int NB_MINSMBLEN
protected byte[] m_buf
public NetBIOSDatagram()
public NetBIOSDatagram(byte[] pkt)
pkt
- byte[]public NetBIOSDatagram(int bufSize)
bufSize
- intpublic static final int getNextDatagramId()
public final byte[] getBuffer()
public final int getDatagramId()
public final NetBIOSName getDestinationName()
public final int getFlags()
public final int getLength()
public final int getDataLength()
public final int getMessageType()
public final byte[] getSourceIPAddress()
public final String getSourceAddress()
public final NetBIOSName getSourceName()
public final int getSourcePort()
public final boolean isSMBData()
public final String getMessageTypeString()
public final void SendDatagram(int dgramTyp, String fromName, char fromNameType, String toName, char toNameType, byte[] userData, int userLen, int userOff, InetAddress addr, int port) throws IOException, UnknownHostException
dgramTyp
- Datagram typefromName
- From NetBIOS namefromNameType
- From NetBIOS name type.toName
- To NetBIOS nametoNameType
- To NetBIOS name type.userData
- User data bufferuserLen
- User data length.userOff
- Offset of data within user buffer.addr
- Address to send toport
- Port to send toIOException
- Error occurred sending datagramUnknownHostException
- Failed to generate the broadcast mask for the networkpublic final void SendDatagram(int dgramTyp, String fromName, char fromNameType, String toName, char toNameType, byte[] userData, int userLen, int userOff) throws IOException, UnknownHostException
dgramTyp
- Datagram typefromName
- From NetBIOS namefromNameType
- From NetBIOS name type.toName
- To NetBIOS nametoNameType
- To NetBIOS name type.userData
- User data bufferuserLen
- User data length.userOff
- Offset of data within user buffer.IOException
- Error occurred sending datagramUnknownHostException
- Failed to generate the broadcast mask for the networkpublic final void SendDatagram(int dgramTyp, String fromName, String toName, byte[] userData, int userLen) throws IOException, UnknownHostException
dgramTyp
- Datagram typefromName
- From NetBIOS nametoName
- To NetBIOS nameuserData
- User data bufferuserLen
- User data length.IOException
- Error occurred sending datagramUnknownHostException
- Failed to generate the broadcast mask for the networkpublic final void SendDatagram(int dgramTyp, DatagramSocket sock, String fromName, char fromNameType, String toName, char toNameType, byte[] userData, int userLen, int userOff) throws IOException
dgramTyp
- Datagram typesock
- Datagram socket to use to send the datagram packet.fromName
- From NetBIOS namefromNameType
- From NetBIOS name type.toName
- To NetBIOS nametoNameType
- To NetBIOS name type.userData
- User data bufferuserLen
- User data length.userOff
- Offset of data within user buffer.IOException
- The exception description.public final void SendDatagram(int dgramTyp, DatagramSocket sock, String fromName, String toName, byte[] userData, int userLen) throws IOException
fromName
- java.lang.StringtoName
- java.lang.StringuserData
- byte[]userLen
- intIOException
- The exception description.public final void setDatagramId(int id)
id
- intpublic final void setDestinationName(String name)
name
- java.lang.Stringpublic final void setDestinationName(String name, char typ)
name
- java.lang.Stringpublic final void setFlags(int flg)
flg
- intpublic final void setLength(int len)
len
- intpublic final void setMessageType(int msg)
msg
- intpublic final void setSourceIPAddress(byte[] ipaddr)
ipaddr
- byte[]public final void setSourceName(String name)
name
- java.lang.Stringpublic final void setSourceName(String name, char typ)
name
- java.lang.Stringpublic final void setSourcePort(int port)
port
- intpublic final void setUserData(byte[] buf, int len)
buf
- byte[]len
- intpublic final void setUserData(byte[] buf, int len, int off)
buf
- User data bufferlen
- Length of user dataoff
- Offset to start of data within buffer.protected final void CommonInit()
Copyright © 2005–2018 Alfresco Software. All rights reserved.