networkclient
client.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2018 Network RADIUS SARL <info@networkradius.com>
3 
4 This software may not be redistributed in any form without the prior
5 written consent of Network RADIUS.
6 
7 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
8 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
11 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
12 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
13 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
14 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
15 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
16 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
17 SUCH DAMAGE.
18  */
19 
24 /*
25  * System-specific header files.
26  */
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <netdb.h>
32 #include <netinet/in.h>
33 #include <sys/time.h>
34 
35 /*
36  * Definitions of attributes.
37  */
38 #include <networkradius-devel/radius.h>
39 
135 #ifdef PW_EAP_MESSAGE
136 #ifndef PW_MESSAGE_AUTHENTICATOR
137 #error EAP-Message requires Message-Authenticator
138 #endif
139 #endif
140 
141 #ifndef HAVE_OPENSSL
142 #include "md5.h"
144 #define NR_MD5_CTX MD5_CTX
145 
146 #define nr_MD5Init MD5_Init
147 
148 #define nr_MD5Update MD5_Update
149 
150 #define nr_MD5Final MD5_Final
151 
152 #define nr_MD5Transform MD5_Transform
153 
154 #else /* WITHOUT_OPENSSL */
155 
156 #include <openssl/md5.h>
158 #define NR_MD5_CTX MD5_CTX
159 
160 #define nr_MD5Init MD5_Init
161 
162 #define nr_MD5Update MD5_Update
163 
164 #define nr_MD5Final MD5_Final
165 
166 #define nr_MD5Transform MD5_Transform
167 #endif
168 
169 #ifndef NR_MAX_PACKET_LEN
170 
179 #define NR_MAX_PACKET_LEN (4096)
180 #endif
181 
182 #ifndef NR_MAX_ATTRIBUTES
183 
192 #define NR_MAX_ATTRIBUTES (200)
193 #endif
194 
195 #undef NR_MAX_PACKET_CODE
196 
201 #define NR_MAX_PACKET_CODE 46
202 
208 #define NR_MAX_VENDOR (1 << 24)
209 
217 #define MAX_STRING_LEN (254)
218 
221 typedef enum nr_attr_type_t {
235 
236 #define PW_ACCESS_REQUEST 1
237 #define PW_ACCESS_ACCEPT 2
238 #define PW_ACCESS_REJECT 3
239 #define PW_ACCOUNTING_REQUEST 4
240 #define PW_ACCOUNTING_RESPONSE 5
241 #define PW_ACCOUNTING_STATUS 6
242 #define PW_ACCESS_CHALLENGE 11
243 #define PW_STATUS_SERVER 12
244 #define PW_DISCONNECT_REQUEST 40
245 #define PW_DISCONNECT_ACK 41
246 #define PW_DISCONNECT_NAK 42
247 #define PW_COA_REQUEST 43
248 #define PW_COA_ACK 44
249 #define PW_COA_NAK 45
250 
256 typedef enum nr_error_t {
317 } nr_error_t;
318 
319 #define TAG_VALID(x) ((x) < 0x20)
320 
322 #define FLAG_ENCRYPT_NONE (0)
323 
325 #define FLAG_ENCRYPT_USER_PASSWORD (1)
326 
328 #define FLAG_ENCRYPT_TUNNEL_PASSWORD (2)
329 
337 typedef struct attr_flags {
338  unsigned int has_tag : 1;
339  unsigned int unknown : 1;
340 #ifdef NR_TYPE_TLV
341  unsigned int has_tlv : 1; /* has sub attributes */
342  unsigned int is_tlv : 1; /* is a sub attribute */
343 #endif
344 #ifdef VENDOR_EXTENDED
345  unsigned int extended : 1; /* extended attribute */
346  unsigned int extended_flags : 1; /* with flag */
347  unsigned int evs : 1; /* extended VSA */
348 #endif
349 
350  uint8_t encrypt;
351  uint8_t length;
352 } ATTR_FLAGS;
353 
354 
361 typedef struct nr_dict_attr {
362  unsigned int attr;
364  unsigned int vendor;
366  const char *name;
367 } DICT_ATTR;
368 
373 typedef struct nr_dict_value {
374  const DICT_ATTR *da;
375  int value;
376  char name[1];
377 } DICT_VALUE;
378 
386 typedef struct nr_dict_vendor {
387  unsigned int vendor;
388  size_t type;
389  size_t length;
390  const char *name;
391 } DICT_VENDOR;
392 
396 typedef union value_pair_data {
397  char strvalue[MAX_STRING_LEN]; /* +1 for NUL */
398  uint8_t octets[253];
399  struct in_addr ipaddr;
400  struct in6_addr ipv6addr;
401  uint32_t date;
402  uint32_t integer;
403  uint64_t integer64;
404 #ifdef NR_TYPE_SIGNED
405  int32_t sinteger;
406 #endif
407 #ifdef NR_TYPE_ABINARY
408  uint8_t filter[32];
409 #endif
410  uint8_t ifid[8]; /* struct? */
411  uint8_t ipv6prefix[18]; /* struct? */
412 #ifdef NR_TYPE_TLV
413  uint8_t *tlv;
414 #endif
416 
417 
423 typedef struct value_pair {
424  const DICT_ATTR *da;
425  size_t length;
426  int tag;
427  struct value_pair *next;
429 } VALUE_PAIR;
430 #define vp_strvalue data.strvalue
431 #define vp_octets data.octets
432 #define vp_ipv6addr data.ipv6addr
433 #define vp_ifid data.ifid
434 #define vp_ipv6prefix data.ipv6prefix
435 #define vp_ipaddr data.ipaddr.s_addr
436 #define vp_date data.integer
437 #define vp_integer data.integer
438 #define vp_integer64 data.integer64
439 #ifdef NR_TYPE_ABINARY
440 #define vp_filter data.filter
441 #endif
442 #ifdef NR_TYPE_ETHER
443 #define vp_ether data.ether
444 #endif
445 #ifdef NR_TYPE_SIGNED
446 #define vp_signed data.sinteger
447 #endif
448 #ifdef NR_TYPE_TLV
449 #define vp_tlv data.tlv
450 #endif
451 
452 #ifdef NR_TYPE_TLV
453 #define NR_ATTR_MAX_TLV (4)
454 extern const int nr_attr_shift[NR_ATTR_MAX_TLV];
455 extern const int nr_attr_mask[NR_ATTR_MAX_TLV];
456 extern const unsigned int nr_attr_max_tlv;
457 #endif
458 
462 typedef enum nr_transmit_state_t {
464 
465  /*
466  * The caller sets these.
467  */
472  /*
473  * The (re)-transmitter sets these.
474  */
481 
482 
488 typedef struct radius_packet {
489  int sockfd;
490  struct sockaddr_storage src;
491  struct sockaddr_storage dst;
492  socklen_t sizeof_addr;
494  const char *secret;
495  size_t sizeof_secret;
497  unsigned int code;
498  int id;
499  size_t length;
500  uint8_t vector[16];
502  struct timeval timestamp;
516 
517  int attempts;
519  int delay;
520  int flags;
522  uint8_t *data;
523  size_t sizeof_data;
525 } RADIUS_PACKET;
526 
527 #define NR_PACKET_ENCODED (1 << 0)
528 #define NR_PACKET_HEADER (1 << 1)
529 #define NR_PACKET_SIGNED (1 << 2)
530 #define NR_PACKET_OK (1 << 3)
531 #define NR_PACKET_VERIFIED (1 << 4)
532 #define NR_PACKET_DECODED (1 << 5)
533 
534 
560 typedef struct nr_retransmit_config_t {
569  int irt;
570 
579  int mrt; /* default 16s */
580 
596  int mrd; /* default 30s */
597 
620  int mrc; /* default 5 attempts */
622 
636 typedef struct nr_track_id_t {
637  int sockfd;
639  int code;
641  struct sockaddr_storage src;
642  struct sockaddr_storage dst;
643  socklen_t sizeof_addr;
645  const char *secret;
646  size_t sizeof_secret;
648  int used;
650  void *ctx;
651  int (*packet_send)(void *, RADIUS_PACKET *);
654 
656 } nr_track_id_t;
657 
658 
673 extern const char *nr_strerror(int error);
674 
684 extern VALUE_PAIR *nr_vp_alloc(const DICT_ATTR *da);
685 
694 extern void nr_vp_free(VALUE_PAIR **head);
695 
705 extern VALUE_PAIR *nr_vp_init(VALUE_PAIR *vp, const DICT_ATTR *da);
706 
720 extern VALUE_PAIR *nr_vp_alloc_raw(unsigned int attr, unsigned int vendor);
721 
737 extern int nr_vp_set_data(VALUE_PAIR *vp, const void *data, size_t data_len);
738 
755 extern int nr_vp_set_raw_data(VALUE_PAIR *vp, const void *data, size_t data_len);
756 
765 extern VALUE_PAIR *nr_vp_create(int attr, int vendor, const void *data,
766  size_t data_len);
767 
773 extern void nr_vps_append(VALUE_PAIR **head, VALUE_PAIR *vp);
774 
782 extern VALUE_PAIR *nr_vps_find(VALUE_PAIR *head,
783  unsigned int attr, unsigned int vendor);
784 
799 extern const DICT_ATTR *nr_dict_attr_byvalue(unsigned int attr,
800  unsigned int vendor);
801 
814 extern const DICT_ATTR *nr_dict_attr_byname(const char *name);
815 
830 extern int nr_dict_attr_2struct(DICT_ATTR *da,
831  unsigned int attr, unsigned int vendor,
832  char *buffer, size_t bufsize);
833 
837 extern const DICT_VALUE *nr_dict_value_byattr(unsigned int attr,
838  unsigned int vendor,
839  int value);
840 
844 const DICT_VALUE *nr_dict_value_byname(unsigned int attr,
845  unsigned int vendor,
846  const char *name);
847 
860 extern int nr_dict_vendor_byname(const char *name);
861 
872 extern const DICT_VENDOR *nr_dict_vendor_byvalue(unsigned int vendor);
873 
879 extern const DICT_VENDOR nr_dict_vendors[];
880 
888 extern const int nr_dict_num_attrs;
889 
903 extern const DICT_ATTR nr_dict_attrs[];
904 
910 extern const int nr_dict_num_names;
911 
921 extern DICT_ATTR const *nr_dict_attr_names[];
922 
932 extern const char *nr_packet_codes[NR_MAX_PACKET_CODE + 1];
933 
970 extern ssize_t nr_socket_recv(RADIUS_PACKET *packet);
971 
984 extern int nr_socket_send(RADIUS_PACKET *packet);
985 
986 
1008 extern ssize_t nr_socket_recv_response(RADIUS_PACKET *response,
1009  const RADIUS_PACKET *request);
1010 
1028 extern int nr_socket_send_response(RADIUS_PACKET *packet, const RADIUS_PACKET *original);
1029 
1038 extern int nr_packet_ok(RADIUS_PACKET *packet);
1039 
1050 extern int nr_packet_ok_raw(const uint8_t *data, size_t sizeof_data);
1051 
1106 extern ssize_t nr_packet_encode(RADIUS_PACKET *packet, const RADIUS_PACKET *original);
1107 
1120 extern int nr_packet_decode(RADIUS_PACKET *packet, const RADIUS_PACKET *original);
1121 
1133 extern int nr_packet_sign(RADIUS_PACKET *packet, const RADIUS_PACKET *original);
1134 
1147 extern int nr_packet_verify(RADIUS_PACKET *packet,
1148  const RADIUS_PACKET *original);
1149 
1161 extern void nr_packet_print_hex(RADIUS_PACKET *packet);
1162 
1163 
1173 extern int nr_packet_can_encode(RADIUS_PACKET *packet,
1174  const RADIUS_PACKET *original);
1175 
1182 extern int nr_transmit_init(nr_track_id_t *s, RADIUS_PACKET *request);
1183 
1205 extern int nr_transmit(nr_track_id_t *s, struct timeval *when,
1206  RADIUS_PACKET *request, RADIUS_PACKET *response);
1207 
1215 extern struct sockaddr_storage *nr_ipv42sockaddr(uint32_t ipaddr, int port,
1216  struct sockaddr_storage *s);
1217 
1224 extern int sockaddr_cmp(const struct sockaddr_storage *a,
1225  const struct sockaddr_storage *b);
1226 
1246 extern int nr_socket_open(struct sockaddr_storage *s);
1247 
1258 extern int nr_track_id_socket(nr_track_id_t *s,
1259  struct sockaddr_storage *src,
1260  struct sockaddr_storage *dst);
1261 
1274 extern ssize_t nr_rand_bytes(uint8_t *data, size_t data_len);
1275 
1287 extern uint32_t nr_rand(void);
1288 
1298 extern void nr_timeval_add(struct timeval *t, unsigned int seconds,
1299  unsigned int usec);
1300 
1310 extern int nr_timeval_cmp(const struct timeval *a, const struct timeval *b);
1311 
1323 extern int nr_track_id_init(nr_track_id_t *s, int code, const char *secret);
1324 
1332 extern int nr_track_id_close(const nr_track_id_t *s);
1333 
1344 extern int nr_track_id_alloc(nr_track_id_t *s, RADIUS_PACKET *packet);
1345 
1360 extern int nr_track_id_realloc(nr_track_id_t *s, RADIUS_PACKET *packet);
1361 
1368 extern int nr_track_id_release(nr_track_id_t *s, RADIUS_PACKET *packet);
1369 
1381  RADIUS_PACKET **packet_p,
1382  RADIUS_PACKET *original,
1383  size_t sizeof_data);
1384 
1396 extern void nr_track_id_packet_free(nr_track_id_t *s, RADIUS_PACKET *packet);
1397 
1405 extern void nr_strerror_printf(const char *fmt, ...);
1406 
1407 #ifndef NDEBUG
1408 #define nr_debug_error nr_strerror_printf
1409 #else
1410 #define nr_debug_error if (0) nr_strerror_printf
1411 #endif
1412 
1426 extern ssize_t nr_password_encrypt(uint8_t *output, size_t outlen,
1427  const uint8_t *input, size_t inlen,
1428  const char *secret, const uint8_t *vector);
1429 
1443 extern ssize_t nr_tunnelpw_encrypt(uint8_t *output, size_t outlen,
1444  const uint8_t *input, size_t inlen,
1445  const char *secret, const uint8_t *vector);
1446 
1461 extern ssize_t nr_tunnelpw_decrypt(uint8_t *output, size_t outlen,
1462  const uint8_t *input, size_t inlen,
1463  const char *secret, const uint8_t *vector);
1464 
1473 extern void nr_hmac_md5(const uint8_t *data, size_t data_len,
1474  const uint8_t *key, size_t key_len,
1475  uint8_t digest[16]);
1476 
1488 extern int nr_tlv_ok(const uint8_t *data, size_t length,
1489  size_t dv_type, size_t dv_length);
1490 
1498 typedef int (*nr_packet_walk_func_t)(void *, const DICT_ATTR *, const uint8_t *, size_t);
1499 
1520 extern int nr_packet_walk(RADIUS_PACKET *packet, void *ctx,
1521  nr_packet_walk_func_t callback);
1522 
1536 extern int nr_packet_init(RADIUS_PACKET *packet, const RADIUS_PACKET *original,
1537  const char *secret, int code,
1538  void *data, size_t sizeof_data);
1539 
1564 extern ssize_t nr_packet_attr_append(RADIUS_PACKET *packet,
1565  const RADIUS_PACKET *original,
1566  const DICT_ATTR *da,
1567  const void *data, size_t data_len);
1568 
1569 
1585 extern ssize_t nr_packet_vps_append(RADIUS_PACKET *packet,
1586  const RADIUS_PACKET *original,
1587  const VALUE_PAIR *vps);
1588 
1604 extern int nr_packet_response_ok(RADIUS_PACKET const *packet, RADIUS_PACKET const *response);
1605 
1622 extern ssize_t nr_vp2attr(const RADIUS_PACKET *packet,
1623  const RADIUS_PACKET *original,
1624  const VALUE_PAIR **pvp, uint8_t *data, size_t room);
1625 
1638 extern ssize_t nr_vp2rfc(const RADIUS_PACKET *packet,
1639  const RADIUS_PACKET *original,
1640  const VALUE_PAIR **pvp,
1641  uint8_t *data, size_t room);
1642 
1655 extern ssize_t nr_attr2vp(const RADIUS_PACKET *packet, const RADIUS_PACKET *original,
1656  const uint8_t *data, size_t length,
1657  VALUE_PAIR **pvp);
1658 
1671 extern ssize_t nr_attr2vp_rfc(const RADIUS_PACKET *packet,
1672  const RADIUS_PACKET *original,
1673  const uint8_t *data, size_t length,
1674  VALUE_PAIR **pvp);
1675 
1688 extern ssize_t nr_attr2vp_vsa(const RADIUS_PACKET *packet,
1689  const RADIUS_PACKET *original,
1690  const uint8_t *data, size_t length,
1691  VALUE_PAIR **pvp);
1692 
1705 extern ssize_t nr_attr2vp_raw(const RADIUS_PACKET *packet,
1706  const RADIUS_PACKET *original,
1707  const uint8_t *data, size_t length,
1708  VALUE_PAIR **pvp);
1709 
1722 extern ssize_t nr_vp2vsa(const RADIUS_PACKET *packet, const RADIUS_PACKET *original,
1723  const VALUE_PAIR **pvp, uint8_t *data,
1724  size_t room);
1725 
1749 extern ssize_t nr_attr2data(const RADIUS_PACKET *packet, ssize_t start,
1750  unsigned int attr, unsigned int vendor,
1751  const uint8_t **pdata, size_t *plength);
1752 
1766 extern size_t nr_vp_snprintf(char *buffer, size_t bufsize, const VALUE_PAIR *vp);
1767 
1777 extern size_t nr_vp_snprintf_value(char *buffer, size_t bufsize, const VALUE_PAIR *vp);
1778 
1784 extern void nr_vp_fprintf_list(FILE *fp, const VALUE_PAIR *vps);
1785 
1793 extern int nr_vp_sscanf(const char *string, VALUE_PAIR **pvp);
1794 
1802 extern ssize_t nr_vp_sscanf_value(VALUE_PAIR *vp, const char *value);
1803 
1807 #if 1
1808 #define return_NR_ERR(_x) return -(NR_ERR_ ## _x)
1809 #else
1810 /*
1811  * Used to see exactly where and when which function returned the error.
1812  */
1813 #define return_NR_ERR(_x) {fprintf(stderr, "ERROR %s[%d] %d\n", __FILE__, __LINE__, NR_ERR_ ## _x); return -(NR_ERR_ ## _x);}
1814 #endif
1815 
1816 #if defined(__GNUC__)
1817 # define PRINTF_LIKE(n) __attribute__ ((format(printf, n, n+1)))
1818 # define NEVER_RETURNS __attribute__ ((noreturn))
1819 # define UNUSED __attribute__ ((unused))
1820 # define BLANK_FORMAT " " /* GCC_LINT whines about empty formats */
1821 #else
1822 
1826 # define PRINTF_LIKE(n)
1827 
1831 # define NEVER_RETURNS
1832 
1836 # define UNUSED
1837 
1841 # define BLANK_FORMAT ""
1842 #endif
size_t length
Definition: client.h:389
Definition: client.h:478
ssize_t nr_socket_recv(RADIUS_PACKET *packet)
Definition: socket.c:35
const DICT_VENDOR nr_dict_vendors[]
Definition: dictionaries.c:11
Definition: client.h:469
int nr_socket_send_response(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: socket.c:195
ssize_t nr_packet_vps_append(RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR *vps)
Definition: packet.c:928
Definition: client.h:278
int nr_packet_response_ok(RADIUS_PACKET const *packet, RADIUS_PACKET const *response)
Definition: packet.c:959
nr_transmit_state_t
Definition: client.h:462
int nr_packet_can_encode(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: packet.c:515
Definition: client.h:314
int nr_transmit(nr_track_id_t *s, struct timeval *when, RADIUS_PACKET *request, RADIUS_PACKET *response)
Definition: transmit.c:180
const DICT_ATTR nr_dict_attrs[]
Definition: dictionaries.c:28
nr_attr_type_t
Definition: client.h:221
Definition: client.h:274
ssize_t nr_tunnelpw_decrypt(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen, const char *secret, const uint8_t *vector)
Definition: crypto.c:124
Definition: client.h:560
struct sockaddr_storage src
Definition: client.h:490
const char * secret
Definition: client.h:645
const char * nr_packet_codes[NR_MAX_PACKET_CODE+1]
Definition: packet.c:34
int mrd
Definition: client.h:596
struct value_pair VALUE_PAIR
uint32_t nr_rand(void)
Definition: custom.c:46
uint8_t ifid[8]
Definition: client.h:410
Definition: client.h:280
Definition: client.h:292
Definition: client.h:488
Definition: client.h:312
VALUE_PAIR * nr_vp_init(VALUE_PAIR *vp, const DICT_ATTR *da)
Definition: valuepair.c:46
VALUE_PAIR * nr_vp_create(int attr, int vendor, const void *data, size_t data_len)
Definition: valuepair.c:175
Definition: client.h:258
unsigned int unknown
Definition: client.h:339
int nr_packet_sign(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: packet.c:418
struct nr_dict_vendor DICT_VENDOR
int nr_track_id_close(const nr_track_id_t *s)
Definition: id.c:152
size_t length
Definition: client.h:425
Definition: client.h:224
Definition: client.h:468
ssize_t nr_packet_attr_append(RADIUS_PACKET *packet, const RADIUS_PACKET *original, const DICT_ATTR *da, const void *data, size_t data_len)
Definition: packet.c:858
ssize_t nr_attr2vp_rfc(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
Definition: attrs.c:1010
int nr_timeval_cmp(const struct timeval *a, const struct timeval *b)
Definition: custom.c:70
ssize_t nr_vp2vsa(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR **pvp, uint8_t *data, size_t room)
Definition: attrs.c:387
struct sockaddr_storage dst
Definition: client.h:642
Definition: client.h:268
Definition: client.h:266
size_t nr_vp_snprintf(char *buffer, size_t bufsize, const VALUE_PAIR *vp)
Definition: print.c:234
Definition: client.h:272
int nr_packet_decode(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: packet.c:364
Definition: client.h:260
#define NR_MAX_PACKET_CODE
Definition: client.h:201
uint8_t octets[253]
Definition: client.h:398
unsigned int code
Definition: client.h:497
DICT_ATTR const * nr_dict_attr_names[]
Definition: dictionaries.c:1373
const DICT_ATTR * nr_dict_attr_byvalue(unsigned int attr, unsigned int vendor)
Definition: dict.c:26
size_t sizeof_secret
Definition: client.h:495
int delay
Definition: client.h:519
Definition: client.h:304
Definition: client.h:230
struct sockaddr_storage src
Definition: client.h:641
Definition: client.h:300
Definition: client.h:223
Definition: client.h:306
void nr_hmac_md5(const uint8_t *data, size_t data_len, const uint8_t *key, size_t key_len, uint8_t digest[16])
Definition: crypto.c:183
int used
Definition: client.h:648
size_t sizeof_secret
Definition: client.h:646
const DICT_ATTR * nr_dict_attr_byname(const char *name)
Definition: dict.c:65
Definition: client.h:423
int nr_track_id_packet_alloc(nr_track_id_t *s, RADIUS_PACKET **packet_p, RADIUS_PACKET *original, size_t sizeof_data)
Definition: id.c:163
int tag
Definition: client.h:426
Definition: client.h:337
void nr_strerror_printf(const char *fmt,...)
Definition: client.h:636
int nr_packet_init(RADIUS_PACKET *packet, const RADIUS_PACKET *original, const char *secret, int code, void *data, size_t sizeof_data)
Definition: packet.c:783
Definition: client.h:294
#define MAX_STRING_LEN
Definition: client.h:217
ssize_t nr_attr2data(const RADIUS_PACKET *packet, ssize_t start, unsigned int attr, unsigned int vendor, const uint8_t **pdata, size_t *plength)
Definition: attrs.c:1319
const int nr_dict_num_attrs
Definition: dictionaries.c:1369
Definition: client.h:227
int value
Definition: client.h:375
VALUE_PAIR * nr_vp_alloc_raw(unsigned int attr, unsigned int vendor)
Definition: valuepair.c:77
Definition: client.h:463
struct value_pair * next
Definition: client.h:427
void nr_track_id_packet_free(nr_track_id_t *s, RADIUS_PACKET *packet)
Definition: id.c:228
const DICT_ATTR * da
Definition: client.h:374
Definition: client.h:310
int nr_track_id_socket(nr_track_id_t *s, struct sockaddr_storage *src, struct sockaddr_storage *dst)
Definition: socket.c:357
int mrc
Definition: client.h:620
VALUE_PAIR * nr_vps_find(VALUE_PAIR *head, unsigned int attr, unsigned int vendor)
Definition: valuepair.c:205
const DICT_VENDOR * nr_dict_vendor_byvalue(unsigned int vendor)
Definition: dict.c:154
Definition: client.h:290
const char * nr_strerror(int error)
Definition: print.c:283
int sockaddr_cmp(const struct sockaddr_storage *a, const struct sockaddr_storage *b)
Definition: socket.c:236
uint32_t integer
Definition: client.h:402
char strvalue[MAX_STRING_LEN]
Definition: client.h:397
VALUE_PAIR_DATA data
Definition: client.h:428
struct radius_packet RADIUS_PACKET
ssize_t nr_vp2attr(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR **pvp, uint8_t *data, size_t room)
Definition: attrs.c:559
int code
Definition: client.h:639
ssize_t nr_packet_encode(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: packet.c:617
size_t sizeof_data
Definition: client.h:523
int nr_packet_verify(RADIUS_PACKET *packet, const RADIUS_PACKET *original)
Definition: packet.c:300
int nr_socket_send(RADIUS_PACKET *packet)
Definition: socket.c:152
int nr_socket_open(struct sockaddr_storage *s)
Definition: socket.c:277
ssize_t nr_password_encrypt(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen, const char *secret, const uint8_t *vector)
Definition: crypto.c:32
Definition: client.h:361
Definition: client.h:228
int nr_vp_sscanf(const char *string, VALUE_PAIR **pvp)
Definition: parse.c:148
int id
Definition: client.h:498
Definition: client.h:262
const DICT_ATTR * da
Definition: client.h:424
Definition: client.h:282
Definition: client.h:226
ATTR_FLAGS flags
Definition: client.h:365
Definition: client.h:386
const DICT_VALUE * nr_dict_value_byattr(unsigned int attr, unsigned int vendor, int value)
const DICT_VALUE * nr_dict_value_byname(unsigned int attr, unsigned int vendor, const char *name)
Definition: client.h:229
int(* packet_send)(void *, RADIUS_PACKET *)
Definition: client.h:651
uint8_t * data
Definition: client.h:522
Definition: client.h:308
void nr_timeval_add(struct timeval *t, unsigned int seconds, unsigned int usec)
Definition: custom.c:59
int nr_dict_vendor_byname(const char *name)
Definition: dict.c:138
int nr_transmit_init(nr_track_id_t *s, RADIUS_PACKET *request)
Definition: transmit.c:203
Definition: client.h:233
size_t type
Definition: client.h:388
int mrt
Definition: client.h:579
int sockfd
Definition: client.h:637
Definition: client.h:276
uint8_t vector[16]
Definition: client.h:500
uint8_t length
Definition: client.h:351
int nr_track_id_init(nr_track_id_t *s, int code, const char *secret)
Definition: id.c:118
Definition: client.h:470
Definition: client.h:476
uint8_t ipv6prefix[18]
Definition: client.h:411
ssize_t nr_vp2rfc(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const VALUE_PAIR **pvp, uint8_t *data, size_t room)
Definition: attrs.c:444
void nr_vp_fprintf_list(FILE *fp, const VALUE_PAIR *vps)
Definition: print.c:256
socklen_t sizeof_addr
Definition: client.h:643
RADIUS_PACKET * ids[256]
Definition: client.h:655
Definition: client.h:225
int sockfd
Definition: client.h:489
nr_retransmit_config_t timers
Definition: client.h:653
int nr_packet_ok_raw(const uint8_t *data, size_t sizeof_data)
Definition: packet.c:96
ssize_t nr_attr2vp(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
Definition: attrs.c:1287
void nr_packet_print_hex(RADIUS_PACKET *packet)
Definition: print.c:73
struct nr_dict_value DICT_VALUE
ssize_t nr_vp_sscanf_value(VALUE_PAIR *vp, const char *value)
Definition: parse.c:78
struct nr_track_id_t nr_track_id_t
struct in_addr ipaddr
Definition: client.h:399
int nr_track_id_release(nr_track_id_t *s, RADIUS_PACKET *packet)
Definition: id.c:69
struct nr_retransmit_config_t nr_retransmit_config_t
ssize_t nr_socket_recv_response(RADIUS_PACKET *response, const RADIUS_PACKET *request)
Definition: socket.c:119
Definition: client.h:288
char name[1]
Definition: client.h:376
const char * name
Definition: client.h:366
nr_attr_type_t type
Definition: client.h:363
Definition: client.h:231
uint64_t integer64
Definition: client.h:403
ssize_t nr_rand_bytes(uint8_t *data, size_t data_len)
Definition: custom.c:30
Definition: client.h:316
const char * secret
Definition: client.h:494
Definition: client.h:264
Definition: client.h:296
Definition: client.h:270
int attempts
Definition: client.h:517
int nr_tlv_ok(const uint8_t *data, size_t length, size_t dv_type, size_t dv_length)
Definition: attrs.c:1032
VALUE_PAIR * vps
Definition: client.h:524
Definition: client.h:396
int nr_track_id_realloc(nr_track_id_t *s, RADIUS_PACKET *packet)
Definition: id.c:86
const char * name
Definition: client.h:390
uint8_t encrypt
Definition: client.h:350
VALUE_PAIR * nr_vp_alloc(const DICT_ATTR *da)
Definition: valuepair.c:57
size_t nr_vp_snprintf_value(char *buffer, size_t bufsize, const VALUE_PAIR *vp)
Definition: print.c:157
struct attr_flags ATTR_FLAGS
unsigned int vendor
Definition: client.h:364
int irt
Definition: client.h:569
int flags
Definition: client.h:520
Definition: client.h:477
struct timeval timestamp
Definition: client.h:502
int nr_vp_set_data(VALUE_PAIR *vp, const void *data, size_t data_len)
Definition: valuepair.c:103
int nr_track_id_alloc(nr_track_id_t *s, RADIUS_PACKET *packet)
Definition: id.c:49
struct in6_addr ipv6addr
Definition: client.h:400
const int nr_dict_num_names
Definition: dictionaries.c:1371
nr_transmit_state_t state
Definition: client.h:515
int nr_dict_attr_2struct(DICT_ATTR *da, unsigned int attr, unsigned int vendor, char *buffer, size_t bufsize)
Definition: dict.c:94
ssize_t nr_tunnelpw_encrypt(uint8_t *output, size_t outlen, const uint8_t *input, size_t inlen, const char *secret, const uint8_t *vector)
Definition: crypto.c:78
Definition: client.h:284
struct nr_dict_attr DICT_ATTR
ssize_t nr_attr2vp_vsa(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
Definition: attrs.c:1207
unsigned int has_tag
Definition: client.h:338
Definition: client.h:222
size_t length
Definition: client.h:499
void nr_vps_append(VALUE_PAIR **head, VALUE_PAIR *vp)
Definition: valuepair.c:194
Definition: client.h:232
int nr_vp_set_raw_data(VALUE_PAIR *vp, const void *data, size_t data_len)
Definition: valuepair.c:151
int(* nr_packet_walk_func_t)(void *, const DICT_ATTR *, const uint8_t *, size_t)
Definition: client.h:1498
int nr_packet_walk(RADIUS_PACKET *packet, void *ctx, nr_packet_walk_func_t callback)
Definition: packet.c:684
MD5 structures and prototypes.
Definition: client.h:475
unsigned int attr
Definition: client.h:362
int nr_packet_ok(RADIUS_PACKET *packet)
Definition: packet.c:145
void * ctx
Definition: client.h:650
struct sockaddr_storage * nr_ipv42sockaddr(uint32_t ipaddr, int port, struct sockaddr_storage *s)
Definition: socket.c:216
Definition: client.h:302
uint32_t date
Definition: client.h:401
ssize_t nr_attr2vp_raw(const RADIUS_PACKET *packet, const RADIUS_PACKET *original, const uint8_t *data, size_t length, VALUE_PAIR **pvp)
Definition: attrs.c:692
nr_error_t
Definition: client.h:256
Definition: client.h:298
Definition: client.h:373
socklen_t sizeof_addr
Definition: client.h:492
void nr_vp_free(VALUE_PAIR **head)
Definition: valuepair.c:26
struct sockaddr_storage dst
Definition: client.h:491
union value_pair_data VALUE_PAIR_DATA
Definition: client.h:286
unsigned int vendor
Definition: client.h:387