00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CONNECTOR_H
00038 #define CONNECTOR_H
00039
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043
00044 #include "common.h"
00045
00046 #include <stdlib.h>
00047 #include <stdio.h>
00048
00049 #include <openssl/rand.h>
00050
00051 #include "session.h"
00052 #include "payload.h"
00053 #include "message.h"
00054 #include "IKEv2.h"
00055 #include "payload.h"
00056 #include "conf_utils.h"
00057 #include "enums.h"
00058 #include "auth.h"
00059
00060
00061
00062
00063
00064 #define EAP_CODE_REQUEST 1
00065 #define EAP_CODE_RESPONSE 2
00066 #define EAP_CODE_SUCCESS 3
00067 #define EAP_CODE_FAILURE 4
00068
00084 #define EAP_HDF_LENGTHINCLUDED (1<<0)
00085 #define EAP_HDF_MOREFRAGMENTS (1<<1)
00086 #define EAP_HDF_INTEGRITYINCLUDED (1<<2)
00087
00091 struct EAPHeader
00092 {
00093 uint8_t Code;
00094 uint8_t Id;
00095 uint16_t Length;
00096 uint8_t Type;
00097 uint8_t Flags;
00098 }__attribute__((packed));
00099
00105 struct IKEv2Data
00106 {
00107 struct ikev2_ctx *i2;
00108 struct IKEv2Session *session;
00109 };
00110
00111 #define EAPIKEv2_TYPE 47
00112
00113 int CertInit( struct ikev2_ctx *i2 );
00114 int IKEv2Init( struct ikev2_ctx *i2 );
00115
00116 void IKEv2Shutdown(void);
00117 int GenEapKeys(struct IKEv2Session *s, int len);
00118
00119 uint32_t CreateIKEv2Message(const ikev2_ctx *i2, uint8_t *ikemsg, uint32_t imlen, bool response, uint8_t msgid,
00120 struct IKEv2Session *session, uint8_t **out );
00121
00122 int ExtractData(const uint8_t *in, uint8_t **data, uint32_t *dlen, uint32_t ilen );
00123
00124 int ParseIKEv2Message(const uint8_t *in, uint8_t **ikemsg, uint32_t *imlen, struct IKEv2Session *session );
00125
00126 uint32_t CreateResultMessage( bool succ, struct IKEv2Session *session, uint8_t **out );
00127
00128 uint16_t CreateFragmentAck(const uint8_t *in, uint8_t **out, struct IKEv2Session *session );
00129
00130 int ParseFragmentAck(const uint8_t *in, struct IKEv2Session *session );
00131
00132 struct IKEv2Data * IKEv2Data_new(struct ikev2_ctx *i2, struct IKEv2Session *s);
00133
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137
00138 #endif //CONNECTOR_H