/* @todo: this is a hack */
# define DEBUG if (fr_debug_flag && fr_log_fp) fr_printf_log
-void fr_strerror_printf(char const *fmt, ...);
# define debug_pair(vp) do { if (fr_debug_flag && fr_log_fp) { \
vp_print(fr_log_fp, vp); \
} \
UNUSED fr_ipaddr_t *src_ipaddr,
#endif
fr_ipaddr_t *dst_ipaddr,
- int dst_port)
+ uint16_t dst_port)
{
struct sockaddr_storage dst;
socklen_t sizeof_dst;
ssize_t data_len;
uint8_t header[4];
size_t len;
- int port;
+ uint16_t port;
memset(&src, 0, sizeof_src);
memset(&dst, 0, sizeof_dst);
/*
* Allocate the new request data structure
*/
- packet = rad_alloc(NULL, 0);
+ packet = rad_alloc(NULL, false);
if (!packet) {
fr_strerror_printf("out of memory");
return NULL;
/*
* This is more than a bit of a hack.
*/
- packet->code = PW_AUTHENTICATION_REQUEST;
+ packet->code = PW_CODE_ACCESS_REQUEST;
memcpy(&id, packet->data + 4, 4);
packet->id = ntohl(id);
if (packet->data_len < VQP_HDR_LEN) return -1;
- paircursor(&cursor, &packet->vps);
+ fr_cursor_init(&cursor, &packet->vps);
vp = paircreate(packet, PW_VQP_PACKET_TYPE, 0);
if (!vp) {
fr_strerror_printf("No memory");
}
vp->vp_integer = packet->data[1];
debug_pair(vp);
- pairinsert(&cursor, vp);
+ fr_cursor_insert(&cursor, vp);
vp = paircreate(packet, PW_VQP_ERROR_CODE, 0);
if (!vp) {
}
vp->vp_integer = packet->data[2];
debug_pair(vp);
- pairinsert(&cursor, vp);
+ fr_cursor_insert(&cursor, vp);
vp = paircreate(packet, PW_VQP_SEQUENCE_NUMBER, 0);
if (!vp) {
}
vp->vp_integer = packet->id; /* already set by vqp_recv */
debug_pair(vp);
- pairinsert(&cursor, vp);
+ fr_cursor_insert(&cursor, vp);
ptr = packet->data + VQP_HDR_LEN;
end = packet->data + packet->data_len;
}
switch (vp->da->type) {
- case PW_TYPE_IPADDR:
+ case PW_TYPE_IPV4_ADDR:
if (length == 4) {
memcpy(&vp->vp_ipaddr, ptr, 4);
vp->length = 4;
default:
case PW_TYPE_OCTETS:
- pairmemcpy(vp, ptr, length);
+ if (length < 1024) {
+ pairmemcpy(vp, ptr, length);
+ } else {
+ pairmemcpy(vp, ptr, 1024);
+ }
break;
case PW_TYPE_STRING:
- vp->length = length;
- vp->vp_strvalue = p = talloc_array(vp, char, vp->length + 1);
- vp->type = VT_DATA;
- memcpy(p, ptr, vp->length);
- p[vp->length] = '\0';
+ if (length < 1024) {
+ vp->length = length;
+ vp->vp_strvalue = p = talloc_array(vp, char, vp->length + 1);
+ vp->type = VT_DATA;
+ memcpy(p, ptr, vp->length);
+ p[vp->length] = '\0';
+ } else {
+ vp->length = 1024;
+ vp->vp_strvalue = p = talloc_array(vp, char, 1025);
+ vp->type = VT_DATA;
+ memcpy(p, ptr, vp->length);
+ p[vp->length] = '\0';
+ }
break;
}
ptr += length;
debug_pair(vp);
- pairinsert(&cursor, vp);
+ fr_cursor_insert(&cursor, vp);
}
/*
/* Data */
switch (vp->da->type) {
- case PW_TYPE_IPADDR:
+ case PW_TYPE_IPV4_ADDR:
memcpy(ptr, &vp->vp_ipaddr, 4);
break;