5 * packet.h Structures and prototypes
6 * for packet manipulation
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 * Copyright 2001,2002,2003,2004,2005,2006 The FreeRADIUS server project
27 uint32_t lrad_request_packet_hash(const RADIUS_PACKET *packet);
28 uint32_t lrad_reply_packet_hash(const RADIUS_PACKET *packet);
29 int lrad_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b);
30 void lrad_request_from_reply(RADIUS_PACKET *request,
31 const RADIUS_PACKET *reply);
32 int lrad_socket(lrad_ipaddr_t *ipaddr, int port);
34 typedef struct lrad_packet_list_t lrad_packet_list_t;
36 lrad_packet_list_t *lrad_packet_list_create(int sockfd, int alloc_id);
37 void lrad_packet_list_free(lrad_packet_list_t *pl);
38 int lrad_packet_list_insert(lrad_packet_list_t *pl,
39 RADIUS_PACKET **request_p);
41 RADIUS_PACKET **lrad_packet_list_find(lrad_packet_list_t *pl,
42 RADIUS_PACKET *request);
43 RADIUS_PACKET **lrad_packet_list_find_byreply(lrad_packet_list_t *pl,
44 RADIUS_PACKET *reply);
45 RADIUS_PACKET **lrad_packet_list_yank(lrad_packet_list_t *pl,
46 RADIUS_PACKET *request);
47 int lrad_packet_list_num_elements(lrad_packet_list_t *pl);
48 int lrad_packet_list_id_alloc(lrad_packet_list_t *pl,
49 RADIUS_PACKET *request);
50 int lrad_packet_list_id_free(lrad_packet_list_t *pl,
51 RADIUS_PACKET *request);
52 int lrad_packet_list_socket_add(lrad_packet_list_t *pl, int sockfd);
53 int lrad_packet_list_socket_remove(lrad_packet_list_t *pl, int sockfd);
54 int lrad_packet_list_walk(lrad_packet_list_t *pl, void *ctx,
55 lrad_hash_table_walk_t callback);
56 int lrad_packet_list_fd_set(lrad_packet_list_t *pl, fd_set *set);
57 RADIUS_PACKET *lrad_packet_list_recv(lrad_packet_list_t *pl, fd_set *set);
59 int lrad_packet_list_num_incoming(lrad_packet_list_t *pl);
60 int lrad_packet_list_num_outgoing(lrad_packet_list_t *pl);
64 # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
68 * "find" returns a pointer to the RADIUS_PACKET* member in the
69 * caller's structure. In order to get the pointer to the *top*
70 * of the caller's structure, you have to subtract the offset to
71 * the member from the returned pointer, and cast it to the
74 # define lrad_packet2myptr(TYPE, MEMBER, PTR) (TYPE *) (((char *)PTR) - offsetof(TYPE, MEMBER))
75 #endif /* LRAD_PACKET_H */