本文整理汇总了C++中put_u32函数的典型用法代码示例。如果您正苦于以下问题:C++ put_u32函数的具体用法?C++ put_u32怎么用?C++ put_u32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put_u32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: packet_fxp_init
int packet_fxp_init(Buffer *buff, Buffer *preped_buff) {
u_char *cp;
u_int msg_len;
u_int xmsg_len;
u_int msg_ver;
cp = buffer_ptr(buff);
// 1. Ensure extensions are not forwarded. Drop packet size down to 5 bytes + 4 byte length. Later byte are ignored through buffer_consume.
msg_len = get_u32(cp);
xmsg_len = 5;
put_u32(cp, xmsg_len);
// 2. Ensure client version number presented is not greater than that supported.
cp += 5;
msg_ver = get_u32(cp);
if (msg_ver > 3)
msg_ver = 3;
put_u32(cp, msg_ver);
// Copy packet over to prepared buffer
buffer_append(preped_buff, buffer_ptr(buff), xmsg_len + sizeof(u_int));
buffer_consume(buff, msg_len + sizeof(u_int));
return 1;
}
示例2: isdn_net_ciscohdlck_slarp_send_request
static void
isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *mlp)
{
isdn_net_dev *idev;
struct sk_buff *skb;
unsigned char *p;
if (list_empty(&mlp->online)) {
isdn_BUG();
return;
}
idev = list_entry(mlp->online.next, isdn_net_dev, online);
skb = isdn_net_ciscohdlck_alloc_skb(idev, 4 + 14);
if (!skb)
return;
p = skb_put(skb, 4 + 14);
/* cisco header */
p += put_u8 (p, CISCO_ADDR_UNICAST);
p += put_u8 (p, CISCO_CTRL);
p += put_u16(p, CISCO_TYPE_SLARP);
/* slarp request */
p += put_u32(p, CISCO_SLARP_REQUEST);
p += put_u32(p, 0); // address
p += put_u32(p, 0); // netmask
p += put_u16(p, 0); // unused
isdn_net_write_super(idev, skb);
}
示例3: mrt_put_bgp4_hdr
static byte *
mrt_put_bgp4_hdr(byte *buf, struct bgp_conn *conn, int as4)
{
struct bgp_proto *p = conn->bgp;
if (as4)
{
put_u32(buf+0, p->remote_as);
put_u32(buf+4, p->local_as);
buf+=8;
}
else
{
put_u16(buf+0, (p->remote_as <= 0xFFFF) ? p->remote_as : AS_TRANS);
put_u16(buf+2, (p->local_as <= 0xFFFF) ? p->local_as : AS_TRANS);
buf+=4;
}
put_u16(buf+0, (p->neigh && p->neigh->iface) ? p->neigh->iface->index : 0);
put_u16(buf+2, BGP_AF);
buf+=4;
buf = put_ipa(buf, conn->sk ? conn->sk->daddr : IPA_NONE);
buf = put_ipa(buf, conn->sk ? conn->sk->saddr : IPA_NONE);
return buf;
}
示例4: sophon_insfile_store
Sophon_Result
sophon_insfile_store (Sophon_VM *vm, Sophon_Module *mod,
Sophon_IOFunc func, Sophon_Ptr data)
{
Sophon_U16 i;
SOPHON_ASSERT(vm && mod && func);
put_u32(func, data, SOPHON_INSFILE_MAGIC);
put_u32(func, data, SOPHON_INSFILE_VERSION);
if (mod->name)
put_str(vm, func, data, mod->name);
else
put_u32(func, data, 0);
put_u16(func, data, mod->const_count);
for (i = 0; i < mod->const_count; i++) {
put_value(vm, func, data, mod->consts[i]);
}
put_u16(func, data, mod->func_count);
for (i = 0; i < mod->func_count; i++) {
put_func(vm, func, data, mod->funcs[i]);
}
return SOPHON_OK;
}
示例5: send_cmd_turbo
int send_cmd_turbo(libusb_device_handle* fd, int turbo_on)
{
struct tf_packet req;
trace(3, printf("send_cmd_turbo\n"));
put_u16(&req.length, 12);
put_u32(&req.cmd, CMD_TURBO);
put_u32(&req.data, turbo_on);
return send_tf_packet(fd, &req);
}
示例6: send_cmd_turbo
ssize_t send_cmd_turbo(int fd, int turbo_on)
{
struct tf_packet req;
trace(2, fprintf(stderr, "%s\n", __func__));
put_u16(&req.length, 12);
put_u32(&req.cmd, CMD_TURBO);
put_u32(&req.data, turbo_on);
return send_tf_packet(fd, &req);
}
示例7: packet_fxp_fsetstat
int packet_fxp_fsetstat(Buffer *buff, Buffer *preped_buff) {
u_int msg_len;
u_int xmsg_len;
// File names
u_int file_len;
u_char *handle;
// Copy first part of packet over to prepared buffer
msg_len = get_u32(buffer_ptr(buff));
xmsg_len = msg_len;
buffer_append(preped_buff, buffer_ptr(buff), 9);
buffer_consume(buff, 9);
xmsg_len -= 5;
// Copy handle
handle = buffer_get_string(buff, &file_len);
buffer_put_string(preped_buff, (char*) handle, file_len);
xmsg_len -= (file_len + 4);
// Copy attributes through, cleaning extensions where required
parse_attrs(buff, preped_buff, &msg_len, &xmsg_len);
// Copy any remaining packet data over
buffer_append(preped_buff, buffer_ptr(buff), xmsg_len);
buffer_consume(buff, xmsg_len);
// Rewrite message length
put_u32(buffer_end(preped_buff)-msg_len-4, msg_len);
return 1;
}
示例8: packet_fxp_mkdir
int packet_fxp_mkdir(Buffer *buff, Buffer *preped_buff) {
u_int msg_len;
u_int xmsg_len;
// File names
u_int file_len;
u_char *filename;
// Copy first part of packet over to prepared buffer
msg_len = get_u32(buffer_ptr(buff));
xmsg_len = msg_len;
buffer_append(preped_buff, buffer_ptr(buff), 9);
buffer_consume(buff, 9);
xmsg_len -= 5;
// Rewrite path
filename = buffer_get_string(buff, &file_len);
filename = unchroot_filename(filename, (u_char*) user_homedir);
buffer_put_cstring(preped_buff, (char*) filename);
xmsg_len -= (file_len + 4);
msg_len += (strlen((char*) filename) - file_len);
// Copy attributes through, cleaning extensions where required
parse_attrs(buff, preped_buff, &msg_len, &xmsg_len);
// Copy any remaining packet data over
buffer_append(preped_buff, buffer_ptr(buff), xmsg_len);
buffer_consume(buff, xmsg_len);
// Rewrite message length
put_u32(buffer_end(preped_buff)-msg_len-4, msg_len);
return 1;
}
示例9: packet_fxp_realpath
int packet_fxp_realpath(Buffer *buff, Buffer *preped_buff) {
u_int msg_len, xmsg_len;
u_int file_len;
u_char *filename;
// Copy first part of packet over to prepared buffer
msg_len = get_u32(buffer_ptr(buff));
xmsg_len = msg_len;
buffer_append(preped_buff, buffer_ptr(buff), 9);
buffer_consume(buff, 9);
xmsg_len -= 5;
// Rewrite path
filename = buffer_get_string(buff, &file_len);
filename = unchroot_filename(filename, (u_char*) user_homedir);
buffer_put_cstring(preped_buff, (char*) filename);
xmsg_len -= (file_len + 4);
msg_len += (strlen((char*) filename) - file_len);
// Copy packet over to prepared buffer
buffer_append(preped_buff, buffer_ptr(buff), xmsg_len);
buffer_consume(buff, xmsg_len);
// Replace length with new length
put_u32(buffer_end(preped_buff)-msg_len-4, msg_len);
return 1;
}
示例10: buffer_put_int
void buffer_put_int(Buffer *buffer, unsigned int value)
{
char buf[4];
put_u32(buf, value);
buffer_append(buffer, buf, 4);
}
示例11: send_cmd_hdd_file_send_with_offset
int send_cmd_hdd_file_send_with_offset(libusb_device_handle* fd, __u8 dir, char *path, __u64 offset)
{
struct tf_packet req;
__u16 packetSize, pad;
int pathLen = strlen(path) + 1;
trace(3, printf("send_cmd_hdd_file_send_with_offset: %s [%ld]\n",path,offset));
if((PACKET_HEAD_SIZE + 1 + 2 + pathLen) >= MAXIMUM_PACKET_SIZE)
{
fprintf(stdout, "ERROR: Path is too long.\n");
return -1;
}
packetSize = PACKET_HEAD_SIZE + 1 + 2 + pathLen +8;
pad = ((packetSize + 1) & ~1 ) - packetSize;
//printf("Packet padding: %d\n",pad);
pad = 0;//((packetSize + 1) & ~1 ) - packetSize;
//printf("Packet padding: %d\n",pad);
packetSize +=pad;
put_u16(&req.length, packetSize);
put_u32(&req.cmd, CMD_HDD_FILE_SEND);
req.data[0] = dir;
put_u16(&req.data[1], (__u16) pathLen);
strcpy((char *) &req.data[3], path);
put_u64( &req.data[3+pathLen+pad],offset);
return send_tf_packet(fd, &req);
}
示例12: send_cmd_hdd_rename
int send_cmd_hdd_rename(libusb_device_handle* fd, char *src, char *dst)
{
struct tf_packet req;
__u16 packetSize;
__u16 srcLen = strlen(src) + 1;
__u16 dstLen = strlen(dst) + 1;
trace(3, printf("send_cmd_hdd_rename: %s : %s\n",src,dst));
if((PACKET_HEAD_SIZE + 2 + srcLen + 2 + dstLen) >= MAXIMUM_PACKET_SIZE)
{
fprintf(stdout,
"ERROR: Combination of source and destination paths is too long.\n");
return -1;
}
packetSize = PACKET_HEAD_SIZE + 2 + srcLen + 2 + dstLen;
packetSize = (packetSize + 1) & ~1;
put_u16(&req.length, packetSize);
put_u32(&req.cmd, CMD_HDD_RENAME);
put_u16(&req.data[0], srcLen);
strcpy((char *) &req.data[2], src);
put_u16(&req.data[2 + srcLen], dstLen);
strcpy((char *) &req.data[2 + srcLen + 2], dst);
return send_tf_packet(fd, &req);
}
示例13: mm_log_handler
void
mm_log_handler(LogLevel level, const char *msg, void *ctx)
{
Buffer log_msg;
struct monitor *mon = (struct monitor *)ctx;
if (mon->m_log_sendfd == -1)
fatal("%s: no log channel", __func__);
buffer_init(&log_msg);
/*
* Placeholder for packet length. Will be filled in with the actual
* packet length once the packet has been constucted. This saves
* fragile math.
*/
buffer_put_int(&log_msg, 0);
buffer_put_int(&log_msg, level);
buffer_put_cstring(&log_msg, msg);
put_u32(buffer_ptr(&log_msg), buffer_len(&log_msg) - 4);
if (atomicio(vwrite, mon->m_log_sendfd, buffer_ptr(&log_msg),
buffer_len(&log_msg)) != buffer_len(&log_msg))
fatal("%s: write: %s", __func__, strerror(errno));
buffer_free(&log_msg);
}
示例14: mac_compute
u_char *
mac_compute(Mac *mac, u_int32_t seqno, u_char *data, int datalen)
{
static u_char m[EVP_MAX_MD_SIZE];
u_char b[4];
if (mac->mac_len > sizeof(m))
fatal("mac_compute: mac too long %u %lu",
mac->mac_len, (u_long)sizeof(m));
switch (mac->type) {
case SSH_EVP:
put_u32(b, seqno);
/* reset HMAC context */
HMAC_Init(&mac->evp_ctx, NULL, 0, NULL);
HMAC_Update(&mac->evp_ctx, b, sizeof(b));
HMAC_Update(&mac->evp_ctx, data, datalen);
HMAC_Final(&mac->evp_ctx, m, NULL);
break;
default:
fatal("mac_compute: unknown MAC type");
}
return (m);
}
示例15: learn_to_nxast
/* Converts 'learn' into a "struct nx_action_learn" and appends that action to
* 'ofpacts'. */
void
learn_to_nxast(const struct ofpact_learn *learn, struct ofpbuf *openflow)
{
const struct ofpact_learn_spec *spec;
struct nx_action_learn *nal;
size_t start_ofs;
start_ofs = openflow->size;
nal = ofputil_put_NXAST_LEARN(openflow);
nal->idle_timeout = htons(learn->idle_timeout);
nal->hard_timeout = htons(learn->hard_timeout);
nal->fin_idle_timeout = htons(learn->fin_idle_timeout);
nal->fin_hard_timeout = htons(learn->fin_hard_timeout);
nal->priority = htons(learn->priority);
nal->cookie = htonll(learn->cookie);
nal->flags = htons(learn->flags);
nal->table_id = learn->table_id;
for (spec = learn->specs; spec < &learn->specs[learn->n_specs]; spec++) {
put_u16(openflow, spec->n_bits | spec->dst_type | spec->src_type);
if (spec->src_type == NX_LEARN_SRC_FIELD) {
put_u32(openflow, spec->src.field->nxm_header);
put_u16(openflow, spec->src.ofs);
} else {
size_t n_dst_bytes = 2 * DIV_ROUND_UP(spec->n_bits, 16);
uint8_t *bits = ofpbuf_put_zeros(openflow, n_dst_bytes);
bitwise_copy(&spec->src_imm, sizeof spec->src_imm, 0,
bits, n_dst_bytes, 0,
spec->n_bits);
}
if (spec->dst_type == NX_LEARN_DST_MATCH ||
spec->dst_type == NX_LEARN_DST_LOAD) {
put_u32(openflow, spec->dst.field->nxm_header);
put_u16(openflow, spec->dst.ofs);
}
}
if ((openflow->size - start_ofs) % 8) {
ofpbuf_put_zeros(openflow, 8 - (openflow->size - start_ofs) % 8);
}
nal = ofpbuf_at_assert(openflow, start_ofs, sizeof *nal);
nal->len = htons(openflow->size - start_ofs);
}