4 * @brief Implementation of eap_identity_t.
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 #include "eap_identity.h"
28 typedef struct private_eap_identity_t private_eap_identity_t
;
31 * Private data of an eap_identity_t object.
33 struct private_eap_identity_t
{
36 * Public authenticator_t interface.
38 eap_identity_t
public;
43 identification_t
*peer
;
47 * Implementation of eap_method_t.process for the peer
49 static status_t
process(private_eap_identity_t
*this,
50 eap_payload_t
*in
, eap_payload_t
**out
)
54 hdr
= chunk_alloca(5);
55 id
= this->peer
->get_encoding(this->peer
);
57 *(hdr
.ptr
+ 0) = EAP_RESPONSE
;
58 *(hdr
.ptr
+ 1) = in
->get_identifier(in
);
59 *(u_int16_t
*)(hdr
.ptr
+ 2) = htons(hdr
.len
+ id
.len
);
60 *(hdr
.ptr
+ 4) = EAP_IDENTITY
;
62 *out
= eap_payload_create_data(chunk_cata("cc", hdr
, id
));
68 * Implementation of eap_method_t.initiate for the peer
70 static status_t
initiate(private_eap_identity_t
*this, eap_payload_t
**out
)
72 /* peer never initiates */
77 * Implementation of eap_method_t.get_type.
79 static eap_type_t
get_type(private_eap_identity_t
*this)
85 * Implementation of eap_method_t.get_msk.
87 static status_t
get_msk(private_eap_identity_t
*this, chunk_t
*msk
)
93 * Implementation of eap_method_t.is_mutual.
95 static bool is_mutual(private_eap_identity_t
*this)
101 * Implementation of eap_method_t.destroy.
103 static void destroy(private_eap_identity_t
*this)
109 * Described in header.
111 eap_identity_t
*eap_create(eap_role_t role
,
112 identification_t
*server
, identification_t
*peer
)
114 private_eap_identity_t
*this;
116 if (role
!= EAP_PEER
)
121 this = malloc_thing(private_eap_identity_t
);
123 /* public functions */
124 this->public.eap_method_interface
.initiate
= (status_t(*)(eap_method_t
*,eap_payload_t
**))initiate
;
125 this->public.eap_method_interface
.process
= (status_t(*)(eap_method_t
*,eap_payload_t
*,eap_payload_t
**))process
;
126 this->public.eap_method_interface
.get_type
= (eap_type_t(*)(eap_method_t
*))get_type
;
127 this->public.eap_method_interface
.is_mutual
= (bool(*)(eap_method_t
*))is_mutual
;
128 this->public.eap_method_interface
.get_msk
= (status_t(*)(eap_method_t
*,chunk_t
*))get_msk
;
129 this->public.eap_method_interface
.destroy
= (void(*)(eap_method_t
*))destroy
;
134 return &this->public;