virtual google::protobuf::Message* GetAddressMappingOperation(
        const pbrpc::Auth& auth,
        const pbrpc::UserCredentials& user_credentials,
        const google::protobuf::Message& request,
        const char* data,
        uint32_t data_len,
        boost::scoped_array<char>* response_data,
        uint32_t* response_data_len) {
      const addressMappingGetRequest* rq
          = reinterpret_cast<const addressMappingGetRequest*>(&request);

      AddressMappingSet* response = new AddressMappingSet();

      pair<multimap<string,AddressMapping>::iterator,
           multimap<string,AddressMapping>::iterator> ret;
      ret = mappings_.equal_range(rq->uuid());
      for (multimap<string,AddressMapping>::iterator it = ret.first;
           it != ret.second;
           ++it) {
        AddressMapping* mapping = response->add_mappings();
        mapping->CopyFrom(it->second);
      }

      return response;
    }
Esempio n. 2
0
google::protobuf::Message* TestRPCServerDIR::GetAddressMappingOperation(
    const pbrpc::Auth& auth,
    const pbrpc::UserCredentials& user_credentials,
    const google::protobuf::Message& request,
    const char* data,
    uint32_t data_len,
    boost::scoped_array<char>* response_data,
    uint32_t* response_data_len) {
  const addressMappingGetRequest* rq
      = reinterpret_cast<const addressMappingGetRequest*>(&request);

  AddressMappingSet* response = new AddressMappingSet();

  AddressMapping* mapping = response->add_mappings();
  size_t uuid_split_pos = rq->uuid().find_last_of(":");
  mapping->set_uuid(rq->uuid());
  mapping->set_version(0);
  mapping->set_protocol(PBRPCURL::SCHEME_PBRPC);
  mapping->set_address(rq->uuid().substr(0, uuid_split_pos));
  mapping->set_port(atoi(rq->uuid().substr(uuid_split_pos+1).c_str()));
  mapping->set_match_network("*");
  mapping->set_ttl_s(3600);
  mapping->set_uri("");

  return response;
}
  void AddAddressMapping(const std::string& match_network,
                         const std::string& hostname) {
    AddressMapping mapping;
    mapping.set_uuid(kTestUUID_);
    mapping.set_version(0);
    mapping.set_protocol(PBRPCURL::GetSchemePBRPC());
    mapping.set_address(hostname);
    mapping.set_port(kTestPort_);
    mapping.set_match_network(match_network);
    mapping.set_ttl_s(3600);
    mapping.set_uri("");

    dir_->AddMapping(kTestUUID_, mapping);
  }