fr_time_delta_t our_timeout;
fr_radius_packet_t *found = NULL;
fr_radius_packet_t *reply = NULL;
- int nb_reply = 0;
- int nb_offer = 0;
- dc_offer_t *offer_list = NULL;
- fd_set read_fd;
- int retval;
- fr_cursor_t cursor;
+ fr_pair_list_t reply_vps;
+ int nb_reply = 0;
+ int nb_offer = 0;
+ dc_offer_t *offer_list = NULL;
+ fd_set read_fd;
+ int retval;
+ fr_cursor_t cursor;
+
+ fr_pair_list_init(&reply_vps);
our_timeout = timeout;
if (fr_debug_lvl > 1) fr_dhcpv4_print_hex(stdout, reply->data, reply->data_len);
- fr_cursor_init(&cursor, &reply->vps);
+ fr_cursor_init(&cursor, &reply_vps);
if (fr_dhcpv4_decode(reply, reply->data, reply->data_len, &cursor, &reply->code) < 0) {
ERROR("Failed decoding reply");
return NULL;
if (!found) found = reply;
if (reply->code == FR_DHCP_OFFER) {
- fr_pair_t *vp1 = fr_pair_find_by_da(&reply->vps,
+ fr_pair_t *vp1 = fr_pair_find_by_da(&reply_vps,
attr_dhcp_dhcp_server_identifier);
- fr_pair_t *vp2 = fr_pair_find_by_da(&reply->vps,
+ fr_pair_t *vp2 = fr_pair_find_by_da(&reply_vps,
attr_dhcp_your_ip_address);
if (vp1 && vp2) {
}
#endif /* HAVE_LIBPCAP */
-static void dhcp_packet_debug(fr_radius_packet_t *packet, bool received)
+static void dhcp_packet_debug(fr_radius_packet_t *packet, fr_pair_list_t *list, bool received)
{
fr_cursor_t cursor;
char buffer[2048];
#endif
packet->data_len);
- for (vp = fr_cursor_init(&cursor, &packet->vps);
+ for (vp = fr_cursor_init(&cursor, list);
vp;
vp = fr_cursor_next(&cursor)) {
VP_VERIFY(vp);
/*
* Encode the packet
*/
- if (fr_dhcpv4_packet_encode(packet) < 0) {
+ if (fr_dhcpv4_packet_encode(packet, &packet_vps) < 0) {
ERROR("Failed encoding packet");
fr_exit(EXIT_FAILURE);
}
if (fr_debug_lvl > 1) fr_dhcpv4_print_hex(stdout, packet->data, packet->data_len);
fr_dhcpv4_decode(packet, packet->data, packet->data_len, &cursor, &packet->code);
- dhcp_packet_debug(packet, false);
+ dhcp_packet_debug(packet, &packet_vps, false);
}
#ifdef HAVE_LIBPCAP
ERROR("Failed decoding packet");
ret = -1;
}
- dhcp_packet_debug(reply, true);
+ dhcp_packet_debug(reply, &reply_vps, true);
}
fr_dhcpv4_global_free();
return 0;
}
-int fr_dhcpv4_packet_encode(fr_radius_packet_t *packet)
+int fr_dhcpv4_packet_encode(fr_radius_packet_t *packet, fr_pair_list_t *list)
{
ssize_t len;
fr_pair_t *vp;
packet->id = fr_rand();
}
- len = fr_dhcpv4_encode(packet->data, packet->data_len, NULL, packet->code, packet->id, &packet->vps);
+ len = fr_dhcpv4_encode(packet->data, packet->data_len, NULL, packet->code, packet->id, list);
if (len < 0) return -1;
packet->data_len = len;