00001
00002
00003
00004
00005
00006
00007
00008
#ifndef _RADIUSPACKET_H__
00009
#define _RADIUSPACKET_H__
00010
00011
#include "RadiusAttribute.h"
00012
00013
00014
00015
#define D_PACKET_ACCESS_REQUEST 1
00016
#define D_PACKET_ACCESS_ACCEPT 2
00017
#define D_PACKET_ACCESS_REJECT 3
00018
#define D_PACKET_ACCOUNTING_REQUEST 4
00019
#define D_PACKET_ACCOUNTING_RESPONSE 5
00020
#define D_PACKET_ACCESS_CHALLENGE 11
00021
#define D_PACKET_STATUS_SERVER 12
00022
#define D_PACKET_STATUS_CLIENT 13
00023
00024
#define D_PACKET_MAX_KNOWN_CODE 13
00025
00026
00027
00028
00029
#define D_RADIUS_PACKET_HEADER_LENGTH 20
00030
#define D_RADIUS_PACKET_MAX_LENGTH 4096
00031
#define D_AUTHENTICATOR_LENGTH 16
00032
00033
00034
00035
#define D_RAW_DATA_LENGTH 4352
00036
00037
00038
class RadiusSecret;
00039
class RadiusClientStack;
00040
00051 class RadiusPacket
00052 {
00053
public:
00054
00056
00065
RadiusPacket(
unsigned char p_code,
RadiusClientStack & p_stack);
00066
00068
00076
RadiusPacket(
unsigned char p_code,
RadiusPacket & p_request);
00077
00079
00091
RadiusPacket(
unsigned char p_code);
00092
00093
00095
RadiusPacket(
const RadiusPacket & p_packet);
00096
00098
~RadiusPacket();
00099
00100
00102
00105
unsigned char getCode(
void);
00106
00108
const char *
getCodeDescription(
void);
00109
00110
00112
00115 uint16_t
getLength(
void);
00116
00117
00118
00120
00123
unsigned char getID(
void);
00124
00126
00129
void setID(
unsigned char p_id);
00130
00132
void randomID();
00133
00134
00136
00139
RadiusSecret *
getSecret(
void);
00140
00142
00145
void setSecret(
RadiusSecret * p_secret);
00146
00147
00149
const unsigned char *
getAuthenticator(
void);
00150
00152
void setAuthenticator(
const unsigned char * p_auth);
00153
00154
00155
00157
void dump();
00158
00159
00161
00182
int getFirstAttribute(
RadiusAttribute & p_attr);
00183
00184
00186
00197
int getNextAttribute(
RadiusAttribute & p_attr);
00198
00199
00201
00213
int findAttribute(
unsigned char p_attrType,
RadiusAttribute & p_attr);
00214
00215
00217
00234
int addAttribute(
unsigned char p_attrType,
RadiusAttribute & p_attr);
00235
00236
00238
unsigned char *
getRawData(
void);
00239
00240
00242
00249
int adjustLength(uint16_t p_length);
00250
00251
00253
00261
void responseAuthenticator(
RadiusSecret * p_secret = NULL);
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
void encodeUserPassword(
void);
00275
00276
00278
00286
void accountingRequestAuthenticator(
RadiusSecret * p_secret = NULL);
00287
00288
00290
bool verifyResponse(
RadiusPacket & p_packet);
00291
00292
private:
00293
00294
friend class RadiusAttribute;
00295
00297
void init(
unsigned char p_code);
00298
00300
void randomAuthenticator(
void);
00301
00302
00304
00311
void setCode(
unsigned char p_code);
00312
00313
00315
00320
void setLength(uint16_t p_length);
00321
00322
00323
00325 unsigned char m_data[D_RAW_DATA_LENGTH];
00326
00327
00329 RadiusSecret *
m_secret;
00330
00331
00332
00333
00334
00335
00336
00337
unsigned char m_password[D_USER_PASSWORD_MAX_LENGTH];
00338 uint16_t m_passwordLength;
00339 uint16_t m_passwordOffset;
00340
00341
00342
00343
00344
00345
00346
unsigned char m_oldPassword[D_USER_PASSWORD_MAX_LENGTH];
00347 uint16_t m_oldPasswordLength;
00348 uint16_t m_oldPasswordOffset;
00349 };
00350
00351
#endif // _RADIUSPACKET_H__
00352