Example #1
0
    void secure_session_test(){
      std::string mes("the test message");
      callback client_callbacks;
      std::string client_id("client");
      std::string server_id("server");
      
      themispp::secure_session_t client(std::vector<uint8_t>(client_id.c_str(), client_id.c_str()+client_id.length()), std::vector<uint8_t>(client_priv, client_priv+sizeof(client_priv)), &client_callbacks);

      callback server_callbacks;
      themispp::secure_session_t server(std::vector<uint8_t>(server_id.c_str(), server_id.c_str()+server_id.length()), std::vector<uint8_t>(server_priv, server_priv+sizeof(server_priv)), &server_callbacks);

      std::vector<uint8_t> control_msg1=client.init();
      std::vector<uint8_t> control_msg2=server.unwrap(control_msg1);
      std::vector<uint8_t> control_msg3=client.unwrap(control_msg2);
      std::vector<uint8_t> control_msg4=server.unwrap(control_msg3);
      std::vector<uint8_t> control_msg5=client.unwrap(control_msg4);
      sput_fail_unless(server.is_established(), "server ready", __LINE__);
      sput_fail_unless(client.is_established(), "client ready", __LINE__);

      std::vector<uint8_t> msg1=client.wrap(std::vector<uint8_t>(mes.c_str(), mes.c_str()+mes.length()+1));
      std::vector<uint8_t> msg2=server.unwrap(msg1);
      sput_fail_unless(strcmp(mes.c_str(), (const char*)(&msg2[0]))==0, "server get message", __LINE__);

      std::vector<uint8_t> msg3=server.wrap(std::vector<uint8_t>(mes.c_str(), mes.c_str()+mes.length()+1));
      std::vector<uint8_t> msg4=client.unwrap(msg3);
      sput_fail_unless(strcmp(mes.c_str(), (const char*)(&msg4[0]))==0, "client get message", __LINE__);
    }
static struct vivante_dri_wait *
new_wait_info(ClientPtr client, DrawablePtr draw, enum event_type type)
{
	struct vivante_dri_wait *wait = calloc(1, sizeof *wait);

	if (wait) {
		wait->drawable_id = draw->id;
		wait->client = client;
		wait->type = type;

		xorg_list_init(&wait->client_list);
		xorg_list_init(&wait->drawable_list);

		if (!add_reslist(wait_drawable_restype, draw->id,
				 &wait->drawable_list) ||
		    !add_reslist(wait_client_restype, client_id(client),
				 &wait->client_list)) {
			xorg_list_del(&wait->client_list);
			xorg_list_del(&wait->drawable_list);
			free(wait);
			wait = NULL;
		}
	}
	return wait;
}
Example #3
0
int server::process_message(const std::string& link,
	const std::vector<char>& data)
{
	std::string client_id(link.substr(0, USER_ID_LEN));
	std::map<std::string, server_connection*>::iterator iter =
		clients_.find(client_id);
	if (iter != clients_.end() && iter->second && iter->second->is_logined())
	{
		Net::send_data(iter->second->get_socket(), (char *) &data[0], data.size());
	}
	else
	{
		//!fixme save data to DB
		//!fixme do something if not logined
	}

	return 0;
}
  void Producer::WriteProduceRequestHeader()
  {
    writer_->WriteInt32(0);  // This will updated later.
    uint16_t produce_request_id = 0;
    writer_->WriteInt16(produce_request_id);

    uint16_t version_id = 0;
    writer_->WriteInt16(version_id);

    uint32_t correlation_id = 0xffffffff;
    writer_->WriteInt32(correlation_id);

    string client_id("");
    // writer_->WriteShortString(client_id);
    writer_->WriteInt16(0);

    // required acks.
    writer_->WriteInt16(num_of_acks_);
    // ack timeout.
    writer_->WriteInt32(0x1f4);

  }
Example #5
0
bool CVSClient::WriteData(void)
{
    CSmallString  client_id("-1");

    if(ActionRequest.GetParameterKeyValue("id",client_id) == false) {
        ES_ERROR("unable to get client id from command specification");
        return(false);
    }

    // is client_id integer?
    if(client_id.IsInt() == false) {
        CSmallString error;
        error << "specified client id '" << client_id << "' is not an integer number";
        ES_ERROR(error);
        return(false);
    }

    CSmallString molid;
    if(ActionRequest.GetParameterKeyValue("molid",molid) == false) {
        ES_ERROR("unable to get molid from command specification");
        return(false);
    }

    // -------------------------------------------

    // create command
    CClientCommand* p_command = CreateCommand(Operation_WriteVSData);
    if(p_command == NULL) return(false);

    // set client ID
    CXMLElement* p_ele = p_command->GetRootCommandElement();
    if(p_ele == NULL) {
        ES_ERROR("unable to get root command element");
        delete p_command;
        return(false);
    }

    bool result = true;
    p_ele->SetAttribute("client_id",client_id);
    p_ele->SetAttribute("molid",molid);

    if(result == false) {
        ES_ERROR("unable to set client_id and/or molid");
        delete p_command;
        return(false);
    }

    if(WriteStructure(p_ele) == false) {
        ES_ERROR("unable to write structure");
        delete p_command;
        return(false);
    }

    // FIXME - try/catch
    ExecuteCommand(p_command);

    if(result == false) {
        ES_ERROR("unable to execute command");
        delete p_command;
        return(false);
    }

    delete p_command;

    return(true);
}