Lines Matching refs:gw
129 struct mqtt_sn_gateway *gw; in encode_and_send() local
131 gw = SYS_SLIST_PEEK_HEAD_CONTAINER(&client->gateway, gw, next); in encode_and_send()
132 if (gw == NULL || gw->addr_len == 0) { in encode_and_send()
137 err = client->transport->sendto(client, client->tx.data, client->tx.len, gw->addr, in encode_and_send()
138 gw->addr_len); in encode_and_send()
317 static void mqtt_sn_gw_destroy(struct mqtt_sn_client *client, struct mqtt_sn_gateway *gw) in mqtt_sn_gw_destroy() argument
319 LOG_DBG("Destroying gateway %d", gw->gw_id); in mqtt_sn_gw_destroy()
320 sys_slist_find_and_remove(&client->gateway, &gw->next); in mqtt_sn_gw_destroy()
321 k_mem_slab_free(&gateways, (void *)gw); in mqtt_sn_gw_destroy()
326 struct mqtt_sn_gateway *gw; in mqtt_sn_gw_destroy_all() local
330 gw = SYS_SLIST_CONTAINER(next, gw, next); in mqtt_sn_gw_destroy_all()
332 k_mem_slab_free(&gateways, (void *)gw); in mqtt_sn_gw_destroy_all()
339 struct mqtt_sn_gateway *gw; in mqtt_sn_gw_create() local
342 if (k_mem_slab_alloc(&gateways, (void **)&gw, K_NO_WAIT)) { in mqtt_sn_gw_create()
350 memset(gw, 0, sizeof(*gw)); in mqtt_sn_gw_create()
351 memcpy(gw->addr, gw_addr.data, gw_addr.size); in mqtt_sn_gw_create()
352 gw->addr_len = gw_addr.size; in mqtt_sn_gw_create()
353 gw->gw_id = gw_id; in mqtt_sn_gw_create()
355 gw->adv_timer = duration; in mqtt_sn_gw_create()
357 gw->adv_timer = in mqtt_sn_gw_create()
361 return gw; in mqtt_sn_gw_create()
366 struct mqtt_sn_gateway *gw; in mqtt_sn_gw_find_id() local
368 SYS_SLIST_FOR_EACH_CONTAINER(&client->gateway, gw, next) { in mqtt_sn_gw_find_id()
369 if (gw->gw_id == gw_id) { in mqtt_sn_gw_find_id()
370 return gw; in mqtt_sn_gw_find_id()
540 struct mqtt_sn_gateway *gw; in mqtt_sn_do_gwinfo() local
543 gw = SYS_SLIST_PEEK_HEAD_CONTAINER(&client->gateway, gw, next); in mqtt_sn_do_gwinfo()
545 if (gw == NULL || gw->addr_len == 0) { in mqtt_sn_do_gwinfo()
550 response.params.gwinfo.gw_id = gw->gw_id; in mqtt_sn_do_gwinfo()
551 addr.data = gw->addr; in mqtt_sn_do_gwinfo()
552 addr.size = gw->addr_len; in mqtt_sn_do_gwinfo()
711 struct mqtt_sn_gateway *gw = NULL; in process_ping() local
725 SYS_SLIST_PEEK_HEAD_CONTAINER(&client->gateway, gw, next); in process_ping()
726 LOG_DBG("Removing non-responsive GW 0x%08x", gw->gw_id); in process_ping()
727 mqtt_sn_gw_destroy(client, gw); in process_ping()
780 struct mqtt_sn_gateway *gw; in process_advertise() local
783 SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&client->gateway, gw, gw_next, next) { in process_advertise()
784 LOG_DBG("Checking if GW 0x%02x is old", gw->gw_id); in process_advertise()
785 if (gw->adv_timer != -1 && gw->adv_timer <= now) { in process_advertise()
786 LOG_DBG("Removing non-responsive GW 0x%08x", gw->gw_id); in process_advertise()
787 if (client->gateway.head == &gw->next) { in process_advertise()
790 mqtt_sn_gw_destroy(client, gw); in process_advertise()
792 if (gw->adv_timer != -1 && (*next_cycle == 0 || gw->adv_timer < *next_cycle)) { in process_advertise()
793 *next_cycle = gw->adv_timer; in process_advertise()
898 struct mqtt_sn_gateway *gw; in mqtt_sn_add_gw() local
900 gw = mqtt_sn_gw_find_id(client, gw_id); in mqtt_sn_add_gw()
902 if (gw != NULL) { in mqtt_sn_add_gw()
903 mqtt_sn_gw_destroy(client, gw); in mqtt_sn_add_gw()
906 gw = mqtt_sn_gw_create(gw_id, -1, gw_addr); in mqtt_sn_add_gw()
907 if (!gw) { in mqtt_sn_add_gw()
911 sys_slist_append(&client->gateway, &gw->next); in mqtt_sn_add_gw()
1116 struct mqtt_sn_gateway *gw; in handle_advertise() local
1118 gw = mqtt_sn_gw_find_id(client, p->gw_id); in handle_advertise()
1120 if (gw == NULL) { in handle_advertise()
1122 gw = mqtt_sn_gw_create(p->gw_id, p->duration, rx_addr); in handle_advertise()
1123 if (!gw) { in handle_advertise()
1126 sys_slist_append(&client->gateway, &gw->next); in handle_advertise()
1129 gw->adv_timer = in handle_advertise()
1164 struct mqtt_sn_gateway *gw; in handle_gwinfo() local
1177 gw = mqtt_sn_gw_create(p->gw_id, -1, rx_addr); in handle_gwinfo()
1179 if (!gw) { in handle_gwinfo()
1183 sys_slist_append(&client->gateway, &gw->next); in handle_gwinfo()