本文整理汇总了C++中NET_DBG函数的典型用法代码示例。如果您正苦于以下问题:C++ NET_DBG函数的具体用法?C++ NET_DBG怎么用?C++ NET_DBG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NET_DBG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_https
static int start_https(struct http_client_ctx *ctx)
{
struct k_sem startup_sync;
/* Start the thread that handles HTTPS traffic. */
if (ctx->https.tid) {
return -EALREADY;
}
NET_DBG("Starting HTTPS thread for %p", ctx);
k_sem_init(&startup_sync, 0, 1);
ctx->https.tid = k_thread_create(&ctx->https.thread,
ctx->https.stack,
ctx->https.stack_size,
(k_thread_entry_t)https_handler,
ctx, &startup_sync, 0,
K_PRIO_COOP(7), 0, 0);
/* Wait until we know that the HTTPS thread startup was ok */
if (k_sem_take(&startup_sync, HTTPS_STARTUP_TIMEOUT) < 0) {
https_shutdown(ctx);
return -ECANCELED;
}
NET_DBG("HTTPS thread %p started for %p", ctx->https.tid, ctx);
return 0;
}
示例2: on_body
static int on_body(struct http_parser *parser, const char *at, size_t length)
{
struct http_client_ctx *ctx = CONTAINER_OF(parser,
struct http_client_ctx,
parser);
ctx->rsp.body_found = 1;
ctx->rsp.processed += length;
NET_DBG("Processed %zd length %zd", ctx->rsp.processed, length);
if (!ctx->rsp.body_start) {
ctx->rsp.body_start = (u8_t *)at;
}
if (ctx->rsp.cb) {
NET_DBG("Calling callback for partitioned %zd len data",
ctx->rsp.data_len);
ctx->rsp.cb(ctx,
ctx->rsp.response_buf,
ctx->rsp.response_buf_len,
ctx->rsp.data_len,
HTTP_DATA_MORE,
ctx->req.user_data);
/* Re-use the result buffer and start to fill it again */
ctx->rsp.data_len = 0;
}
return 0;
}
示例3: net_bt_recv
static enum net_verdict net_bt_recv(struct net_if *iface, struct net_buf *buf)
{
uint32_t src;
uint32_t dst;
NET_DBG("iface %p buf %p len %u", iface, buf, net_buf_frags_len(buf));
/* Uncompress will drop the current fragment. Buf ll src/dst address
* will then be wrong and must be updated according to the new fragment.
*/
src = net_nbuf_ll_src(buf)->addr ?
net_nbuf_ll_src(buf)->addr - net_nbuf_ll(buf) : 0;
dst = net_nbuf_ll_dst(buf)->addr ?
net_nbuf_ll_dst(buf)->addr - net_nbuf_ll(buf) : 0;
if (!net_6lo_uncompress(buf)) {
NET_DBG("Packet decompression failed");
return NET_DROP;
}
net_nbuf_ll_src(buf)->addr = src ? net_nbuf_ll(buf) + src : NULL;
net_nbuf_ll_dst(buf)->addr = dst ? net_nbuf_ll(buf) + dst : NULL;
return NET_CONTINUE;
}
示例4: ipsp_recv
static void ipsp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
struct bt_context *ctxt = CHAN_CTXT(chan);
struct net_buf *nbuf;
NET_DBG("Incoming data channel %p len %u", chan,
net_buf_frags_len(buf));
/* Get buffer for bearer / protocol related data */
nbuf = net_nbuf_get_reserve_rx(0);
/* Set destination address */
net_nbuf_ll_dst(nbuf)->addr = ctxt->src.val;
net_nbuf_ll_dst(nbuf)->len = sizeof(ctxt->src);
/* Set source address */
net_nbuf_ll_src(nbuf)->addr = ctxt->dst.val;
net_nbuf_ll_src(nbuf)->len = sizeof(ctxt->dst);
/* Add data buffer as fragment of RX buffer, take a reference while
* doing so since L2CAP will unref the buffer after return.
*/
net_buf_frag_add(nbuf, net_buf_ref(buf));
if (net_recv_data(ctxt->iface, nbuf) < 0) {
NET_DBG("Packet dropped by NET stack");
net_nbuf_unref(nbuf);
}
}
示例5: net_tx_fiber
static void net_tx_fiber(void)
{
NET_DBG("Starting TX fiber\n");
while (1) {
struct net_buf *buf;
uint8_t run;
/* Get next packet from application - wait if necessary */
buf = nano_fifo_get_wait(&netdev.tx_queue);
NET_DBG("Sending (buf %p, len %u) to IP stack\n",
buf, buf->len);
if (check_and_send_packet(buf) < 0) {
/* Release buffer on error */
net_buf_put(buf);
continue;
}
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
/* Check for any events that we might need to process */
do {
run = process_run(buf);
} while (run > 0);
/* Check stack usage (no-op if not enabled) */
analyze_stacks(buf, &buf);
}
}
示例6: net_buf_get
struct net_buf *l2_buf_get_reserve(uint16_t reserve_head)
#endif
{
struct net_buf *buf;
buf = net_buf_get(&free_l2_bufs, reserve_head);
if (!buf) {
#ifdef DEBUG_L2_BUFS
NET_ERR("Failed to get free L2 buffer (%s():%d)\n",
caller, line);
#else
NET_ERR("Failed to get free L2 buffer\n");
#endif
return NULL;
}
dec_free_l2_bufs(buf);
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_L2_BUFS
NET_DBG("[%d] buf %p reserve %u ref %d (%s():%d)\n",
get_free_l2_bufs(), buf, reserve_head, buf->ref,
caller, line);
#else
NET_DBG("buf %p reserve %u ref %d\n", buf, reserve_head, buf->ref);
#endif
packetbuf_clear(buf);
return buf;
}
示例7: tcp_received
static void tcp_received(struct net_app_ctx *ctx,
struct net_pkt *pkt,
int status,
void *user_data)
{
struct data *data = ctx->user_data;
ARG_UNUSED(user_data);
ARG_UNUSED(status);
if (!pkt || net_pkt_appdatalen(pkt) == 0) {
if (pkt) {
net_pkt_unref(pkt);
}
return;
}
NET_DBG("Sent %d bytes, received %u bytes",
data->expecting_tcp, net_pkt_appdatalen(pkt));
if (!compare_tcp_data(pkt, data->expecting_tcp, data->received_tcp)) {
NET_DBG("Data mismatch");
} else {
data->received_tcp += net_pkt_appdatalen(pkt);
}
if (data->expecting_tcp <= data->received_tcp) {
/* Send more data */
send_tcp_data(ctx, data);
}
net_pkt_unref(pkt);
}
示例8: ipsp_recv
static void ipsp_recv(struct bt_l2cap_chan *chan, struct net_buf *buf)
{
struct bt_context *ctxt = CHAN_CTXT(chan);
struct net_pkt *pkt;
NET_DBG("Incoming data channel %p len %zu", chan,
net_buf_frags_len(buf));
/* Get packet for bearer / protocol related data */
pkt = net_pkt_get_reserve_rx(0, K_FOREVER);
/* Set destination address */
net_pkt_ll_dst(pkt)->addr = ctxt->src.val;
net_pkt_ll_dst(pkt)->len = sizeof(ctxt->src);
net_pkt_ll_dst(pkt)->type = NET_LINK_BLUETOOTH;
/* Set source address */
net_pkt_ll_src(pkt)->addr = ctxt->dst.val;
net_pkt_ll_src(pkt)->len = sizeof(ctxt->dst);
net_pkt_ll_src(pkt)->type = NET_LINK_BLUETOOTH;
/* Add data buffer as fragment of RX buffer, take a reference while
* doing so since L2CAP will unref the buffer after return.
*/
net_pkt_frag_add(pkt, net_buf_ref(buf));
if (net_recv_data(ctxt->iface, pkt) < 0) {
NET_DBG("Packet dropped by NET stack");
net_pkt_unref(pkt);
}
}
示例9: net_rpl_mrhof_update_mc
static int net_rpl_mrhof_update_mc(struct net_rpl_instance *instance)
{
#if defined(CONFIG_NET_RPL_MC_NONE)
instance->mc.type = NET_RPL_MC_NONE;
return 0;
#else
u16_t path_metric;
struct net_rpl_dag *dag;
#if defined(CONFIG_NET_RPL_MC_ENERGY)
u8_t type;
instance->mc.type = NET_RPL_MC_ENERGY;
#else
instance->mc.type = NET_RPL_MC_ETX;
#endif
instance->mc.flags = NET_RPL_MC_FLAG_P;
instance->mc.aggregated = NET_RPL_MC_A_ADDITIVE;
instance->mc.precedence = 0;
dag = instance->current_dag;
if (!net_rpl_dag_is_joined(dag)) {
NET_DBG("Cannot update the metric container when not joined.");
return -EINVAL;
}
if (dag->rank == NET_RPL_ROOT_RANK(instance)) {
path_metric = 0;
} else {
path_metric = calculate_path_metric(dag->preferred_parent);
}
#if defined(CONFIG_NET_RPL_MC_ETX)
instance->mc.length = sizeof(instance->mc.obj.etx);
instance->mc.obj.etx = path_metric;
NET_DBG("My path ETX to the root is %u.%u\n",
instance->mc.obj.etx / RPL_DAG_MC_ETX_DIVISOR,
(instance->mc.obj.etx % RPL_DAG_MC_ETX_DIVISOR * 100) /
NET_RPL_DAG_MC_ETX_DIVISOR);
#elif defined(CONFIG_NET_RPL_MC_ENERGY)
instance->mc.length = sizeof(instance->mc.obj.energy);
if (dag->rank == NET_RPL_ROOT_RANK(instance)) {
type = NET_RPL_MC_NODE_TYPE_MAINS;
} else {
type = NET_RPL_MC_NODE_TYPE_BATTERY;
}
instance->mc.obj.energy.flags = type << NET_RPL_MC_ENERGY_TYPE;
instance->mc.obj.energy.estimation = path_metric;
#endif
return 0;
#endif /* CONFIG_NET_RPL_MC_NONE */
}
示例10: process_data
static inline enum net_verdict process_data(struct net_pkt *pkt,
bool is_loopback)
{
int ret;
bool locally_routed = false;
#if defined(CONFIG_NET_IPV6_FRAGMENT)
/* If the packet is routed back to us when we have reassembled
* an IPv6 packet, then do not pass it to L2 as the packet does
* not have link layer headers in it.
*/
if (net_pkt_ipv6_fragment_start(pkt)) {
locally_routed = true;
}
#endif
/* If there is no data, then drop the packet. */
if (!pkt->frags) {
NET_DBG("Corrupted packet (frags %p)", pkt->frags);
net_stats_update_processing_error();
return NET_DROP;
}
if (!is_loopback && !locally_routed) {
ret = net_if_recv_data(net_pkt_iface(pkt), pkt);
if (ret != NET_CONTINUE) {
if (ret == NET_DROP) {
NET_DBG("Packet %p discarded by L2", pkt);
net_stats_update_processing_error();
}
return ret;
}
}
/* IP version and header length. */
switch (NET_IPV6_HDR(pkt)->vtc & 0xf0) {
#if defined(CONFIG_NET_IPV6)
case 0x60:
net_stats_update_ipv6_recv();
net_pkt_set_family(pkt, PF_INET6);
return net_ipv6_process_pkt(pkt);
#endif
#if defined(CONFIG_NET_IPV4)
case 0x40:
net_stats_update_ipv4_recv();
net_pkt_set_family(pkt, PF_INET);
return net_ipv4_process_pkt(pkt);
#endif
}
NET_DBG("Unknown IP family packet (0x%x)",
NET_IPV6_HDR(pkt)->vtc & 0xf0);
net_stats_update_ip_errors_protoerr();
net_stats_update_ip_errors_vhlerr();
return NET_DROP;
}
示例11: switch
static struct net_buf *ip_buf_get_reserve(enum ip_buf_type type,
uint16_t reserve_head)
#endif
{
struct net_buf *buf = NULL;
/* Note that we do not reserve any space in front of the
* buffer so buf->data points to first byte of the IP header.
* This is done like this so that IP stack works the same
* way as BT and 802.15.4 stacks.
*
* The reserve_head variable in the function will tell
* the size of the IP + other headers if there are any.
* That variable is only used to calculate the pointer
* where the application data starts.
*/
switch (type) {
case IP_BUF_RX:
buf = net_buf_get(&free_rx_bufs, 0);
dec_free_rx_bufs(buf);
break;
case IP_BUF_TX:
buf = net_buf_get(&free_tx_bufs, 0);
dec_free_tx_bufs(buf);
break;
}
if (!buf) {
#ifdef DEBUG_IP_BUFS
NET_ERR("Failed to get free %s buffer (%s():%d)\n",
type2str(type), caller, line);
#else
NET_ERR("Failed to get free %s buffer\n", type2str(type));
#endif
return NULL;
}
ip_buf_type(buf) = type;
ip_buf_appdata(buf) = buf->data + reserve_head;
ip_buf_appdatalen(buf) = 0;
ip_buf_reserve(buf) = reserve_head;
net_buf_add(buf, reserve_head);
NET_BUF_CHECK_IF_NOT_IN_USE(buf);
#ifdef DEBUG_IP_BUFS
NET_DBG("%s [%d] buf %p reserve %u ref %d (%s():%d)\n",
type2str(type), get_frees(type),
buf, reserve_head, buf->ref, caller, line);
#else
NET_DBG("%s buf %p reserve %u ref %d\n", type2str(type), buf,
reserve_head, buf->ref);
#endif
return buf;
}
示例12: net_bt_recv
static enum net_verdict net_bt_recv(struct net_if *iface, struct net_pkt *pkt)
{
NET_DBG("iface %p pkt %p len %zu", iface, pkt, net_pkt_get_len(pkt));
if (!net_6lo_uncompress(pkt)) {
NET_DBG("Packet decompression failed");
return NET_DROP;
}
return NET_CONTINUE;
}
示例13: defined
struct net_nbr *net_nbr_ref(struct net_nbr *nbr)
#endif
{
#if defined(CONFIG_NET_DEBUG_IPV6_NBR_CACHE)
NET_DBG("nbr %p ref %u (%s():%d)", nbr, nbr->ref + 1, caller, line);
#else
NET_DBG("nbr %p ref %u", nbr, nbr->ref + 1);
#endif
nbr->ref++;
return nbr;
}
示例14: processing_data
static void processing_data(struct net_pkt *pkt, bool is_loopback)
{
switch (process_data(pkt, is_loopback)) {
case NET_OK:
NET_DBG("Consumed pkt %p", pkt);
break;
case NET_DROP:
default:
NET_DBG("Dropping pkt %p", pkt);
net_pkt_unref(pkt);
break;
}
}
示例15: dhcpv4_timeout
static void dhcpv4_timeout(struct k_work *work)
{
struct net_if *iface = CONTAINER_OF(work, struct net_if,
dhcpv4_timeout);
if (!iface) {
NET_DBG("Invalid iface");
return;
}
switch (iface->dhcpv4.state) {
case NET_DHCPV4_DISCOVER:
/* Failed to get OFFER message, send DISCOVER again */
send_discover(iface);
break;
case NET_DHCPV4_REQUEST:
/*
* Maximum number of renewal attempts failed, so start
* from the beginning.
*/
if (iface->dhcpv4.attempts >= DHCPV4_MAX_NUMBER_OF_ATTEMPTS) {
send_discover(iface);
} else {
/* Repeat requests until max number of attempts */
send_request(iface, false);
}
break;
case NET_DHCPV4_RENEWAL:
if (iface->dhcpv4.attempts >= DHCPV4_MAX_NUMBER_OF_ATTEMPTS) {
if (!net_if_ipv4_addr_rm(iface,
&iface->dhcpv4.requested_ip)) {
NET_DBG("Failed to remove addr from iface");
}
/*
* Maximum number of renewal attempts failed, so start
* from the beginning.
*/
send_discover(iface);
} else {
/* Repeat renewal request for max number of attempts */
send_request(iface, true);
}
break;
default:
break;
}
}