bool SdpParseGetServiceName(const uint8 size_service_record, const uint8* service_record, uint8 size_service_name, char** service_name, uint8* length_service_name)
{
	Region value;
	uint8 k;
	
	/* if found service name field */
	if(findServiceName(size_service_record, service_record, saServiceName, &value))
	{	
		/* read in size of service name string */
		value.end = value.begin;
		value.begin--;
		
		/* Set length_service_name to no. of chars. in service name */
		*length_service_name = (uint8)RegionReadUnsigned(&value);
		
		/* if array has been allocated and field length is valid */
		if(*length_service_name && size_service_name)
		{			
			/* Ensure we dont try to use more memory than has been allocated */
			if(*length_service_name > size_service_name - 1)
				*length_service_name = size_service_name - 1;
			
			/* move to first string element */
			value.begin++;
			value.end = value.begin + 1;
			
			/* copy string element into array and move to next */
			for(k = 0; k < (*length_service_name); k++)
			{
				service_name[0][k] = RegionReadUnsigned(&value);
				value.end++;
			}
			
			/* set null char */
			(*length_service_name)++;
			service_name[0][k] = '\0';
						
			/* Accessed Successfully */
			return TRUE;
		}
	}
	
	/* set return string to "Failed" */
	*length_service_name = 0;
	*service_name = NULL;
	
	/* Failed */
	return FALSE;
}
Ejemplo n.º 2
0
/* Get the supported features from the returned attribute list */
static uint16 getHfpAgSupportedFeatures(const uint8 *begin, const uint8 *end, uint16 *features)
{
 Region value;
    if(findHfpSupportedFeatures(begin, end, &value))
    {
  *features = (uint16) RegionReadUnsigned(&value);
  return 1;
    }
    return 0;
}
Ejemplo n.º 3
0
/* Retrieve the rfcomm server channel */
static uint16 getRfcommChannelNumber(const uint8 *begin, const uint8 *end, uint16 *chan)
{
    Region value;
    if(findRfcommServerChannel(begin, end, &value))
    {
        *chan = (uint16) RegionReadUnsigned(&value);
        return 1;
    }
    return 0;
}
Ejemplo n.º 4
0
bool SdpParseGetPbapRepos(const uint8 size_service_record, const uint8* service_record, uint8* repos)
{
	Region value;
	if(findPbapRepos(size_service_record, service_record, &value))
	{
		*repos = RegionReadUnsigned(&value);
		/* Accessed Successfully */
		return TRUE;
	}
	/* Failed */
	return FALSE;
}
bool SdpParseGetSupportedFeatures(const uint8 size_service_record, const uint8* service_record, uint16* features)
{
	Region value;
    if(findSupportedFeatures(size_service_record, service_record, &value))
    {
		*features = (uint16) RegionReadUnsigned(&value);
		/* Accessed Successfully */
		return TRUE;
    }
	/* Failed */
    return FALSE;
}
Ejemplo n.º 6
0
/****************************************************************************
 * NAME
 *  SdpParseGetMapMasInstance
 * 
 * DESCRIPTION
 * API to access the MAS support message feature. 
 *
 * PARAMETERS
 *  Refer sdp_parse.h
 *
 * RETURNS
 *  TRUE on success with MsgFeature contains the MASInstanceID.
 **************************************************************************/
bool SdpParseGetMapMasMsgFeature( const uint8 size_service_record,
                                  uint8* service_record, 
                                  uint8* msg_feature )
{
	Region value;
	if(findMapMasMsgFeature(size_service_record, service_record, &value))
	{
		*msg_feature = RegionReadUnsigned(&value);
		/* Accessed Successfully */
		return TRUE;
	}
	/* Failed */
	return FALSE;
}
Ejemplo n.º 7
0
/****************************************************************************
 * NAME
 *  SdpParseGetMapMasInstance
 * 
 * DESCRIPTION
 * API to access the MAS instance ID 
 *
 * PARAMETERS
 *  Refer sdp_parse.h
 *
 * RETURNS
 *  TRUE on success with instanceId contains the MASInstanceID.
 **************************************************************************/
bool SdpParseGetMapMasInstance( const uint8 size_service_record,
                                uint8* service_record, 
                                uint8* instance_id )
{
	Region value;
	if(findMapMasInstance(size_service_record, service_record, &value))
	{
		*instance_id = RegionReadUnsigned(&value);
		/* Accessed Successfully */
		return TRUE;
	}
	/* Failed */
	return FALSE;
}
bool SdpParseInsertServiceName(const uint8 size_service_record, const uint8* service_record, char* service_name)
{
	Region value;
	uint8 size_service_name, size_old_service_name, k;
	
	size_service_name= strlen(service_name);
	
	if(size_service_name <= MAX_SIZE_SERVICE_NAME && size_service_name > 0)
	{
		/* if found service name field */
		if(findServiceName(size_service_record, service_record, saServiceName, &value))
		{	
			/* move to size service name value */
			value.end = value.begin;
			value.begin--;
			
			/* read in old value */
			size_old_service_name = RegionReadUnsigned(&value);
			
			if(size_service_name <= size_old_service_name)
			{
				/* move to first string element */
				value.begin++;
				value.end = value.begin + 1;
			
				/* copy string element into array and move to next */
				for(k = 0; k < size_service_name; k++)
				{
					RegionWriteUnsigned(&value, (uint32)service_name[k]);
					value.begin ++;
					value.end ++;
				}
								
				/* fill the rest with spaces */
				for(k = size_service_name; k < size_old_service_name; k++)
				{
					RegionWriteUnsigned(&value, (uint32)' ');
					value.begin++;
					value.end++;
				}
			
				return TRUE;
			}
		}
	}
	/* Failed */
	return FALSE;
}
bool SdpParseGetMultipleRfcommServerChannels(uint8 size_service_record, uint8* service_record, uint8 size_chans, uint8** chans, uint8* chans_found)
{
	Region protocols, value;
	*chans_found = 0;
	
	if(findProtocolDescriptorList(size_service_record, service_record, &protocols))
		while(findServerChannel(&protocols, (uint32) UUID_RFCOMM, &value))
		{					
			/* reset protocols.begin so next search starts from after the channel we just found */
			protocols.begin = value.end;
		
			/* if space in the array then read in value, else break */
			if((*chans_found) < size_chans)
			{
				/* Read in found channel */
				chans[0][*chans_found] = (uint8)RegionReadUnsigned(&value);
				(*chans_found)++;
			}
			else
			{
				break;
			}
    	}
	
	/* If we found any rfcomm channels */
	if(*chans_found)
	{
		/* Accessed Successfully */
		return TRUE;
	}
	else
	{
		/* Failed */
    	return FALSE;
	}
}
Ejemplo n.º 10
0
/* Obtain the profile version number */
static bool getHfpAgProfileVersion(const uint8 *begin, const uint8 *end, uint16 *profile)
{
    Region value;
    if (findProfileVersion(begin, end, &value))
    {
        if (RegionSize(&value) == 2)
        {   
            uint32 profile_version = RegionReadUnsigned(&value);
            
            if ( profile_version==0x0105 )
            {
	            *profile = (uint16)hfp_handsfree_15_profile;
            }
            else
            {	/* Not explicitly declared as v1.5, so assume v1.1 */
	            *profile = (uint16)hfp_handsfree_profile;
            }
            
            return TRUE;
        }
    }

    return FALSE;
}
bool RegionMatchesUUID32(const Region *r, uint32 uuid)
{
    /* Valid sizes are 2, 4, and 16 so this is good enough */
    return RegionReadUnsigned(r) == uuid && (RegionSize(r) != 16 || memcmp(uuid_suffix, r->begin, 12) == 0);
}