本文整理汇总了C++中send_frame函数的典型用法代码示例。如果您正苦于以下问题:C++ send_frame函数的具体用法?C++ send_frame怎么用?C++ send_frame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_frame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: answer_magic
static void answer_magic(int serialfd,
const char *kernel_image, unsigned int kernel_address,
const char *cmdline, unsigned int cmdline_address,
const char *initrd_image, unsigned int initrd_address)
{
int kernelfd, initrdfd;
struct sfl_frame frame;
printf("[FLTERM] Received firmware download request from the device.\n");
kernelfd = open(kernel_image, O_RDONLY);
if(kernelfd == -1) {
perror("[FLTERM] Unable to open kernel image (request ignored).");
return;
}
initrdfd = -1;
if(initrd_image != NULL) {
initrdfd = open(initrd_image, O_RDONLY);
if(initrdfd == -1) {
perror("[FLTERM] Unable to open initrd image (request ignored).");
close(kernelfd);
return;
}
}
write_exact(serialfd, sfl_magic_ack, SFL_MAGIC_LEN);
upload_fd(serialfd, "kernel", kernelfd, kernel_address);
if(cmdline != NULL) {
int len;
printf("[FLTERM] Setting kernel command line: '%s'.\n", cmdline);
len = strlen(cmdline)+1;
if(len > (254-4)) {
fprintf(stderr, "[FLTERM] Kernel command line too long, load aborted.\n");
close(initrdfd);
close(kernelfd);
return;
}
frame.length = len+4;
frame.cmd = SFL_CMD_LOAD;
frame.payload[0] = (cmdline_address & 0xff000000) >> 24;
frame.payload[1] = (cmdline_address & 0x00ff0000) >> 16;
frame.payload[2] = (cmdline_address & 0x0000ff00) >> 8;
frame.payload[3] = (cmdline_address & 0x000000ff);
strcpy((char *)&frame.payload[4], cmdline);
send_frame(serialfd, &frame);
frame.length = 4;
frame.cmd = SFL_CMD_CMDLINE;
frame.payload[0] = (cmdline_address & 0xff000000) >> 24;
frame.payload[1] = (cmdline_address & 0x00ff0000) >> 16;
frame.payload[2] = (cmdline_address & 0x0000ff00) >> 8;
frame.payload[3] = (cmdline_address & 0x000000ff);
send_frame(serialfd, &frame);
}
示例2: eventbus_register
void eventbus_register(String address,void (*func)(String *)){
handler_t handler;
handler.address=address;
handler.function=func;
if(find(address)==false){
jsonMessage_t js;
js.address=address;
js.type="register";
js.replyAddress=NULL;
JSON_Value *body = json_parse_string(NULL);
JSON_Value *headers = json_parse_string(NULL);
js.body=body;
js.headers=headers;
String message=NULL;
getMessage(js,&message);
send_frame(&message);
free(message);
}
insertFirst(node_index,handler);
node_index++;
}
示例3: portTASK_FUNCTION
static portTASK_FUNCTION(TimeTask,pvParameters)
{
unsigned char frame[MAX_FRAME_SIZE];
int num_datos;
int tiempoSim;
uint32_t hora;
while(1)
{
vTaskDelay(configTICK_RATE_HZ); //cada segundo
tiempoSim=getTiempoSim(); //Obtenemos la equivalencia de 1 segundo Real son tiempoSim minutos en el simulado
hora = getHora(); //Obtenemos la hora
hora+=tiempoSim; //aumentamos hora tiempoSim (Minutos)
if(hora>1440){ //si llegamos a las 24:00 (1440 minutos) ponemos las 00:00
hora=0;
}
//Modificamos y enviamos la hora
setHora(hora);
num_datos=create_frame(frame, COMANDO_TIME, &hora, sizeof(hora), MAX_FRAME_SIZE);
if (num_datos>=0){
send_frame(frame, num_datos);
}else{
logError(num_datos);
}
}
}
示例4: send_broadcast
/**
* Envoi d'une trame a tous les joueurs encore connectes (broadcast)
* S'il y'a un probleme d'envoi, le joueur concerne est deconnecte et desinscrit
*
* @param the_players Liste des joueurs
* @param frame Trame a envoyer
*/
void send_broadcast(Players the_players, Frame frame) {
size_t i = 0;
Player current_player;
/*debug*/
print_frame(frame);
for(i=0; i < the_players->size; i++) {
current_player = the_players->player[i];
/* Envoi de la trame a tous les joueurs inscrits
* Desinscription et deconnexion du joueur en cas de deconnexion brutale
*/
if(current_player->is_registered) {
if(send_frame(current_player->sock, frame) == ERROR) {
/*debug*/
printf("Suppression d'un joueurs");
remove_player_by_sock(current_player->sock, the_players, 1);
}
}
}
free_frame(frame);
}
示例5: mySendFrame
void mySendFrame(unsigned char* databuff, int size) {//add crc and cooperate with physical layer. databuff should be ready to send. size shoule be without crc
if (databuff[0] != FRAME_NAK) {
//piggyback ack
short i = (receiverLeft - 1) % windowSize;//log the last ack arrived
if (i < 0)
i += windowSize;
for (short j = 0; j < bufferSize; j++) {
if (receiver[(receiverLeft + j) % bufferSize].frameArrived)
i = (receiverLeft + j) % windowSize;
else break;
}
databuff[0] == FRAME_DATA ? databuff[2] = i : databuff[1] = i;
}
//append crc
*(unsigned int*)(databuff + size) = crc32(databuff, size);
size += 4;//add length
if (databuff[0] == FRAME_DATA)
//add timer
start_timer(databuff[1], retimer);
//piggyback ack timer
if (databuff[0] != FRAME_NAK) {
stop_ack_timer();
start_ack_timer(acktimer);
}
send_frame(databuff, size);
}
示例6: handle_ready_query
/* Handle incoming READY_QUERY frames.
*/
static void handle_ready_query(Conn_t *conn, struct ready_frame *f)
{
f->opcode = htons(READY_IND);
send_frame(conn, f, sizeof(struct ready_frame));
return;
}
示例7: send_auth
void send_auth(struct params* p, char *mac)
{
char buf[4096];
struct ieee80211_frame *wh;
unsigned short *ptr;
int len;
wh = (struct ieee80211_frame*) buf;
memset(buf, 0, sizeof(buf));
fill_basic(wh, p);
memcpy(wh->i_addr1, mac, 6);
memcpy(wh->i_addr3, p->mac, 6);
wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT;
wh->i_fc[0] |= IEEE80211_FC0_SUBTYPE_AUTH;
ptr = (unsigned short*) (wh+1);
*ptr++ = htole16(0);
*ptr++ = htole16(2);
*ptr++ = htole16(0);
len = ((char*)ptr) - ((char*) wh);
printf("sending auth\n");
send_frame(p, wh, len);
}
示例8: pcnet_send
uint64 pcnet_send(struct eth_dev *e, uint8 *d, uint64 len, uint8 dst[6])
{
struct pcnet_private *p = (struct pcnet_private *)e->phys;
int i;
/*
printf("pcnet_send: len=%x dst=", len);
print_mac(dst);
printf("\n");
*/
for(i = 0 ; i < DRE_COUNT ; i++) {
if(!p->tx[i].TBADR) {
p->tx[i].ones = 0xf;
p->tx[i].TBADR = (uint32)(uint64)kmalloc_align(1544,
"pcnet_tx_32", NULL);
}
if(!p->tx[i].OWN) {
send_frame(&p->tx[i], e->addr, dst, d, len);
p->tx[i].ADD_NO_FCS = 1;
p->tx[i].ENP = 1;
p->tx[i].STP = 1;
p->tx[i].OWN = 1;
}
}
return 0;
}
示例9: send_proxy_arp_rsp
/* Send a LE_ARP_RESPONSE for a LAN destination (MAC address) when
* the LAN destination is present in kernel bridging table and we
* are acting as a proxy lane client
*/
static void send_proxy_arp_rsp(unsigned char *target_mac, uint32_t tran_id,
uint16_t lec_id, unsigned char *src_atm_addr)
{
struct ctrl_frame *frame;
int frame_size;
frame_size = sizeof(struct ctrl_frame) + lec_params.sizeoftlvs;
frame = malloc(frame_size);
if (frame == NULL) return;
memset(frame, 0, frame_size);
prefill_frame(frame, LE_ARP_RSP);
frame->header.tran_id = tran_id;
frame->header.lec_id = lec_id;
frame->header.flags = htons(REMOTE_ADDRESS);
memcpy(frame->target_atm_addr, lec_params.c1n_my_atm_addr, ATM_ESA_LEN);
frame->target_lan_dst.tag = htons(LAN_DST_MAC_ADDR);
memcpy(frame->target_lan_dst.mac, target_mac, ETH_ALEN);
memcpy(frame->src_atm_addr, src_atm_addr, ATM_ESA_LEN);
frame->num_tlvs = lec_params.num_tlvs;
if (lec_params.num_tlvs > 0)
memcpy(frame + 1, lec_params.tlvs, lec_params.sizeoftlvs);
if (send_frame(lec_params.ctrl_direct, frame, frame_size) < 0)
diag(COMPONENT, DIAG_ERROR, "send_proxy_arp_rsp: send_frame() failed");
free(frame);
return;
}
示例10: send_auth
void send_auth(struct params *p)
{
char buf[2048];
struct ieee80211_frame *wh;
char *data;
int len;
memset(buf, 0, sizeof(buf));
wh = (struct ieee80211_frame*) buf;
fill_basic(wh, p);
wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT | IEEE80211_FC0_SUBTYPE_AUTH;
data = (char*) (wh + 1);
/* algo */
*data++ = 0;
*data++ = 0;
/* transaction no. */
*data++ = 1;
*data++ = 0;
/* status code */
*data++ = 0;
*data++ = 0;
len = data - (char*)wh;
send_frame(p, buf, len);
}
示例11: send_assoc
void send_assoc(struct params *p, char *mac)
{
char buf[4096];
struct ieee80211_frame *wh;
char *ptr;
int len;
wh = (struct ieee80211_frame*) buf;
memset(buf, 0, sizeof(buf));
fill_basic(wh, p);
memcpy(wh->i_addr1, mac, 6);
memcpy(wh->i_addr3, p->mac, 6);
wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT;
wh->i_fc[0] |= IEEE80211_FC0_SUBTYPE_ASSOC_RESP;
ptr = (char*) (wh+1);
*ptr |= IEEE80211_CAPINFO_ESS;
ptr += 2; /* cap */
ptr += 2; /* status */
ptr += 2; /* aid */
/* rates */
*ptr++ = 1;
*ptr++ = 4;
*ptr++ = 2 | 0x80;
*ptr++ = 4 | 0x80;
*ptr++ = 11;
*ptr++ = 22;
len = ptr - ((char*) wh);
printf("sending assoc response\n");
send_frame(p, wh, len);
}
示例12: main
int main(int argc, char *argv[])
{
#ifdef IMX
int retuid;
retuid = setuid(0); // root me!
if (retuid == -1) {
exit(-10);
}
#endif
// Open the pipe, write the data, close the pipe.
pipe_fd = open("/run/pipelights.3.fifo", O_WRONLY);
if (pipe_fd == -1) {
printf("Failed to open pipe!\n");
exit(-120);
}
since_start(); // initialize the count of when we started execution
// Ok, we're ready to start, so call the setup
setup();
synchronize(1); // And setup the sync function
while (1) {
loop(since_start());
synchronize(20000000); // 50 fps or 20 msec/frame
send_frame(pipe_fd, 0L); // Try to transmit the frame
}
close(pipe_fd); // And close the fifo
return 0;
}
示例13: relay_data
void relay_data(struct params *p, struct ieee80211_frame *wh, int len)
{
char seq[2];
char fc[2];
unsigned short *ps;
/* copy crap */
memcpy(fc, wh->i_fc, 2);
memcpy(seq, wh->i_seq, 2);
/* relay frame */
wh->i_fc[1] &= ~(IEEE80211_FC1_DIR_TODS | IEEE80211_FC1_RETRY);
wh->i_fc[1] |= IEEE80211_FC1_DIR_FROMDS;
memcpy(wh->i_addr1, wh->i_addr3, sizeof(wh->i_addr1));
memcpy(wh->i_addr3, wh->i_addr2, sizeof(wh->i_addr3));
memcpy(wh->i_addr2, p->mac, sizeof(wh->i_addr2));
ps = (unsigned short*)wh->i_seq;
*ps = seqfn(p->seq, 0);
send_frame(p, wh, len);
enque(p, wh, len);
/* restore */
memcpy(wh->i_fc, fc, sizeof(fc));
memcpy(wh->i_addr2, wh->i_addr3, sizeof(wh->i_addr2));
memcpy(wh->i_addr3, wh->i_addr1, sizeof(wh->i_addr2));
memcpy(wh->i_addr1, p->mac, sizeof(wh->i_addr1));
memcpy(wh->i_seq, seq, sizeof(seq));
}
示例14: send_beacon
void send_beacon(struct params *p)
{
char buf[4096];
struct ieee80211_frame *wh;
int len;
char *ptr;
wh = (struct ieee80211_frame*) buf;
memset(buf, 0, sizeof(buf));
fill_basic(wh, p);
memset(wh->i_addr1, 0xff, 6);
memcpy(wh->i_addr3, p->mac, 6);
wh->i_fc[0] |= IEEE80211_FC0_TYPE_MGT;
wh->i_fc[0] |= IEEE80211_FC0_SUBTYPE_BEACON;
len = fill_beacon(p, wh);
/* TIM */
ptr = (char*)wh + len;
*ptr++ = 5;
*ptr++ = 4;
len += 2+4;
#if 0
printf("sending beacon\n");
#endif
send_frame(p, wh, len);
if (gettimeofday(&p->blast, NULL) == -1)
err(1, "gettimeofday()");
}
示例15: can_echo_gen
static int can_echo_gen(void)
{
struct can_frame tx_frames[CAN_MSG_COUNT];
struct can_frame rx_frame;
unsigned char counter = 0;
int send_pos = 0, recv_pos = 0, unprocessed = 0, loops = 0;
int i;
while (running) {
if (unprocessed < CAN_MSG_COUNT) {
/* still send messages */
tx_frames[send_pos].can_dlc = CAN_MSG_LEN;
tx_frames[send_pos].can_id = CAN_MSG_ID;
for (i = 0; i < CAN_MSG_LEN; i++)
tx_frames[send_pos].data[i] = counter + i;
if (send_frame(&tx_frames[send_pos]))
return -1;
/* increment to be equal to expected */
tx_frames[send_pos].can_id++;
for (i = 0; i < CAN_MSG_LEN; i++)
tx_frames[send_pos].data[i]++;
send_pos++;
if (send_pos == CAN_MSG_COUNT)
send_pos = 0;
unprocessed++;
if (verbose == 1)
echo_progress(counter);
counter++;
if ((counter % 33) == 0)
millisleep(3);
else
millisleep(1);
} else {
if (recv_frame(&rx_frame))
return -1;
if (verbose > 1)
print_frame(&rx_frame);
/* compare with expected */
compare_frame(&tx_frames[recv_pos], &rx_frame);
loops++;
if (test_loops && loops >= test_loops)
break;
recv_pos++;
if (recv_pos == CAN_MSG_COUNT)
recv_pos = 0;
unprocessed--;
}
}
printf("\nTest messages sent and received: %d\n", loops);
return 0;
}