/* * Should be called AFTER yanking it from the list, so that * any newly inserted entries don't collide with this one. */ int fr_packet_list_id_free(fr_packet_list_t *pl, RADIUS_PACKET *request) { fr_packet_socket_t *ps; fr_packet_dst2id_t my_pd, *pd; if (!pl || !request) return 0; ps = fr_socket_find(pl, request->sockfd); if (!ps) return 0; my_pd.dst_ipaddr = request->dst_ipaddr; my_pd.dst_port = request->dst_port; pd = fr_hash_table_finddata(pl->dst2id_ht, &my_pd); if (!pd) return 0; pd->id[request->id] &= ~(1 << ps->offset); pd->num_outgoing--; ps->num_outgoing--; pl->num_outgoing--; if(pd->num_outgoing == 0) { fr_hash_table_delete(pl->dst2id_ht,&my_pd); } return 1; }
bool fr_packet_list_socket_thaw(fr_packet_list_t *pl, int sockfd) { fr_packet_socket_t *ps; if (!pl) return false; ps = fr_socket_find(pl, sockfd); if (!ps) return false; ps->dont_use = 0; return true; }
bool fr_packet_list_socket_del(fr_packet_list_t *pl, int sockfd) { fr_packet_socket_t *ps; if (!pl) return false; ps = fr_socket_find(pl, sockfd); if (!ps) return false; if (ps->num_outgoing != 0) return false; ps->sockfd = -1; pl->num_sockets--; return true; }
bool fr_packet_list_socket_freeze(fr_packet_list_t *pl, int sockfd) { fr_packet_socket_t *ps; if (!pl) { fr_strerror_printf("Invalid argument"); return false; } ps = fr_socket_find(pl, sockfd); if (!ps) { fr_strerror_printf("No such socket"); return false; } ps->dont_use = 1; return true; }
int fr_packet_list_socket_remove(fr_packet_list_t *pl, int sockfd) { fr_packet_socket_t *ps; if (!pl) return 0; ps = fr_socket_find(pl, sockfd); if (!ps) return 0; /* * FIXME: Allow the caller forcibly discard these? */ if (ps->num_outgoing != 0) return 0; ps->sockfd = -1; pl->mask &= ~(1 << ps->offset); return 1; }
/* * Should be called AFTER yanking it from the list, so that * any newly inserted entries don't collide with this one. */ bool fr_packet_list_id_free(fr_packet_list_t *pl, RADIUS_PACKET *request, bool yank) { fr_packet_socket_t *ps; if (!pl || !request) return false; if (yank && !fr_packet_list_yank(pl, request)) return false; ps = fr_socket_find(pl, request->sockfd); if (!ps) return false; /* * Don't mark the ID as free. We just won't use it until * we've cycled through all 256 IDs. */ ps->num_outgoing--; pl->num_outgoing--; request->id = -1; return true; }