当前位置: 首页>>代码示例>>C++>>正文


C++ queuebuf_to_packetbuf函数代码示例

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


在下文中一共展示了queuebuf_to_packetbuf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qsend_list

/*---------------------------------------------------------------------------*/
static void
qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
  struct rdc_buf_list *curr = buf_list;
  struct rdc_buf_list *next;
  int ret;
  int is_receiver_awake;
  
  if(curr == NULL) {
    return;
  }
  /* Do not send during reception of a burst */
  if(we_are_receiving_burst) {
    /* Prepare the packetbuf for callback */
    queuebuf_to_packetbuf(curr->buf);
    /* Return COLLISION so the MAC may try again later */
    mac_call_sent_callback(sent, ptr, MAC_TX_COLLISION, 1);
    return;
  }
  /* The receiver needs to be awoken before we send */
  is_receiver_awake = 0;
  do { /* A loop sending a burst of packets from buf_list */
    next = list_item_next(curr);

    /* Prepare the packetbuf */
    queuebuf_to_packetbuf(curr->buf);
    if(next != NULL) {
      packetbuf_set_attr(PACKETBUF_ATTR_PENDING, 1);
    }

    /* Send the current packet */
    ret = send_packet(sent, ptr, curr, is_receiver_awake);
    if(ret != MAC_TX_DEFERRED) {
      mac_call_sent_callback(sent, ptr, ret, 1);
    }

    if(ret == MAC_TX_OK) {
      if(next != NULL) {
        /* We're in a burst, no need to wake the receiver up again */
        is_receiver_awake = 1;
        curr = next;
      }
    } else {
      /* The transmission failed, we stop the burst */
      next = NULL;
    }
  } while(next != NULL);
}
开发者ID:alesko,项目名称:contiki,代码行数:49,代码来源:contikimac.c

示例2: send_list

/*---------------------------------------------------------------------------*/
static void send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list) {
    // printf("WPI-MAC-send_list(), node ID: %u\n", node_id);
    if(buf_list != NULL) {
        queuebuf_to_packetbuf(buf_list->buf);
        send_packet(sent, ptr);
    }
}
开发者ID:chrnola,项目名称:contiki_wpimac,代码行数:8,代码来源:wpimac.c

示例3: transmit_queued_packet

/*---------------------------------------------------------------------------*/
static void
transmit_queued_packet(void *ptr)
{
  /*  struct queued_packet *q = ptr;*/
  struct queued_packet *q;

  /* Don't transmit a packet if the RDC is still transmitting the
     previous one. */
  if(rdc_is_transmitting) {
    return;
  }
  
  //  printf("q %d\n", list_length(queued_packet_list));

  q = list_head(queued_packet_list);

  if(q != NULL) {
    queuebuf_to_packetbuf(q->buf);
    PRINTF("csma: sending number %d %p, queue len %d\n", q->transmissions, q,
           list_length(queued_packet_list));
    //    printf("s %d\n", packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0]);
    rdc_is_transmitting = 1;
    NETSTACK_RDC.send(packet_sent, q);
  }
}
开发者ID:lepton-distribution,项目名称:lepton,代码行数:26,代码来源:csma.c

示例4: found_route

/*---------------------------------------------------------------------------*/
static void
found_route(struct route_discovery_conn *rdc, const rimeaddr_t *dest)
{
  struct route_entry *rt;
  struct mesh_conn *c = (struct mesh_conn *)
    ((char *)rdc - offsetof(struct mesh_conn, route_discovery_conn));

  PRINTF("found_route\n");

  if(c->queued_data != NULL &&
     rimeaddr_cmp(dest, &c->queued_data_dest)) {
    queuebuf_to_packetbuf(c->queued_data);
    queuebuf_free(c->queued_data);
    c->queued_data = NULL;

    rt = route_lookup(dest);
    if(rt != NULL) {
      multihop_resend(&c->multihop, &rt->R_next_addr);
      if(c->cb->sent != NULL) {
        c->cb->sent(c);
      }
    } else {
      if(c->cb->timedout != NULL) {
        c->cb->timedout(c);
      }
    }
  }
}
开发者ID:adrianhihi,项目名称:LOADng,代码行数:29,代码来源:mesh.backup.c

示例5: send_broadcast

/*---------------------------------------------------------------------------*/
static void
send_broadcast(mac_callback_t sent, void *ptr)
{
    struct queuebuf *qb;

    qb = queuebuf_new_from_packetbuf();
    if(!qb || (NETSTACK_FRAMER.create() < 0)) {
        PRINTF("coresec-strategy: Did not send broadcast\n");
        if(qb) {
            queuebuf_free(qb);
        }
        sent(ptr, MAC_TX_ERR, 0);
        return;
    }

    prepare_announce();
    adaptivesec_send_command_frame();
    watchdog_periodic();

    queuebuf_to_packetbuf(qb);
    queuebuf_free(qb);
#if WITH_BROADCAST_ENCRYPTION
    {
        uint8_t ignore[ADAPTIVESEC_BROADCAST_MIC_LEN];

        if(packetbuf_attr(PACKETBUF_ATTR_SECURITY_LEVEL) & (1 << 2)) {
            adaptivesec_aead(adaptivesec_group_key, 1, ignore, 1);
        }
    }
#endif /* WITH_BROADCAST_ENCRYPTION */
    NETSTACK_MAC.send(sent, ptr);
}
开发者ID:hpiseth,项目名称:contiki,代码行数:33,代码来源:coresec-strategy.c

示例6: qsend_list

/*---------------------------------------------------------------------------*/
static void
qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
  if(buf_list != NULL) {
    queuebuf_to_packetbuf(buf_list->buf);
    qsend_packet(sent, ptr);
  }
}
开发者ID:lanada-sensor,项目名称:plb,代码行数:9,代码来源:xmac.c

示例7: send_queued_packet

/*---------------------------------------------------------------------------*/
static void
send_queued_packet(void)
{
    struct queuebuf *q;
    struct neighbor *n;
    struct packetqueue_item *i;
    struct collect_conn *c;

    i = packetqueue_first(&forwarding_queue);
    if(i == NULL) {
        PRINTF("%d.%d: nothing on queue\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1]);
        /* No packet on the queue, so there is nothing for us to send. */
        return;
    }
    c = packetqueue_ptr(i);
    if(c == NULL) {
        /* c should not be NULL, but we check it just to be sure. */
        PRINTF("%d.%d: queue, c == NULL!\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1]);
        return;
    }

    if(c->forwarding) {
        /* If we are currently forwarding a packet, we wait until the
           packet is forwarded and try again then. */
        PRINTF("%d.%d: queue, c is forwarding\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1]);
        return;
    }

    q = packetqueue_queuebuf(i);
    if(q != NULL) {
        PRINTF("%d.%d: queue, q is on queue\n",
               rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1]);
        queuebuf_to_packetbuf(q);

        n = neighbor_best();

        /* Don't send to the neighbor if it is the same neighbor that sent
           us the packet. */
        if(n != NULL && !rimeaddr_cmp(&n->addr, packetbuf_addr(PACKETBUF_ADDR_SENDER))) {
#if CONTIKI_TARGET_NETSIM
            ether_set_line(n->addr.u8[0], n->addr.u8[1]);
#endif /* CONTIKI_TARGET_NETSIM */
            PRINTF("%d.%d: sending packet to %d.%d\n",
                   rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1],
                   n->addr.u8[RIMEADDR_SIZE-2], n->addr.u8[RIMEADDR_SIZE-1]);

            c->forwarding = 1;
            runicast_send(&c->runicast_conn, &n->addr, packetbuf_attr(PACKETBUF_ATTR_MAX_REXMIT));
        } else {
            PRINTF("%d.%d: did not find any neighbor to forward to\n",
                   rimeaddr_node_addr.u8[RIMEADDR_SIZE-2], rimeaddr_node_addr.u8[RIMEADDR_SIZE-1]);
        }
    }
}
开发者ID:kincki,项目名称:contiki,代码行数:58,代码来源:collect.c

示例8: recv_from_ipolite

/*---------------------------------------------------------------------------*/
static void
recv_from_ipolite(struct ipolite_conn *ipolite, const rimeaddr_t *from)
{
    PRINTF("%d.%d: netflood recv_from_ipolite\n",
	   rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);

  struct netflood_conn *c = (struct netflood_conn *)ipolite;
  struct netflood_hdr hdr;
  uint8_t hops;
  struct queuebuf *queuebuf;

  memcpy(&hdr, packetbuf_dataptr(), sizeof(struct netflood_hdr));
  hops = hdr.hops;

  /* Remember packet if we need to forward it. */
  queuebuf = queuebuf_new_from_packetbuf();

  packetbuf_hdrreduce(sizeof(struct netflood_hdr));
  if(c->u->recv != NULL) {
    if(!(rimeaddr_cmp(&hdr.originator, &c->last_originator) &&
	 hdr.originator_seqno <= c->last_originator_seqno)) {

      if(c->u->recv(c, from, &hdr.originator, hdr.originator_seqno,
		    hops)) {
	
	if(queuebuf != NULL) {
	  queuebuf_to_packetbuf(queuebuf);
	  queuebuf_free(queuebuf);
	  queuebuf = NULL;
	  memcpy(&hdr, packetbuf_dataptr(), sizeof(struct netflood_hdr));
	  
	  /* Rebroadcast received packet. */
	  if(hops < HOPS_MAX) {
	    PRINTF("%d.%d: netflood rebroadcasting %d.%d/%d (%d.%d/%d) hops %d\n",
		   rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
		   hdr.originator.u8[0], hdr.originator.u8[1],
		   hdr.originator_seqno,
		   c->last_originator.u8[0], c->last_originator.u8[1],
		   c->last_originator_seqno,
		  hops);
	    hdr.hops++;
	    memcpy(packetbuf_dataptr(), &hdr, sizeof(struct netflood_hdr));
	    send(c);
	    rimeaddr_copy(&c->last_originator, &hdr.originator);
	    c->last_originator_seqno = hdr.originator_seqno;
	  }
	}
      }
    }
  }
  if(queuebuf != NULL) {
    queuebuf_free(queuebuf);
  }
}
开发者ID:persuader72,项目名称:contiki,代码行数:55,代码来源:netflood.c

示例9: send_list

/*---------------------------------------------------------------------------*/
uint8_t
send_list(struct net_buf *buf, mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
  if(buf_list != NULL) {
    queuebuf_to_packetbuf(buf, buf_list->buf);
    if (!send_packet(buf, sent, ptr)) {
      return 0;
    }
  }

  return 1;
}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:13,代码来源:sicslowmac.c

示例10: send

/*---------------------------------------------------------------------------*/
static void
send(void *ptr) {
    struct trickle_conn *c = ptr;

    if (c->q != NULL) {
        queuebuf_to_packetbuf(c->q);
        broadcast_send(&c->c);
    } else {
        PRINTF("%d.%d: trickle send but c->q == NULL\n",
                rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]);
    }
}
开发者ID:DIYzzuzpb,项目名称:contiki-mplabx,代码行数:13,代码来源:trickle.c

示例11: send

/*---------------------------------------------------------------------------*/
static void
send(void *ptr)
{
  struct stbroadcast_conn *c = ptr;

  /*  DEBUGF(3, "stbroadcast: send()\n");*/
  queuebuf_to_packetbuf(c->buf);
  broadcast_send(&c->c);
  ctimer_reset(&c->t);
  if(c->u->sent != NULL) {
    c->u->sent(c);
  }
}
开发者ID:EDAyele,项目名称:wsn430,代码行数:14,代码来源:stbroadcast.c

示例12: found_route

/*---------------------------------------------------------------------------*/
static void
found_route(struct route_discovery_conn *rdc, rimeaddr_t *dest)
{
  struct mesh_conn *c = (struct mesh_conn *)
    ((char *)rdc - offsetof(struct mesh_conn, route_discovery_conn));

  if(c->queued_data != NULL &&
     rimeaddr_cmp(dest, &c->queued_data_dest)) {
    queuebuf_to_packetbuf(c->queued_data);
    queuebuf_free(c->queued_data);
    c->queued_data = NULL;
    multihop_send(&c->multihop, dest);
  }
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:15,代码来源:mesh.c

示例13: send

/*---------------------------------------------------------------------------*/
static void
send(void *ptr)
{
  struct polite_conn *c = ptr;

  if(c->q != NULL) {
    queuebuf_to_packetbuf(c->q);
    queuebuf_free(c->q);
    c->q = NULL;
    abc_send(&c->c);
    if(c->cb->sent) {
	c->cb->sent(c);
    }
  }
}
开发者ID:EmuxEvans,项目名称:calipso,代码行数:16,代码来源:polite.c

示例14: send_packet

/*---------------------------------------------------------------------------*/
static void
send_packet(void *ptr)
{
  struct phase_queueitem *p = ptr;

  if(p->buf_list == NULL) {
    queuebuf_to_packetbuf(p->q);
    queuebuf_free(p->q);
    NETSTACK_RDC.send(p->mac_callback, p->mac_callback_ptr);
  } else {
    NETSTACK_RDC.send_list(p->mac_callback, p->mac_callback_ptr, p->buf_list);
  }

  memb_free(&queued_packets_memb, p);
}
开发者ID:DIYzzuzpb,项目名称:contiki-mplabx,代码行数:16,代码来源:phase.c

示例15: send

/*---------------------------------------------------------------------------*/
static void
send(void *ptr)
{
  struct stunicast_conn *c = ptr;

  PRINTF("%d.%d: stunicast: resend to %d.%d\n",
	 rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
	 c->receiver.u8[0], c->receiver.u8[1]);
	 if(c->buf) {
  	queuebuf_to_packetbuf(c->buf);
  	unicast_send(&c->c, &c->receiver);
  	stunicast_set_timer(c, CLOCK_SECOND);
  }
  /*  if(c->u->sent != NULL) {
    c->u->sent(c);
    }*/
}
开发者ID:Sowhat2112,项目名称:KreyosFirmware,代码行数:18,代码来源:stunicast.c


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