|
Listing 3.2 SMBtrans Messages
#define BROWSE_REQUEST_ELECTION 0x08
static smb_Transaction_Request TReqs[1];
static const ushort MailSlotSetup[3]
= { 0x0001, 0x0001, 0x0002 };
static const uchar *MailSlotName
= "\\MAILSLOT\\BROWSE";
int ElectionRequest( uchar *bufr,
int bSize,
ulong Criteria,
ulong Uptime,
uchar *ServerName)
/* ---------------------------------------------------- **
* Marshal an Election Request record.
*
* Returns the number of bytes used.
* ---------------------------------------------------- **
*/
{
size_t len;
uchar buildData[32];
/* Initialize the TReqs block.
*/
(void)memset( TReqs, 0, sizeof(smb_Transaction_Request) );
TReqs->SetupCount = 3;
TReqs->Setup = MailSlotSetup;
TReqs->Name = MailSlotName;
/* Build the Browser message in 'buildData'.
*/
(void)memset( buildData, '\0', 32 );
buildData[0] = BROWSE_REQUEST_ELECTION;
len = 15;
/* If the ServerName is empty, assume that the
* request is for a zero-filled election message.
* Otherwise, fill in the rest of the message.
*/
if( NULL != ServerName && '\0' != *ServerName )
{
buildData[1] = 1; /* Version. */
smb_SetLong( buildData, 2, Criteria ); /* Criteria. */
smb_SetLong( buildData, 6, Uptime ); /* Uptime. */
/* Skip 4 reserved bytes. */
/* Copy the ServerName, and make sure there's a nul.
* Count the nul in the total.
*/
(void)strncpy( &(buildbufr[15]), ServerName, 15 );
bufr[31] = '\0';
len += 1 + strlen( &(buildbufr[15]) );
}
/* Finish filling in the transaction request structure.
*/
TReqs->TotalDataCount = (ushort)len;
TReqs->Data = buildData;
/* Write the transaction into the buffer.
* Return the transaction message size.
*/
len = smb_TransRequest( bufr, bSize, TReqs );
return( len );
} /* ElectionRequest */
$Revision: 1.2 $
$Date: 2003/05/28 20:17:40 $
|
Copyright © 1999-2003 Christopher R. Hertel
Released under the terms of the
LGPL
|
|