net: Convert FOR_EACH macro instances to use CONTAINER
Change-Id: I2fbdc8128bef79eac74441c84fbb80e31f6bc261 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
41921dd5b9
commit
4ab09bdead
|
@ -345,14 +345,11 @@ int net_icmpv6_send_echo_request(struct net_if *iface,
|
|||
enum net_verdict net_icmpv6_input(struct net_buf *buf, uint16_t len,
|
||||
uint8_t type, uint8_t code)
|
||||
{
|
||||
sys_snode_t *node;
|
||||
struct net_icmpv6_handler *cb;
|
||||
|
||||
ARG_UNUSED(len);
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&handlers, node) {
|
||||
cb = (struct net_icmpv6_handler *)node;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&handlers, cb, node) {
|
||||
if (cb->type == type && (cb->code == code || cb->code == 0)) {
|
||||
net_stats_update_icmp_recv();
|
||||
return cb->handler(buf);
|
||||
|
|
|
@ -1332,12 +1332,9 @@ void net_if_unregister_link_cb(struct net_if_link_cb *link)
|
|||
void net_if_call_link_cb(struct net_if *iface, struct net_linkaddr *lladdr,
|
||||
int status)
|
||||
{
|
||||
sys_snode_t *sn, *sns;
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE_SAFE(&link_callbacks, sn, sns) {
|
||||
struct net_if_link_cb *link =
|
||||
CONTAINER_OF(sn, struct net_if_link_cb, node);
|
||||
struct net_if_link_cb *link, *tmp;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&link_callbacks, link, tmp, node) {
|
||||
link->cb(iface, lladdr, status);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,14 +86,11 @@ static inline void mgmt_add_event_mask(uint32_t event_mask)
|
|||
|
||||
static inline void mgmt_rebuild_global_event_mask(void)
|
||||
{
|
||||
sys_snode_t *sn, *sns;
|
||||
struct net_mgmt_event_callback *cb, *tmp;
|
||||
|
||||
global_event_mask = 0;
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE_SAFE(&event_callbacks, sn, sns) {
|
||||
struct net_mgmt_event_callback *cb =
|
||||
CONTAINER_OF(sn, struct net_mgmt_event_callback, node);
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&event_callbacks, cb, tmp, node) {
|
||||
mgmt_add_event_mask(cb->event_mask);
|
||||
}
|
||||
}
|
||||
|
@ -105,17 +102,14 @@ static inline bool mgmt_is_event_handled(uint32_t mgmt_event)
|
|||
|
||||
static inline void mgmt_run_callbacks(struct mgmt_event_entry *mgmt_event)
|
||||
{
|
||||
sys_snode_t *sn, *sns;
|
||||
struct net_mgmt_event_callback *cb, *tmp;
|
||||
|
||||
NET_DBG("Event layer %u code %u type %u",
|
||||
NET_MGMT_GET_LAYER(mgmt_event->event),
|
||||
NET_MGMT_GET_LAYER_CODE(mgmt_event->event),
|
||||
NET_MGMT_GET_COMMAND(mgmt_event->event));
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE_SAFE(&event_callbacks, sn, sns) {
|
||||
struct net_mgmt_event_callback *cb =
|
||||
CONTAINER_OF(sn, struct net_mgmt_event_callback, node);
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&event_callbacks, cb, tmp, node) {
|
||||
NET_DBG("Running callback %p : %p", cb, cb->handler);
|
||||
|
||||
if ((mgmt_event->event & cb->event_mask) == mgmt_event->event) {
|
||||
|
|
|
@ -284,7 +284,7 @@ static void iface_cb(struct net_if *iface, void *user_data)
|
|||
static void route_cb(struct net_route_entry *entry, void *user_data)
|
||||
{
|
||||
struct net_if *iface = user_data;
|
||||
sys_snode_t *test;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
int count;
|
||||
|
||||
if (entry->iface != iface) {
|
||||
|
@ -302,14 +302,9 @@ static void route_cb(struct net_route_entry *entry, void *user_data)
|
|||
|
||||
printk("Next hops :\n");
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&entry->nexthop, test) {
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&entry->nexthop, nexthop_route, node) {
|
||||
struct net_linkaddr_storage *lladdr;
|
||||
|
||||
nexthop_route = CONTAINER_OF(test,
|
||||
struct net_route_nexthop,
|
||||
node);
|
||||
|
||||
if (!nexthop_route->nbr) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -418,7 +418,7 @@ struct net_route_entry *net_route_add(struct net_if *iface,
|
|||
int net_route_del(struct net_route_entry *route)
|
||||
{
|
||||
struct net_nbr *nbr;
|
||||
sys_snode_t *test;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
|
||||
if (!route) {
|
||||
return -EINVAL;
|
||||
|
@ -433,13 +433,7 @@ int net_route_del(struct net_route_entry *route)
|
|||
|
||||
net_route_info("Deleted", route, &route->addr);
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&route->nexthop, test) {
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
|
||||
nexthop_route = CONTAINER_OF(test,
|
||||
struct net_route_nexthop,
|
||||
node);
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, node) {
|
||||
if (!nexthop_route->nbr) {
|
||||
continue;
|
||||
}
|
||||
|
@ -458,7 +452,7 @@ int net_route_del_by_nexthop(struct net_if *iface, struct in6_addr *nexthop)
|
|||
{
|
||||
int count = 0, status = 0;
|
||||
struct net_nbr *nbr_nexthop;
|
||||
sys_snode_t *test;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
int i, ret;
|
||||
|
||||
NET_ASSERT(iface);
|
||||
|
@ -470,13 +464,8 @@ int net_route_del_by_nexthop(struct net_if *iface, struct in6_addr *nexthop)
|
|||
struct net_nbr *nbr = get_nbr(i);
|
||||
struct net_route_entry *route = net_route_data(nbr);
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&route->nexthop, test) {
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
|
||||
nexthop_route = CONTAINER_OF(test,
|
||||
struct net_route_nexthop,
|
||||
node);
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route,
|
||||
node) {
|
||||
if (nexthop_route->nbr == nbr_nexthop) {
|
||||
/* This route contains this nexthop */
|
||||
ret = net_route_del(route);
|
||||
|
@ -505,7 +494,7 @@ int net_route_del_by_nexthop_data(struct net_if *iface,
|
|||
{
|
||||
int count = 0, status = 0;
|
||||
struct net_nbr *nbr_nexthop;
|
||||
sys_snode_t *test;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
int i, ret;
|
||||
|
||||
NET_ASSERT(iface);
|
||||
|
@ -517,14 +506,10 @@ int net_route_del_by_nexthop_data(struct net_if *iface,
|
|||
struct net_nbr *nbr = get_nbr(i);
|
||||
struct net_route_entry *route = net_route_data(nbr);
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&route->nexthop, test) {
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route,
|
||||
node) {
|
||||
void *extra_data;
|
||||
|
||||
nexthop_route = CONTAINER_OF(test,
|
||||
struct net_route_nexthop,
|
||||
node);
|
||||
|
||||
if (nexthop_route->nbr != nbr_nexthop) {
|
||||
continue;
|
||||
}
|
||||
|
@ -561,18 +546,13 @@ int net_route_del_by_nexthop_data(struct net_if *iface,
|
|||
|
||||
struct in6_addr *net_route_get_nexthop(struct net_route_entry *route)
|
||||
{
|
||||
sys_snode_t *test;
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
|
||||
NET_ASSERT(route);
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&route->nexthop, test) {
|
||||
struct net_route_nexthop *nexthop_route;
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&route->nexthop, nexthop_route, node) {
|
||||
struct in6_addr *addr;
|
||||
|
||||
nexthop_route = CONTAINER_OF(test,
|
||||
struct net_route_nexthop,
|
||||
node);
|
||||
|
||||
NET_ASSERT(nexthop_route->nbr->idx != NET_NBR_LLADDR_UNKNOWN);
|
||||
|
||||
if (nexthop_route->nbr->idx == NET_NBR_LLADDR_UNKNOWN) {
|
||||
|
|
|
@ -655,13 +655,11 @@ static void restart_timer(struct net_tcp *tcp)
|
|||
int net_tcp_send_data(struct net_context *context)
|
||||
{
|
||||
struct net_buf *buf;
|
||||
sys_snode_t *node;
|
||||
|
||||
/* For now, just send all queued data synchronously. Need to
|
||||
* add window handling and retry/ACK logic.
|
||||
*/
|
||||
SYS_SLIST_FOR_EACH_NODE(&context->tcp->sent_list, node) {
|
||||
buf = CONTAINER_OF(node, struct net_buf, sent_list);
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&context->tcp->sent_list, buf, sent_list) {
|
||||
if (!net_nbuf_buf_sent(buf)) {
|
||||
net_tcp_send_buf(buf);
|
||||
}
|
||||
|
@ -722,11 +720,9 @@ void net_tcp_ack_received(struct net_context *ctx, uint32_t ack)
|
|||
*/
|
||||
if (ctx->tcp->flags & NET_TCP_RETRYING) {
|
||||
struct net_buf *buf;
|
||||
sys_snode_t *node;
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&ctx->tcp->sent_list, node) {
|
||||
buf = CONTAINER_OF(node, struct net_buf,
|
||||
sent_list);
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&ctx->tcp->sent_list, buf,
|
||||
sent_list) {
|
||||
net_nbuf_set_buf_sent(buf, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -695,7 +695,7 @@ void zoap_reply_clear(struct zoap_reply *reply)
|
|||
|
||||
int zoap_resource_notify(struct zoap_resource *resource)
|
||||
{
|
||||
sys_snode_t *node;
|
||||
struct zoap_observer *o;
|
||||
|
||||
resource->age++;
|
||||
|
||||
|
@ -703,9 +703,7 @@ int zoap_resource_notify(struct zoap_resource *resource)
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
SYS_SLIST_FOR_EACH_NODE(&resource->observers, node) {
|
||||
struct zoap_observer *o = (struct zoap_observer *) node;
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&resource->observers, o, list) {
|
||||
resource->notify(resource, o);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue