本文整理汇总了C++中put_uint32函数的典型用法代码示例。如果您正苦于以下问题:C++ put_uint32函数的具体用法?C++ put_uint32怎么用?C++ put_uint32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put_uint32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ppl_logevent
PktOut *ssh2_portfwd_chanopen(
struct ssh2_connection_state *s, struct ssh2_channel *c,
const char *hostname, int port,
const char *description, const SocketPeerInfo *pi)
{
PacketProtocolLayer *ppl = &s->ppl; /* for ppl_logevent */
PktOut *pktout;
/*
* In server mode, this function is called by portfwdmgr in
* response to PortListeners that were set up by calling
* portfwdmgr_listen, which means that the hostname and port
* parameters will identify the listening socket on which a
* connection just came in.
*/
if (pi && pi->log_text)
ppl_logevent("Forwarding connection to listening port %s:%d from %s",
hostname, port, pi->log_text);
else
ppl_logevent("Forwarding connection to listening port %s:%d",
hostname, port);
pktout = ssh2_chanopen_init(c, "forwarded-tcpip");
put_stringz(pktout, hostname);
put_uint32(pktout, port);
put_stringz(pktout, (pi && pi->addr_text ? pi->addr_text : "0.0.0.0"));
put_uint32(pktout, (pi && pi->port >= 0 ? pi->port : 0));
return pktout;
}
示例2: malloc
void zmq::amqp_marshaller_t::queue_declare_ok (
uint16_t channel_,
const i_amqp::shortstr_t queue_,
uint32_t message_count_,
uint32_t consumer_count_)
{
unsigned char *args = (unsigned char*) malloc (i_amqp::frame_min_size);
assert (args);
size_t offset = 0;
assert (offset + sizeof (uint8_t) + queue_.size <=
i_amqp::frame_min_size);
put_uint8 (args + offset, queue_.size);
offset += sizeof (uint8_t);
memcpy (args + offset, queue_.data, queue_.size);
offset += queue_.size;
assert (offset + sizeof (uint32_t) <= i_amqp::frame_min_size);
put_uint32 (args + offset, message_count_);
offset += sizeof (uint32_t);
assert (offset + sizeof (uint32_t) <= i_amqp::frame_min_size);
put_uint32 (args + offset, consumer_count_);
offset += sizeof (uint32_t);
command_t cmd = {
channel_,
i_amqp::queue_id,
i_amqp::queue_declare_ok_id,
args,
offset
};
command_queue.push (cmd);
}
示例3: sftp_alloc_request
/*
* Read from a file. Returns the number of bytes read, or -1 on an
* error, or possibly 0 if EOF. (I'm not entirely sure whether it
* will return 0 on EOF, or return -1 and store SSH_FX_EOF in the
* error indicator. It might even depend on the SFTP server.)
*/
struct sftp_request *fxp_read_send(struct fxp_handle *handle,
uint64_t offset, int len)
{
struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout;
pktout = sftp_pkt_init(SSH_FXP_READ);
put_uint32(pktout, req->id);
put_string(pktout, handle->hstring, handle->hlen);
put_uint64(pktout, offset);
put_uint32(pktout, len);
sftp_send(pktout);
return req;
}
示例4: put_uint32
bool zmq::router_t::identify_peer (pipe_t *pipe_)
{
msg_t msg;
blob_t identity;
bool ok;
if (options.raw_sock) { // Always assign identity for raw-socket
unsigned char buf [5];
buf [0] = 0;
put_uint32 (buf + 1, next_peer_id++);
identity = blob_t (buf, sizeof buf);
unsigned int i = 0; // Store identity to allow use of raw socket as client
for (blob_t::iterator it = identity.begin(); it != identity.end(); it++) options.identity[i++] = *it;
options.identity_size = i;
}
else {
msg.init ();
ok = pipe_->read (&msg);
if (!ok)
return false;
if (msg.size () == 0) {
// Fall back on the auto-generation
unsigned char buf [5];
buf [0] = 0;
put_uint32 (buf + 1, next_peer_id++);
identity = blob_t (buf, sizeof buf);
msg.close ();
}
else {
identity = blob_t ((unsigned char*) msg.data (), msg.size ());
outpipes_t::iterator it = outpipes.find (identity);
msg.close ();
// Ignore peers with duplicate ID.
if (it != outpipes.end ())
return false;
}
}
pipe_->set_identity (identity);
// Add the record into output pipes lookup table
outpipe_t outpipe = {pipe_, true};
ok = outpipes.insert (outpipes_t::value_type (identity, outpipe)).second;
zmq_assert (ok);
return true;
}
示例5: zmq_assert
int zmq::gssapi_mechanism_base_t::produce_initiate (msg_t *msg_, void *token_value_, size_t token_length_)
{
zmq_assert (token_value_);
zmq_assert (token_length_ <= 0xFFFFFFFFUL);
const size_t command_size = 9 + 4 + token_length_;
const int rc = msg_->init_size (command_size);
errno_assert (rc == 0);
uint8_t *ptr = static_cast <uint8_t *> (msg_->data ());
// Add command string
memcpy (ptr, "\x08INITIATE", 9);
ptr += 9;
// Add token length
put_uint32 (ptr, static_cast <uint32_t> (token_length_));
ptr += 4;
// Add token value
memcpy (ptr, token_value_, token_length_);
ptr += token_length_;
return 0;
}
示例6: oaep_mask
static void oaep_mask(const ssh_hashalg *h, void *seed, int seedlen,
void *vdata, int datalen)
{
unsigned char *data = (unsigned char *)vdata;
unsigned count = 0;
while (datalen > 0) {
int i, max = (datalen > h->hlen ? h->hlen : datalen);
ssh_hash *s;
unsigned char hash[MAX_HASH_LEN];
assert(h->hlen <= MAX_HASH_LEN);
s = ssh_hash_new(h);
put_data(s, seed, seedlen);
put_uint32(s, count);
ssh_hash_final(s, hash);
count++;
for (i = 0; i < max; i++)
data[i] ^= hash[i];
data += max;
datalen -= max;
}
}
示例7: rsa2_sign
static void rsa2_sign(ssh_key *key, ptrlen data,
unsigned flags, BinarySink *bs)
{
RSAKey *rsa = container_of(key, RSAKey, sshk);
unsigned char *bytes;
size_t nbytes;
mp_int *in, *out;
const ssh_hashalg *halg;
const char *sign_alg_name;
halg = rsa2_hash_alg_for_flags(flags, &sign_alg_name);
nbytes = (mp_get_nbits(rsa->modulus) + 7) / 8;
bytes = rsa_pkcs1_signature_string(nbytes, halg, data);
in = mp_from_bytes_be(make_ptrlen(bytes, nbytes));
smemclr(bytes, nbytes);
sfree(bytes);
out = rsa_privkey_op(in, rsa);
mp_free(in);
put_stringz(bs, sign_alg_name);
nbytes = (mp_get_nbits(out) + 7) / 8;
put_uint32(bs, nbytes);
for (size_t i = 0; i < nbytes; i++)
put_byte(bs, mp_get_byte(out, nbytes - 1 - i));
mp_free(out);
}
示例8: blob_t
void zmq::stream_t::identify_peer (pipe_t *pipe_)
{
// Always assign identity for raw-socket
unsigned char buffer [5];
buffer [0] = 0;
blob_t identity;
if (connect_rid.length ()) {
identity = blob_t ((unsigned char*) connect_rid.c_str(),
connect_rid.length ());
connect_rid.clear ();
outpipes_t::iterator it = outpipes.find (identity);
zmq_assert (it == outpipes.end ());
}
else {
put_uint32 (buffer + 1, next_rid++);
identity = blob_t (buffer, sizeof buffer);
memcpy (options.identity, identity.data (), identity.size ());
options.identity_size = (unsigned char) identity.size ();
}
pipe_->set_identity (identity);
// Add the record into output pipes lookup table
outpipe_t outpipe = {pipe_, true};
const bool ok = outpipes.insert (
outpipes_t::value_type (identity, outpipe)).second;
zmq_assert (ok);
}
示例9: default_reply_name_count
static void default_reply_name_count(SftpReplyBuilder *reply, unsigned count)
{
DefaultSftpReplyBuilder *d =
container_of(reply, DefaultSftpReplyBuilder, rb);
d->pkt->type = SSH_FXP_NAME;
put_uint32(d->pkt, count);
}
示例10: zmq_assert
void zmq::stream_t::identify_peer (pipe_t *pipe_)
{
// Always assign routing id for raw-socket
unsigned char buffer[5];
buffer[0] = 0;
blob_t routing_id;
if (connect_routing_id.length ()) {
routing_id.set ((unsigned char *) connect_routing_id.c_str (),
connect_routing_id.length ());
connect_routing_id.clear ();
outpipes_t::iterator it = outpipes.find (routing_id);
zmq_assert (it == outpipes.end ());
} else {
put_uint32 (buffer + 1, next_integral_routing_id++);
routing_id.set (buffer, sizeof buffer);
memcpy (options.routing_id, routing_id.data (), routing_id.size ());
options.routing_id_size = (unsigned char) routing_id.size ();
}
pipe_->set_router_socket_routing_id (routing_id);
// Add the record into output pipes lookup table
outpipe_t outpipe = {pipe_, true};
const bool ok =
outpipes.ZMQ_MAP_INSERT_OR_EMPLACE (ZMQ_MOVE (routing_id), outpipe)
.second;
zmq_assert (ok);
}
示例11: eddsa_openssh_blob
static void eddsa_openssh_blob(ssh_key *key, BinarySink *bs)
{
struct eddsa_key *ek = container_of(key, struct eddsa_key, sshk);
assert(ek->curve->type == EC_EDWARDS);
/* Encode the public and private points as strings */
strbuf *pub_sb = strbuf_new();
put_epoint(pub_sb, ek->publicKey, ek->curve, false);
ptrlen pub = make_ptrlen(pub_sb->s + 4, pub_sb->len - 4);
strbuf *priv_sb = strbuf_new_nm();
put_mp_le_unsigned(priv_sb, ek->privateKey);
ptrlen priv = make_ptrlen(priv_sb->s + 4, priv_sb->len - 4);
put_stringpl(bs, pub);
/* Encode the private key as the concatenation of the
* little-endian key integer and the public key again */
put_uint32(bs, priv.len + pub.len);
put_datapl(bs, priv);
put_datapl(bs, pub);
strbuf_free(pub_sb);
strbuf_free(priv_sb);
}
示例12: BinarySink_put_mp_le_unsigned
static void BinarySink_put_mp_le_unsigned(BinarySink *bs, mp_int *x)
{
size_t bytes = (mp_get_nbits(x) + 7) / 8;
put_uint32(bs, bytes);
for (size_t i = 0; i < bytes; ++i)
put_byte(bs, mp_get_byte(x, i));
}
示例13: default_reply_ok
static void default_reply_ok(SftpReplyBuilder *reply)
{
DefaultSftpReplyBuilder *d =
container_of(reply, DefaultSftpReplyBuilder, rb);
d->pkt->type = SSH_FXP_STATUS;
put_uint32(d->pkt, SSH_FX_OK);
put_stringz(d->pkt, "");
}
示例14: default_reply_error
static void default_reply_error(
SftpReplyBuilder *reply, unsigned code, const char *msg)
{
DefaultSftpReplyBuilder *d =
container_of(reply, DefaultSftpReplyBuilder, rb);
d->pkt->type = SSH_FXP_STATUS;
put_uint32(d->pkt, code);
put_stringz(d->pkt, msg);
}
示例15: assert
void zmq::amqp_marshaller_t::put_field_table (
unsigned char *args, size_t args_size, size_t &offset,
const i_amqp::field_table_t &table_)
{
// Skip field table size (to be filled in later)
assert (offset + sizeof (uint32_t) <= args_size);
offset += sizeof (uint32_t);
size_t table_size = 0;
for (i_amqp::field_table_t::const_iterator table_it = table_.begin();
table_it != table_.end(); table_it++ ) {
// Put field name
assert (offset + sizeof (uint8_t) + table_it->first.size () <=
i_amqp::frame_min_size);
put_uint8 (args + offset, table_it->first.size ());
offset += sizeof (uint8_t);
memcpy (args + offset, table_it->first.c_str (),
table_it->first.size ());
offset += table_it->first.size ();
// Put field type
assert (offset + sizeof (uint8_t) <= args_size);
put_uint8 (args + offset, 'S');
offset += sizeof (uint8_t);
// Put field value
assert (offset + sizeof (uint32_t) + table_it->second.size () <=
i_amqp::frame_min_size);
put_uint32 (args + offset, table_it->second.size ());
offset += sizeof (uint32_t);
memcpy (args + offset, table_it->second.c_str (),
table_it->second.size ());
offset += table_it->second.size ();
// Adjust actual table size
table_size += (sizeof (uint8_t) + table_it->first.size () +
sizeof (uint8_t) + sizeof (uint32_t) +
table_it->second.size ());
}
// Fill in the table size
put_uint32 (args + offset - table_size - sizeof (uint32_t), table_size);
}