Free memory if out of memory
[freeradius.git] / src / modules / rlm_eap / types / rlm_eap_md5 / eap_md5.h
1 #ifndef _EAP_MD5_H
2 #define _EAP_MD5_H
3
4 #include <freeradius-devel/ident.h>
5 RCSIDH(eap_md5_h, "$Id$")
6
7 #include "eap.h"
8
9 #define PW_MD5_CHALLENGE        1
10 #define PW_MD5_RESPONSE         2
11 #define PW_MD5_SUCCESS          3
12 #define PW_MD5_FAILURE          4
13 #define PW_MD5_MAX_CODES        4
14
15 #define MD5_HEADER_LEN          4
16 #define MD5_CHALLENGE_LEN       16
17
18 /*
19  ****
20  * EAP - MD5 doesnot specify code, id & length but chap specifies them,
21  *      for generalization purpose, complete header should be sent
22  *      and not just value_size, value and name.
23  *      future implementation.
24  *
25  *      Huh? What does that mean?
26  */
27
28 /* eap packet structure */
29 typedef struct md5_packet_t {
30 /*
31         uint8_t code;
32         uint8_t id;
33         uint16_t        length;
34 */
35         uint8_t value_size;
36         uint8_t value_name[1];
37 } md5_packet_t;
38
39 typedef struct md5_packet {
40         unsigned char   code;
41         unsigned char   id;
42         unsigned short  length;
43         unsigned char   value_size;
44         unsigned char   *value;
45         char            *name;
46 } MD5_PACKET;
47
48 /* function declarations here */
49
50 MD5_PACKET      *eapmd5_alloc(void);
51 void            eapmd5_free(MD5_PACKET **md5_packet_ptr);
52
53 int             eapmd5_compose(EAP_DS *auth, MD5_PACKET *reply);
54 MD5_PACKET      *eapmd5_extract(EAP_DS *auth);
55 int             eapmd5_verify(MD5_PACKET *pkt, VALUE_PAIR* pwd, uint8_t *ch);
56 #endif /*_EAP_MD5_H*/