• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ put_u32函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中put_u32函数的典型用法代码示例。如果您正苦于以下问题:C++ put_u32函数的具体用法?C++ put_u32怎么用?C++ put_u32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了put_u32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:spaulg,项目名称:sftp-chroot,代码行数:27,代码来源:unchroot_packets.c


示例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);
}
开发者ID:xricson,项目名称:knoppix,代码行数:32,代码来源:isdn_ciscohdlck.c


示例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;
}
开发者ID:ColinBS,项目名称:bird,代码行数:26,代码来源:packets.c


示例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;
}
开发者ID:sharpglasses,项目名称:SophonJS,代码行数:29,代码来源:sophon_insfile.c


示例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);
}
开发者ID:q-bits,项目名称:Antares,代码行数:9,代码来源:usb_io.c


示例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);
}
开发者ID:nben,项目名称:puppy,代码行数:11,代码来源:usb_io.c


示例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;
}
开发者ID:spaulg,项目名称:sftp-chroot,代码行数:33,代码来源:unchroot_packets.c


示例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;
}
开发者ID:spaulg,项目名称:sftp-chroot,代码行数:35,代码来源:unchroot_packets.c


示例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;
}
开发者ID:spaulg,项目名称:sftp-chroot,代码行数:29,代码来源:unchroot_packets.c


示例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);
}
开发者ID:nazda,项目名称:wippien,代码行数:7,代码来源:buffer.c


示例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);
}
开发者ID:q-bits,项目名称:Antares,代码行数:29,代码来源:usb_io.c


示例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);
}
开发者ID:q-bits,项目名称:Antares,代码行数:25,代码来源:usb_io.c


示例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);
}
开发者ID:2dot4,项目名称:Psiphon3-for-Linux,代码行数:25,代码来源:monitor_wrap.c


示例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);
}
开发者ID:AlfredArouna,项目名称:illumos-gate,代码行数:25,代码来源:mac.c


示例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);
}
开发者ID:yamt,项目名称:openvswitch,代码行数:48,代码来源:learn.c


示例16: send_cmd_hdd_size

int send_cmd_hdd_size(libusb_device_handle* fd)
{
    struct tf_packet req;
    trace(3, printf("send_cmd_hdd_size\n"));
    put_u16(&req.length, 8);
    put_u32(&req.cmd, CMD_HDD_SIZE);
    return send_tf_packet(fd, &req);
}
开发者ID:q-bits,项目名称:Antares,代码行数:8,代码来源:usb_io.c


示例17: send_cmd_reset

int send_cmd_reset(libusb_device_handle* fd)
{
    struct tf_packet req;
    trace(3, printf("send_cmd_reset\n"));
    put_u16(&req.length, 8);
    put_u32(&req.cmd, CMD_RESET);
    return send_tf_packet(fd, &req);
}
开发者ID:q-bits,项目名称:Antares,代码行数:8,代码来源:usb_io.c


示例18: send_cmd_hdd_size

ssize_t send_cmd_hdd_size(int fd)
{
    struct tf_packet req;

    trace(2, fprintf(stderr, "%s\n", __func__));

    put_u16(&req.length, 8);
    put_u32(&req.cmd, CMD_HDD_SIZE);
    return send_tf_packet(fd, &req);
}
开发者ID:nben,项目名称:puppy,代码行数:10,代码来源:usb_io.c


示例19: handle_to_string

static int
handle_to_string(int handle, u_char **stringp, int *hlenp)
{
	if (stringp == NULL || hlenp == NULL)
		return -1;
	*stringp = xmalloc(sizeof(int32_t));
	put_u32(*stringp, handle);
	*hlenp = sizeof(int32_t);
	return 0;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:10,代码来源:sftp-server.c


示例20: wav_dump

bool wav_dump( const char* filename, int bytespersample, int channels, int freq, void const* data, int bytecnt)
{
    // room for file header, fmt chunk and data chunk header
    uint8_t buf[(8+4)+(8+18) + 8];

    uint8_t* p=buf;
    p=put_4CC(p,"RIFF");
    p=put_u32(p,4 + (8+18) + (8+bytecnt));
    p=put_4CC(p,"WAVE");
    // fmt chunk
    p=put_4CC(p,"fmt ");
    p=put_u32(p,18);        // chunksize
    p=put_u16(p,0x0001);    // wFormatTag (WAVE_FORMAT_PCM)
    p=put_u16(p,channels);  // nChannels
    p=put_u32(p,freq);      // nSamplesPerSec
    p=put_u32(p,freq*channels*bytespersample);  // nAvgBytesPerSec
    p=put_u16(p,bytespersample*channels);       // nBlockAlign
    p=put_u16(p,bytespersample*8);              // wBitsPerSample
    p=put_u16(p,0);         // cbSize

    // data chunk (header only)
    p=put_4CC(p,"data");
    p=put_u32(p,bytecnt);

    FILE* fp = fopen(filename,"wb");
    if (!fp)
        return false;

    if (fwrite(buf,sizeof(buf),1,fp) != 1)
    {
        fclose(fp);
        return false;
    }

    if (fwrite(data,bytecnt,1,fp) != 1)
    {
        fclose(fp);
        return false;
    }
    fclose(fp);
    return true;
}
开发者ID:bcampbell,项目名称:zig,代码行数:42,代码来源:wav.cpp



注:本文中的put_u32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ put_uint32函数代码示例发布时间:2022-05-30
下一篇:
C++ put_tty_driver函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap