本文整理汇总了C++中packetbuf_totlen函数的典型用法代码示例。如果您正苦于以下问题:C++ packetbuf_totlen函数的具体用法?C++ packetbuf_totlen怎么用?C++ packetbuf_totlen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了packetbuf_totlen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: packet_input
/*---------------------------------------------------------------------------*/
static void
packet_input(void)
{
#if NETSTACK_CONF_WITH_IP64
/* If NAT64 is enabled, IPv4 & ARP packets are sent to the IP64 module */
ethernet_header_t *hdr = (ethernet_header_t *)packetbuf_hdrptr();
if (hdr->et_protlen == UIP_HTONS(ETH_PROT_IP) ||
hdr->et_protlen == UIP_HTONS(ETH_PROT_ARP)) {
IP64_INPUT(packetbuf_hdrptr(), packetbuf_totlen());
return;
}
#endif /* NETSTACK_CONF_WITH_IP64 */
if(NETSTACK_0_FRAMER.parse() < 0) {
PRINTF("ieee8023_mac: failed to parse %u\n", (unsigned int)packetbuf_datalen());
#if IEEE8023_MAC_ADDRESS_FILTER
} else if(!linkaddr6_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr6_node_addr) &&
!linkaddr6_cmp(packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
&linkaddr6_null)) {
/*\note The framer should have done the multicast address
* translation from 0x33 0x33 0xXX... to the 802.3xx null
*/
PRINTF("ieee8023_mac: not for us\n");
#endif /* IEEE8023_MAC_ADDRESS_FILTER */
} else {
int duplicate = 0;
duplicate = mac_sequence_is_duplicate();
if(duplicate && ETH_SUPPORT_DUPLICATE_DETECTION) {
/* Drop the packet. */
PRINTF("ieee8023_mac: drop duplicate link layer packet %u\n",
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID));
} else {
mac_sequence_register_seqno();
}
#if DEBUG
int i;
uint16_t original_datalen = packetbuf_totlen();
uint8_t *original_dataptr = packetbuf_hdrptr();
PRINTF("PKT[%u]:",original_datalen);
for (i=0; i<original_datalen; i++) {
PRINTF("%02x ",original_dataptr[i]);
}
PRINTF("\n");
#endif
if(!(duplicate && ETH_SUPPORT_DUPLICATE_DETECTION)) {
link_if_in(NETSTACK_8023);
NETSTACK_0_NETWORK.input();
link_if_in(NETSTACK_NULL);
} else {
PRINTF("IEEE8023_MAC: drop duplicate\n");
}
}
}
开发者ID:ioannisg,项目名称:Contiki_ATSAM4EXPRO,代码行数:56,代码来源:ieee8023_mac.c
示例2: send_packet
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
int size;
/* 3 bytes per packet attribute is required for serialization */
uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3];
int sid;
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &linkaddr_node_addr);
/* ack or not ? */
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
if(NETSTACK_FRAMER.create_and_secure() < 0) {
/* Failed to allocate space for headers */
LOG6LBR_ERROR("br-rdc: send failed, too large header\n");
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
} else {
/* here we send the data over SLIP to the radio-chip */
size = 0;
if(sixlbr_config_slip_serialize_tx_attrs) {
size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
}
if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
LOG6LBR_ERROR("br-rdc: send failed, too large header\n");
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
} else {
sid = setup_callback(sent, ptr);
if (sid != -1) {
LOG6LBR_PRINTF(PACKET, RADIO_OUT, "write: %d (sid: %d, cb: %d)\n", packetbuf_datalen(), sid, callback_count);
LOG6LBR_DUMP_PACKET(RADIO_OUT, packetbuf_dataptr(), packetbuf_datalen());
buf[0] = '!';
buf[1] = 'S';
buf[2] = sid; /* sequence or session number for this packet */
/* Copy packet data */
memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen());
callbacks[sid].buf_len = packetbuf_totlen() + size + 3;
memcpy(callbacks[sid].buf, buf, callbacks[sid].buf_len);
write_to_slip(buf, callbacks[sid].buf_len);
} else {
LOG6LBR_INFO("native-rdc queue full\n");
mac_call_sent_callback(sent, ptr, MAC_TX_NOACK, 1);
}
}
}
}
开发者ID:msolters,项目名称:6lbr,代码行数:51,代码来源:native-rdc.c
示例3: send_announcement
static void
send_announcement(void *ptr)
{
struct xmac_hdr *hdr;
int announcement_len;
/* Set up the probe header. */
packetbuf_clear();
hdr = packetbuf_dataptr();
announcement_len = format_announcement((char *)hdr +
sizeof(struct xmac_hdr));
if(announcement_len > 0) {
packetbuf_set_datalen(sizeof(struct xmac_hdr) + announcement_len);
hdr->dispatch = DISPATCH;
hdr->type = TYPE_ANNOUNCEMENT;
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &rimeaddr_null);
packetbuf_set_attr(PACKETBUF_ATTR_RADIO_TXPOWER, announcement_radio_txpower);
if(NETSTACK_FRAMER.create() >= 0) {
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
}
}
}
开发者ID:lanada-sensor,项目名称:plb,代码行数:26,代码来源:xmac.c
示例4: plb_send
/*---------------------------------------------------------------------------*/
static void
plb_send(mac_callback_t sent, void *ptr)
{
PRINTF("plb_send\n");
if ( packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == 0 ) //data
{
PRINTF("plb_send : DATA\n");
send_req = 1;
sent_callback = sent;
sent_ptr = ptr;
//packetbuf_clear_hdr();
temp_len=packetbuf_datalen();
packetbuf_copyto(dataptr_temp);
print_packet(dataptr_temp,packetbuf_totlen());//JJH3
}
//kdw sync
else if ( packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == 1 ) //sync
{
sent_callback = sent;
sent_ptr = ptr;
plb_send_sync_start();
}
else // error
{
mac_call_sent_callback(sent, ptr, MAC_TX_ERR, 1); //error fill this
}
return;
}
开发者ID:deawoo,项目名称:contiki-2.7-plb,代码行数:31,代码来源:plb_backup_0218.c
示例5: packetbuf_hdralloc
/*---------------------------------------------------------------------------*/
int
packetbuf_hdralloc(int size)
{
int16_t i;
if(size + packetbuf_totlen() > PACKETBUF_SIZE) {
return 0;
}
/* shift data to the right */
for(i = packetbuf_totlen() - 1; i >= 0; i--) {
packetbuf[i + size] = packetbuf[i];
}
hdrlen += size;
return 1;
}
开发者ID:13416795,项目名称:contiki,代码行数:17,代码来源:packetbuf.c
示例6: send_packet
/*---------------------------------------------------------------------------*/
static int
send_packet(void)
{
if(radio->send(packetbuf_hdrptr(), packetbuf_totlen()) == RADIO_TX_OK) {
return MAC_TX_OK;
}
return MAC_TX_ERR;
}
开发者ID:arbraham,项目名称:hummingbird,代码行数:9,代码来源:nullmac.c
示例7: send_data
/*---------------------------------------------------------------------------*/
static void
send_data(linkaddr_t *next)
{
PRINTF("uip-over-mesh: %d.%d: send_data with len %d\n",
linkaddr_node_addr.u8[0], linkaddr_node_addr.u8[1],
packetbuf_totlen());
unicast_send(&dataconn, next);
}
开发者ID:exziled,项目名称:WeatherSystem,代码行数:9,代码来源:uip-over-mesh.c
示例8: handle_beacon_send_timer
/*---------------------------------------------------------------------------*/
static void
handle_beacon_send_timer(struct net_buf *buf, void *p)
{
struct net_buf *mbuf;
frame802154_t params;
uint8_t len;
mbuf = l2_buf_get_reserve(0);
if(!mbuf) {
return;
}
/* init to zeros */
memset(¶ms, 0, sizeof(params));
/* use packetbuf for sending ?? */
packetbuf_clear(mbuf);
/* Build the FCF. */
params.fcf.frame_type = FRAME802154_BEACONFRAME;
/* Insert IEEE 802.15.4 (2006) version bits. */
params.fcf.frame_version = FRAME802154_IEEE802154_2006;
/* assume long for now */
params.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
linkaddr_copy((linkaddr_t *)¶ms.src_addr, &linkaddr_node_addr);
/* Set the source PAN ID to the global variable. */
params.src_pid = panid;
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
params.dest_addr[0] = 0xFF;
params.dest_addr[1] = 0xFF;
params.dest_pid = 0xffff;
params.seq = framer_802154_next_seqno();
/* Calculate beacon length and copy it to packetbuf */
beacon_payload_len = handler_802154_calculate_beacon_payload_length(beacon_payload, BEACON_PAYLOAD_BUFFER_SIZE);
packetbuf_copyfrom(mbuf, beacon_payload, beacon_payload_len);
/* Set payload and payload length */
params.payload = packetbuf_dataptr(mbuf);
params.payload_len = packetbuf_datalen(mbuf);
len = frame802154_hdrlen(¶ms);
if(packetbuf_hdralloc(mbuf, len)) {
frame802154_create(¶ms, packetbuf_hdrptr(mbuf), len);
if(NETSTACK_RADIO.send(mbuf, packetbuf_hdrptr(mbuf),
packetbuf_totlen(mbuf)) != RADIO_TX_OK) {
l2_buf_unref(mbuf);
return;
}
HANDLER_802154_STAT(handler_802154_stats.beacons_sent++);
}
}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:59,代码来源:handler-802154.c
示例9: parse
/*---------------------------------------------------------------------------*/
static int
parse(void)
{
frame802154_t frame;
int hdr_len;
hdr_len = frame802154_parse(packetbuf_dataptr(), packetbuf_datalen(), &frame);
if(hdr_len && packetbuf_hdrreduce(hdr_len)) {
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, frame.fcf.frame_type);
if(frame.fcf.dest_addr_mode) {
if(frame.dest_pid != frame802154_get_pan_id() &&
frame.dest_pid != FRAME802154_BROADCASTPANDID) {
/* Packet to another PAN */
PRINTF("15.4: for another pan %u\n", frame.dest_pid);
return FRAMER_FAILED;
}
if(!frame802154_is_broadcast_addr(frame.fcf.dest_addr_mode, frame.dest_addr)) {
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, (linkaddr_t *)&frame.dest_addr);
}
}
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (linkaddr_t *)&frame.src_addr);
packetbuf_set_attr(PACKETBUF_ATTR_PENDING, frame.fcf.frame_pending);
if(frame.fcf.sequence_number_suppression == 0) {
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, frame.seq);
} else {
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, 0xffff);
}
#if NETSTACK_CONF_WITH_RIME
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.seq);
#endif
#if LLSEC802154_USES_AUX_HEADER
if(frame.fcf.security_enabled) {
packetbuf_set_attr(PACKETBUF_ATTR_SECURITY_LEVEL, frame.aux_hdr.security_control.security_level);
#if LLSEC802154_USES_FRAME_COUNTER
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, frame.aux_hdr.frame_counter.u16[0]);
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, frame.aux_hdr.frame_counter.u16[1]);
#endif /* LLSEC802154_USES_FRAME_COUNTER */
#if LLSEC802154_USES_EXPLICIT_KEYS
packetbuf_set_attr(PACKETBUF_ATTR_KEY_ID_MODE, frame.aux_hdr.security_control.key_id_mode);
packetbuf_set_attr(PACKETBUF_ATTR_KEY_INDEX, frame.aux_hdr.key_index);
packetbuf_set_attr(PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1, frame.aux_hdr.key_source.u16[0]);
#endif /* LLSEC802154_USES_EXPLICIT_KEYS */
}
#endif /* LLSEC802154_USES_AUX_HEADER */
PRINTF("15.4-IN: %2X", frame.fcf.frame_type);
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_RECEIVER));
PRINTF("%d %u (%u)\n", hdr_len, packetbuf_datalen(), packetbuf_totlen());
return hdr_len;
}
return FRAMER_FAILED;
}
开发者ID:13416795,项目名称:contiki,代码行数:58,代码来源:framer-802154.c
示例10: parse
/*---------------------------------------------------------------------------*/
static int
parse(struct net_buf *buf)
{
frame802154_t frame;
int hdr_len;
hdr_len = frame802154_parse(packetbuf_dataptr(buf), packetbuf_datalen(buf), &frame);
if(hdr_len && packetbuf_hdrreduce(buf, hdr_len)) {
packetbuf_set_attr(buf, PACKETBUF_ATTR_FRAME_TYPE, frame.fcf.frame_type);
if(frame.fcf.dest_addr_mode) {
if(frame.dest_pid != mac_src_pan_id &&
frame.dest_pid != FRAME802154_BROADCASTPANDID) {
/* Packet to another PAN */
PRINTF("15.4: for another pan %u (0x%x)\n", frame.dest_pid,
frame.dest_pid);
return FRAMER_FAILED;
}
if(!is_broadcast_addr(frame.fcf.dest_addr_mode, frame.dest_addr)) {
packetbuf_set_addr(buf, PACKETBUF_ADDR_RECEIVER, (linkaddr_t *)&frame.dest_addr);
}
}
packetbuf_set_addr(buf, PACKETBUF_ADDR_SENDER, (linkaddr_t *)&frame.src_addr);
packetbuf_set_attr(buf, PACKETBUF_ATTR_PENDING, frame.fcf.frame_pending);
/* packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, frame.fcf.ack_required);*/
packetbuf_set_attr(buf, PACKETBUF_ATTR_PACKET_ID, frame.seq);
#if LLSEC802154_SECURITY_LEVEL
if(frame.fcf.security_enabled) {
packetbuf_set_attr(buf, PACKETBUF_ATTR_SECURITY_LEVEL, frame.aux_hdr.security_control.security_level);
packetbuf_set_attr(buf, PACKETBUF_ATTR_FRAME_COUNTER_BYTES_0_1, frame.aux_hdr.frame_counter.u16[0]);
packetbuf_set_attr(buf, PACKETBUF_ATTR_FRAME_COUNTER_BYTES_2_3, frame.aux_hdr.frame_counter.u16[1]);
#if LLSEC802154_USES_EXPLICIT_KEYS
packetbuf_set_attr(buf, PACKETBUF_ATTR_KEY_ID_MODE, frame.aux_hdr.security_control.key_id_mode);
packetbuf_set_attr(buf, PACKETBUF_ATTR_KEY_INDEX, frame.aux_hdr.key_index);
packetbuf_set_attr(buf, PACKETBUF_ATTR_KEY_SOURCE_BYTES_0_1, frame.aux_hdr.key_source.u16[0]);
#endif /* LLSEC802154_USES_EXPLICIT_KEYS */
}
#endif /* LLSEC802154_SECURITY_LEVEL */
PRINTF("15.4-IN: %2X ", frame.fcf.frame_type);
PRINTLLADDR((const uip_lladdr_t *)packetbuf_addr(buf, PACKETBUF_ADDR_SENDER));
PRINTF(" ");
PRINTLLADDR((const uip_lladdr_t *)packetbuf_addr(buf, PACKETBUF_ADDR_RECEIVER));
PRINTF(" %d %u (%u)\n", hdr_len, packetbuf_datalen(buf), packetbuf_totlen(buf));
#ifdef FRAMER_802154_HANDLER
if(FRAMER_802154_HANDLER(&frame)) {
return FRAMER_FRAME_HANDLED;
}
#endif
return hdr_len;
}
return FRAMER_FAILED;
}
开发者ID:32bitmicro,项目名称:zephyr,代码行数:58,代码来源:framer-802154.c
示例11: packetbuf_hdralloc
/*---------------------------------------------------------------------------*/
int
packetbuf_hdralloc(int size)
{
if(hdrptr >= size && packetbuf_totlen() + size <= PACKETBUF_SIZE) {
hdrptr -= size;
return 1;
}
return 0;
}
开发者ID:kamejoko80,项目名称:emb6,代码行数:10,代码来源:packetbuf.c
示例12: input_printsniffer
/*---------------------------------------------------------------------------*/
static void
input_printsniffer(void)
{
static int seqno = 0;
sniffprint("I", seqno++);
if(packetbuf_attr(PACKETBUF_ATTR_CHANNEL) == 0) {
int i;
uint8_t *dataptr;
printf("x %d ", packetbuf_totlen());
dataptr = packetbuf_hdrptr();
printf("%02x ", dataptr[0]);
for(i = 1; i < packetbuf_totlen(); ++i) {
printf("%02x ", dataptr[i]);
}
printf("\n");
}
}
开发者ID:pvhau,项目名称:contiki-ext,代码行数:20,代码来源:powertrace.c
示例13: incoming_packet
static void incoming_packet(void) {
int length = packetbuf_totlen();
int noise = cc2420_rssi();
int crc_ok = -1;
int rssi = packetbuf_attr(PACKETBUF_ATTR_RSSI);
int lqi = packetbuf_attr(PACKETBUF_ATTR_LINK_QUALITY);
noise = cc2420_rssi();
dump_packet(packetbuf_dataptr(), length, crc_ok, rssi, noise, lqi);
}
开发者ID:Badisso,项目名称:econotag-link,代码行数:10,代码来源:receiver.c
示例14: send_packet
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
int size;
/* 3 bytes per packet attribute is required for serialization */
uint8_t buf[PACKETBUF_NUM_ATTRS * 3 + PACKETBUF_SIZE + 3];
uint8_t sid;
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, &rimeaddr_node_addr);
/* ack or not ? */
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
if(NETSTACK_FRAMER.create() < 0) {
/* Failed to allocate space for headers */
PRINTF("br-rdc: send failed, too large header\n");
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
} else {
/* here we send the data over SLIP to the radio-chip */
size = 0;
#if SERIALIZE_ATTRIBUTES
size = packetutils_serialize_atts(&buf[3], sizeof(buf) - 3);
#endif
if(size < 0 || size + packetbuf_totlen() + 3 > sizeof(buf)) {
PRINTF("br-rdc: send failed, too large header\n");
mac_call_sent_callback(sent, ptr, MAC_TX_ERR_FATAL, 1);
} else {
PRINTF("SLIP: Sending %d\n", packetbuf_totlen());
sid = setup_callback(sent, ptr);
buf[0] = '!';
buf[1] = 'S';
buf[2] = sid; /* sequence or session number for this packet */
/* Copy packet data */
memcpy(&buf[3 + size], packetbuf_hdrptr(), packetbuf_totlen());
write_to_slip(buf, packetbuf_totlen() + size + 3);
}
}
}
开发者ID:calvincoetzee,项目名称:6lbr,代码行数:44,代码来源:native-rdc.c
示例15: send_packet
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
int ret;
if(NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()) == RADIO_TX_OK) {
ret = MAC_TX_OK;
} else {
ret = MAC_TX_ERR;
}
mac_call_sent_callback(sent, ptr, ret, 1);
}
开发者ID:paolope,项目名称:Contiki-MspCodeWatcherImproved,代码行数:12,代码来源:nullrdc-noframer.c
示例16: send_packet
/*---------------------------------------------------------------------------*/
static int
send_packet(void)
{
const rimeaddr_t *addr;
addr = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
PRINTF("rime-udp: Sending %d bytes to %d.%d\n", packetbuf_totlen(),
addr->u8[RIMEADDR_SIZE-2], addr->u8[RIMEADDR_SIZE-1]);
if(rimeaddr_cmp(&rimeaddr_null, addr)) {
uip_udp_packet_send(broadcast_conn,
packetbuf_hdrptr(), packetbuf_totlen());
} else {
uip_ip6addr(&unicast_conn->ripaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
uip_netif_addr_autoconf_set(&unicast_conn->ripaddr, (uip_lladdr_t *)addr);
uip_udp_packet_send(unicast_conn,
packetbuf_hdrptr(), packetbuf_totlen());
uip_create_unspecified(&unicast_conn->ripaddr);
}
return 1;
}
开发者ID:kincki,项目名称:contiki,代码行数:22,代码来源:rime-udp.c
示例17: send_packet
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent_callback, void *ptr)
{
const rimeaddr_t *addr;
addr = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
PRINTF("rime-udp: Sending %d bytes to %d.%d\n", packetbuf_totlen(),
addr->u8[0], addr->u8[1]);
if(rimeaddr_cmp(&rimeaddr_null, addr)) {
uip_udp_packet_send(broadcast_conn,
packetbuf_hdrptr(), packetbuf_totlen());
mac_call_sent_callback(sent_callback, ptr, MAC_TX_OK, 1);
} else {
uip_ip6addr(&unicast_conn->ripaddr, 0xfe80, 0, 0, 0, 0, 0, 0, 0);
uip_netif_addr_autoconf_set(&unicast_conn->ripaddr, (uip_lladdr_t *)addr);
uip_udp_packet_send(unicast_conn,
packetbuf_hdrptr(), packetbuf_totlen());
uip_create_unspecified(&unicast_conn->ripaddr);
}
return;
}
开发者ID:EmuxEvans,项目名称:ContikiCC2530Port,代码行数:23,代码来源:rime-udp.c
示例18: send_probe
/**
* Send a probe packet.
*/
static void
send_probe(void)
{
struct lpp_hdr *hdr;
struct announcement_msg *adata;
struct announcement *a;
/* Set up the probe header. */
packetbuf_clear();
packetbuf_set_datalen(sizeof(struct lpp_hdr));
hdr = packetbuf_dataptr();
hdr->type = TYPE_PROBE;
rimeaddr_copy(&hdr->sender, &rimeaddr_node_addr);
/* rimeaddr_copy(&hdr->receiver, packetbuf_addr(PACKETBUF_ADDR_RECEIVER));*/
rimeaddr_copy(&hdr->receiver, &rimeaddr_null);
packetbuf_set_addr(PACKETBUF_ADDR_RECEIVER, &rimeaddr_null);
{
int hdrlen = NETSTACK_FRAMER.create();
if(hdrlen == 0) {
/* Failed to send */
return;
}
}
/* Construct the announcements */
adata = (struct announcement_msg *)((char *)hdr + sizeof(struct lpp_hdr));
adata->num = 0;
for(a = announcement_list(); a != NULL; a = list_item_next(a)) {
adata->data[adata->num].id = a->id;
adata->data[adata->num].value = a->value;
adata->num++;
}
packetbuf_set_datalen(sizeof(struct lpp_hdr) +
ANNOUNCEMENT_MSG_HEADERLEN +
sizeof(struct announcement_data) * adata->num);
/* PRINTF("Sending probe\n");*/
/* printf("probe\n");*/
if(NETSTACK_RADIO.channel_clear()) {
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
} else {
off_time_adjustment = random_rand() % (OFF_TIME / 2);
}
compower_accumulate(&compower_idle_activity);
}
开发者ID:Asterios,项目名称:contiki-econotag,代码行数:54,代码来源:lpp.c
示例19: handler_802154_send_beacon_request
/* called to send a beacon request */
void
handler_802154_send_beacon_request(void)
{
struct net_buf *mbuf;
frame802154_t params;
uint8_t len;
mbuf = l2_buf_get_reserve(0);
if(!mbuf) {
return;
}
/* init to zeros */
memset(¶ms, 0, sizeof(params));
/* use packetbuf for sending ?? */
packetbuf_clear(mbuf);
/* Build the FCF. */
params.fcf.frame_type = FRAME802154_CMDFRAME;
/* Insert IEEE 802.15.4 (2006) version bits. */
params.fcf.frame_version = FRAME802154_IEEE802154_2006;
params.fcf.src_addr_mode = FRAME802154_NOADDR;
params.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
params.dest_addr[0] = 0xFF;
params.dest_addr[1] = 0xFF;
params.dest_pid = 0xffff;
params.seq = chseqno;
packetbuf_set_datalen(mbuf, 1);
params.payload = packetbuf_dataptr(mbuf);
/* set the type in the payload */
params.payload[0] = FRAME802154_BEACONREQ;
params.payload_len = packetbuf_datalen(mbuf);
len = frame802154_hdrlen(¶ms);
if(packetbuf_hdralloc(mbuf, len)) {
frame802154_create(¶ms, packetbuf_hdrptr(mbuf), len);
if(NETSTACK_RADIO.send(mbuf, packetbuf_hdrptr(mbuf),
packetbuf_totlen(mbuf)) != RADIO_TX_OK) {
l2_buf_unref(mbuf);
return;
}
HANDLER_802154_STAT(handler_802154_stats.beacons_reqs_sent++);
}
}
开发者ID:CurieBSP,项目名称:zephyr,代码行数:51,代码来源:handler-802154.c
示例20: pad
/*---------------------------------------------------------------------------*/
static void
pad(void)
{
int transmit_len;
uint8_t *ptr;
uint8_t zeroes_count;
transmit_len = packetbuf_totlen();
if(transmit_len < SHORTEST_PACKET_SIZE) {
/* Padding required */
zeroes_count = SHORTEST_PACKET_SIZE - transmit_len;
ptr = packetbuf_dataptr();
memset(ptr + packetbuf_datalen(), 0, zeroes_count);
packetbuf_set_datalen(packetbuf_datalen() + zeroes_count);
}
}
开发者ID:200018171,项目名称:contiki,代码行数:17,代码来源:contikimac-framer.c
注:本文中的packetbuf_totlen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论