本文整理汇总了C++中send_pkt函数的典型用法代码示例。如果您正苦于以下问题:C++ send_pkt函数的具体用法?C++ send_pkt怎么用?C++ send_pkt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_pkt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sane_start
SANE_Status
sane_start (SANE_Handle h)
{
struct device_s *dev = (struct device_s *) h;
int status;
size_t size;
dev->read_offset = 0;
dev->write_offset_r = 0;
dev->write_offset_g = 1;
dev->write_offset_b = 2;
free (dev->buffer);
dev->buffer = NULL;
send_pkt (PKT_RESET, 0, dev);
send_pkt (PKT_READ_STATUS, 0, dev);
wait_ack (dev, &status);
if (status)
return SANE_STATUS_IO_ERROR;
send_pkt (PKT_READCONF, 0, dev);
if ((size = wait_ack (dev, NULL)))
{
sanei_usb_read_bulk (dev->dn, (unsigned char *) dev->conf_data, &size);
}
send_pkt (PKT_SETCONF, 100, dev);
send_conf (dev);
wait_ack (dev, NULL);
send_pkt (PKT_START_SCAN, 0, dev);
wait_ack (dev, NULL);
if ((size = wait_ack (dev, NULL)))
{
sanei_usb_read_bulk (dev->dn, (unsigned char *) dev->conf_data, &size);
}
if ((size = wait_ack (dev, NULL)))
{
sanei_usb_read_bulk (dev->dn, (unsigned char *) dev->conf_data, &size);
}
if ((size = wait_ack (dev, NULL)))
{
sanei_usb_read_bulk (dev->dn, (unsigned char *) dev->conf_data, &size);
}
dev->status = STATUS_SCANNING;
/* Get the first data */
return get_data (dev);
}
示例2: network_send_pkt
int
network_send_pkt(network_address_t dest_address, int hdr_len,
char* hdr, int data_len, char* data) {
if (synthetic_network) {
if(genrand() < loss_rate)
return (hdr_len+data_len);
if(genrand() < duplication_rate)
send_pkt(dest_address, hdr_len, hdr, data_len, data);
}
return send_pkt(dest_address, hdr_len, hdr, data_len, data);
}
示例3: A_input
/* called from layer 3, when a packet arrives for layer 4 */
void A_input(struct pkt packet)
{
printf("CCH> A_input> Got packet\n");
// isChecksumValid
if(pkt_checksum_valid(&packet)) {
printf("CCH> A_input> Valid checksum\n");
// isACK
if(strncmp(packet.payload, ACK, strlen(ACK)) == 0) {
if(packet.acknum == last_pkt->seqnum) {
printf("CCH> A_input> Received valid ACK\n");
last_ack = &packet;
stoptimer(A);
} else {
// We received an ACK we don't care about
printf("CCH> A_input> Received invalid ACK (ignoring)\n");
}
// isNACK
} else if (strncmp(packet.payload, NACK, strlen(ACK)) == 0) {
printf("CCH> A_input> Received NACK\n");
send_pkt(A, last_pkt);
} else {
// Message
stoptimer(A);
tolayer5(A, packet.payload);
}
} else {
printf("CCH> A_input> Invalid checksum\n");
send_nack(A, &packet);
stoptimer(A);
starttimer(A, TIMEOUT);
return;
}
}
示例4: do_cmd_1_arg
int do_cmd_1_arg(QSP_ARG_DECL Cmd_Index cmd_index, int data_word)
{
u_short len;
char pkt[20];
USB2000_Cmd_Def *ucdp;
ucdp = &usb2000_cmd_tbl[cmd_index];
make_pkt( pkt, ucdp->ucd_cmd, data_word );
send_pkt(QSP_ARG pkt);
len = strlen(pkt);
if( get_echo(QSP_ARG pkt) < 0 )
return -1;
if ( recv_a_byte(SINGLE_QSP_ARG) != ACK ) {
WARN("ERROR: no ACK received");
return -1;
}
if( get_tail(SINGLE_QSP_ARG) < 0 )
return -1;
return 0;
}
示例5: rom_send_DATA
int rom_send_DATA(CalcHandle* handle, uint32_t addr)
{
ticalcs_info(" PC->TI: REQ_BLOCK at @%08x", addr);
TRYF(send_pkt(handle, CMD_REQ_BLOCK, 4, (uint8_t *)&addr));
return 0;
}
示例6: test_ping
static int
test_ping(void)
{
struct pkt *pkt;
struct timeval tv;
printf("ping: "); fflush(stdout);
ping->pkt_icmp_msg->echo.icmp_id = rand_uint16(ctx.rnd);
pkt = pkt_dup(ping);
pkt->pkt_ip->ip_id = rand_uint16(ctx.rnd);
ip_checksum(pkt->pkt_ip, pkt->pkt_end - pkt->pkt_eth_data);
pcap_filter(ctx.pcap, "icmp[0] = 0 and src %s and dst %s",
addr_ntoa(&ctx.dst), addr_ntoa(&ctx.src));
send_pkt(pkt);
for (tv = read_tv; (pkt = recv_pkt(&tv)) != NULL; tv = read_tv) {
if (memcmp(&pkt->pkt_icmp_msg->echo,
&ping->pkt_icmp_msg->echo, 8) == 0)
break;
}
printf("%s\n", pkt ? timeval_ntoa(&tv) : "no reply");
return (0);
}
示例7: network_send_pkt
int
network_send_pkt(network_address_t dest_address, int hdr_len,
char* hdr, int data_len, char* data) {
//printf("network_send_pkt: called\n"); //DEBUG
//printf("network_send_pkt : synthetic network - %d\n", synthetic_network);
if (synthetic_network) {
if(genrand() < loss_rate)
return (hdr_len+data_len);
if(genrand() < duplication_rate)
send_pkt(dest_address, hdr_len, hdr, data_len, data);
}
//printf("call send_pkt\n");
return send_pkt(dest_address, hdr_len, hdr, data_len, data);
}
示例8: rom_send_ERR
int rom_send_ERR(CalcHandle* handle)
{
ticalcs_info(" PC->TI: ERROR");
TRYF(send_pkt(handle, CMD_ERROR, 0, NULL));
return 0;
}
示例9: rom_send_RDY
int rom_send_RDY(CalcHandle* handle)
{
ticalcs_info(" PC->TI: IS_READY");
TRYF(send_pkt(handle, CMD_IS_READY, 0, NULL));
return 0;
}
示例10: rom_send_SIZE
int rom_send_SIZE(CalcHandle* handle)
{
ticalcs_info(" PC->TI: REQ_SIZE");
TRYF(send_pkt(handle, CMD_REQ_SIZE, 0, NULL));
return 0;
}
示例11: network_bcast_pkt
int
network_bcast_pkt(int hdr_len, char* hdr, int data_len, char* data)
{
int i;
int me;
AbortOnCondition(!BCAST_ENABLED,
"Error: network broadcast not enabled.");
if (BCAST_USE_TOPOLOGY_FILE) {
me = topology.me;
for (i=0; i<topology.entries[me].n_links; i++) {
int dest = topology.entries[me].links[i];
if (synthetic_network) {
if(genrand() < loss_rate)
continue;
if(genrand() < duplication_rate)
send_pkt(topology.entries[dest].addr, hdr_len, hdr, data_len, data);
}
if (send_pkt(topology.entries[dest].addr,
hdr_len, hdr, data_len, data) != hdr_len + data_len)
return -1;
}
if (BCAST_LOOPBACK) {
if (send_pkt(topology.entries[me].addr,
hdr_len, hdr, data_len, data) != hdr_len + data_len)
return -1;
}
} else { /* real broadcast */
/* send the packet using the private network broadcast address */
if (send_pkt(broadcast_addr,
hdr_len, hdr, data_len, data) != hdr_len + data_len)
return -1;
}
return hdr_len+data_len;
}
示例12: send_turn_signal
void send_turn_signal() {
memset(&cf, 0, sizeof(cf));
cf.can_id = signal_id;
cf.len = signal_len;
cf.data[signal_pos] = signal_state;
if(signal_pos) randomize_pkt(0, signal_pos);
if(signal_len != signal_pos + 1) randomize_pkt(signal_pos+1, signal_len);
send_pkt(CAN_MTU);
}
示例13: wpan_writeAttr
u8 wpan_writeAttr(u8* addr, u8 attr, u32* val)
{
memcpy(ch.addr, addr, WPAN_ADDR_SIZE);
wpan_pkt.header = WPAN_RW;
wpan_pkt.reserve = 0;
WPAN_CMD_TYPE(0) = WPAN_RW_MASK | (attr & WPAN_ATTR_MASK);
WPAN_CMD_DAT(0) = *val;
return send_pkt(&wpan_pkt);
}
示例14: A_timerinterrupt
/* called when A's timer goes off */
void A_timerinterrupt(void)
{
printf("CCH> A_timerinterrupt> Called\n");
if(last_ack && (last_ack->acknum < last_pkt->seqnum)) {
printf("CCH> A_timerinterrupt> Packet timed out, resending\n");
send_pkt(A, last_pkt);
}
}
示例15: send_unlock
void send_unlock(char door) {
door_state &= ~door;
memset(&cf, 0, sizeof(cf));
cf.can_id = door_id;
cf.len = door_len;
cf.data[door_pos] = door_state;
if (door_pos) randomize_pkt(0, door_pos);
if (door_len != door_pos + 1) randomize_pkt(door_pos + 1, door_len);
send_pkt(CAN_MTU);
}