Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Wireless Networking > WSASetService() is returning 10022

Reply
Thread Tools

WSASetService() is returning 10022

 
 
Dandi
Guest
Posts: n/a
 
      04-22-2009
hi all,

I am trying to publish the OBEX object push Service record using
WSASetService(). But the function is failing with the error code 10022.
Without service record i could able to register. But my PDA device is not
dectecting my bluetooth for OPP service.

Could anybody tell me what is wrong in the below code,

/// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

if ( SOCKET_ERROR == ( ulRetCode = getsockname(LocalSocket, (struct
sockaddr *)&SockAddrBthLocal, &iAddrLen) ) )
{
printf("getsockname() call failed w/socket = [0x%X].
WSAGetLastError=[%d]\n", LocalSocket, WSAGetLastError());
goto CleanupAndExit;
}

BYTE jPortNo = *((BYTE *)&SockAddrBthLocal.port);

//
// CSADDR_INFO
//
lpCSAddrInfo[0].LocalAddr.iSockaddrLength = sizeof( SOCKADDR_BTH );
lpCSAddrInfo[0].LocalAddr.lpSockaddr = (LPSOCKADDR)&SockAddrBthLocal;
lpCSAddrInfo[0].RemoteAddr.iSockaddrLength = sizeof( SOCKADDR_BTH );
lpCSAddrInfo[0].RemoteAddr.lpSockaddr = (LPSOCKADDR)&SockAddrBthLocal;
lpCSAddrInfo[0].iSocketType = SOCK_STREAM;
lpCSAddrInfo[0].iProtocol = BTHPROTO_RFCOMM;

//
// If we got an address, go ahead and advertise it.
//
ZeroMemory(&wsaQuerySet, sizeof(WSAQUERYSET));

wsaQuerySet.dwSize = sizeof(WSAQUERYSET);
wsaQuerySet.lpszServiceInstanceName = L"Object Push Profile";
wsaQuerySet.lpServiceClassId = (LPGUID) &g_guidServiceClass;
// wsaQuerySet.lpszComment = L"Example Service instance registered in the
directory service through RnR";
wsaQuerySet.dwNameSpace = NS_BTH;
wsaQuerySet.dwNumberOfCsAddrs = 1; // Must be 1.
wsaQuerySet.lpcsaBuffer = lpCSAddrInfo; // Req'd.

/*
* Note: 0x35
=> Type descriptor is DataElement Sequeunce
=> Size is mentioned in the following 1 byte
*/

static BYTE rgbSdpRecord[] = {
// SDP size
0x35, 0x00, // Note: The size is filled below.

0x09,


// ServiceClassIDList
0x00, 0x01,

// Service Classes
0x35, 0x03, // 3 bytes

// OBEXObjectPush 0x1105
0x19, 0x11, 0x05,

0x09,


// ProtocolDescriptorList
0x00, 0x04,

// Protocol ID List
0x35, 0x11, // 17 bytes


// L2CAP (0x0100)
0x35, 0x03, // 3 bytes
0x19, 0x01, 0x00,

// RFCOMM (0x0003)
0x35, 0x05, // 5 bytes
0x19, 0x00, 0x03, // ID
0x08, jPortNo,

//0x05, // Channel Number is (5)

// OBEX (0x000
0x35, 0x03, // 3 bytes
0x19, 0x00, 0x08,
0x09,


// BluetoothProfileDescriptorList
0x00, 0x09,

0x35, 0x08, // 8 bytes
0x35, 0x06, // 6 bytes
0x19, 0x11, 0x05, // OBEXObjectPush
0x09, 0x01, 0x00, // Version

0x09,

// Service Name
0x01, 0x00,

0x25, 0x13, // Type - String, size - 19 bytes (Object Push Profile)

0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x50, 0x75, 0x73, 0x68, 0x20,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,

0x09,

// Supported Format List
0x03, 0x03,

0x35, 0x0e, // 14 bytes

0x08, 0x01, // vCard 2.1
0x08, 0x02, // vCard 3.0
0x08, 0x03, // vCard 1.0
0x08, 0x04, // iCal 2.0
0x08, 0x05, // vNote
0x08, 0x06, // vMessage
0x08, 0xff // Any type of object
};

const size_t iRecSize = sizeof(rgbSdpRecord) / sizeof(BYTE);

rgbSdpRecord[1] = iRecSize - 2; // -2 for excluding first 2 bytes

BTH_SET_SERVICE *pbthSetService;
HANDLE recordHandle = NULL;
ULONG ulSdpVersion = BTH_SDP_VERSION;

pbthSetService = (BTH_SET_SERVICE *) calloc(sizeof(BTH_SET_SERVICE) +
iRecSize, sizeof(BYTE));

pbthSetService->pRecordHandle = &recordHandle;
pbthSetService->pSdpVersion = &ulSdpVersion;

SET_COD_MAJOR((pbthSetService->fCodService), COD_MAJOR_COMPUTER);
SET_COD_MINOR((pbthSetService->fCodService), COD_COMPUTER_MINOR_DESKTOP);
SET_COD_SERVICE((pbthSetService->fCodService), COD_SERVICE_OBJECT_XFER);

pbthSetService->fCodService = 0x100104;

pbthSetService->ulRecordLength = iRecSize;
memcpy(pbthSetService->pRecord, rgbSdpRecord, iRecSize);

BLOB blob;
blob.cbSize = sizeof(BTH_SET_SERVICE) + iRecSize - 1;
blob.pBlobData = (PBYTE) pbthSetService;

wsaQuerySet.lpBlob = &blob;

//
// As long as we use a blocking accept(), we will have a race
// between advertising the service and actually being ready to
// accept connections. If we use non-blocking accept, advertise
// the service after accept has been called.
//
if ( SOCKET_ERROR == WSASetService(&wsaQuerySet, RNRSERVICE_REGISTER, 0))
{
printf("WSASetService() call failed. WSAGetLastError=[%d]\n",
WSAGetLastError());
goto CleanupAndExit;
}

/// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <

Regards,
Dandi
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
cannot access Internet after returning from standby =?Utf-8?B?REJI?= Wireless Networking 0 10-31-2005 09:21 PM
Returning multiple variables Kwaj VHDL 2 06-07-2004 10:20 AM
WebService – Returning an Object Karuppasamy ASP .Net 0 01-15-2004 04:38 PM
Re: Net::SNMP - returning huge hex for opaque value dna Perl 0 10-20-2003 02:41 PM



Advertisments