예제 #1
0
bool
SipccSdpAttributeList::LoadGroups(sdp_t* sdp, uint16_t level,
                                  SdpErrorHolder& errorHolder)
{
  uint16_t attrCount = 0;
  if (sdp_attr_num_instances(sdp, level, 0, SDP_ATTR_GROUP, &attrCount) !=
      SDP_SUCCESS) {
    MOZ_ASSERT(false, "Could not get count of group attributes");
    errorHolder.AddParseError(0, "Could not get count of group attributes");
    return false;
  }

  UniquePtr<SdpGroupAttributeList> groups = MakeUnique<SdpGroupAttributeList>();
  for (uint16_t attr = 1; attr <= attrCount; ++attr) {
    SdpGroupAttributeList::Semantics semantics;
    std::vector<std::string> tags;

    switch (sdp_get_group_attr(sdp, level, 0, attr)) {
      case SDP_GROUP_ATTR_FID:
        semantics = SdpGroupAttributeList::kFid;
        break;
      case SDP_GROUP_ATTR_LS:
        semantics = SdpGroupAttributeList::kLs;
        break;
      case SDP_GROUP_ATTR_ANAT:
        semantics = SdpGroupAttributeList::kAnat;
        break;
      case SDP_GROUP_ATTR_BUNDLE:
        semantics = SdpGroupAttributeList::kBundle;
        break;
      default:
        continue;
    }

    uint16_t idCount = sdp_get_group_num_id(sdp, level, 0, attr);
    for (uint16_t id = 1; id <= idCount; ++id) {
      const char* idStr = sdp_get_group_id(sdp, level, 0, attr, id);
      if (!idStr) {
        std::ostringstream os;
        os << "bad a=group identifier at " << (attr - 1) << ", " << (id - 1);
        errorHolder.AddParseError(0, os.str());
        return false;
      }
      tags.push_back(std::string(idStr));
    }
    groups->PushEntry(semantics, tags);
  }

  if (!groups->mGroups.empty()) {
    SetAttribute(groups.release());
  }

  return true;
}
예제 #2
0
int svcBrowse(uuid_t *groupToExtract)
{
	int 		status = -1, i;
	uint16_t	count = 0;
	slist_t		*searchList = NULL;
	slist_t		*attrIdList = NULL;
	slist_t		*svcRecList = NULL;
	sdpsvc_t	*svcRec;

	s_list_append(&searchList, groupToExtract);
	s_list_append_uint(&attrIdList, 0x0000ffff);
	status = sdp_search_attr_req(srvHandle, searchList, 
			RangeOfAttributes, attrIdList, 0xFFFF, &svcRecList, &count);
	s_list_free(&attrIdList);
	s_list_free(&searchList);
	//printf("Status : %d Count : %d, list: %d\n", status, count, s_list_length(svcRecList));
	
	if (status || count == 0)
		return status;

	for (i = 0; i < s_list_length(svcRecList); i++) {
		printf("==============================\n");

		svcRec = (sdpsvc_t *)s_list_nth_data(svcRecList, i);
		print_info_attr(svcRec);
		printf("------------------------------\n");

		printf("SvcRecHdl: 0x%x\n", svcRec->serviceRecordHandle);

		if (!verboseflag) {
			print_svc_class(svcRec);
			print_access_proto(svcRec);
			print_profile_desc(svcRec);
			print_group(svcRec);
		} else {
			// print detailed info
		}

		if (sdp_is_group(svcRec)) {
			uuid_t	*groupId;

			// printf("SvcRec : 0x%x is a group\n", svcRecHandle);
			printf("This is a group.\n");
			groupId = sdp_get_group_attr(svcRec);
			printf("  0x%s\n", sdp_uuid2str(groupId));
			if (sdp_uuidcmp(groupId, groupToExtract) != 0) {
				printf("Extracting it\n");
				svcBrowse(groupId);
			}
		}
	}
	sdp_free_svclist(&svcRecList);
	return status;
}