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
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef __EAP_TLS_PARSER_HXX__
00052 #define __EAP_TLS_PARSER_HXX__
00053
00054 #include "eap_tls.hxx"
00055 #include "eap_parser.hxx"
00056
00057
00058
00059
00060 typedef AAAParser<AAAMessageBlock *, EapRequestTls *> EapRequestTlsParser;
00061
00062 inline void EapRequestTlsParser::parseRawToApp()
00063 {
00064
00065 AAAMessageBlock* msg = getRawData();
00066 EapRequestTls *request = getAppData();
00067
00068 ACE_INT16 length_packet = ntohs(*(short *)(msg->base()+2));
00069 ACE_UINT32 length_data = length_packet-5-1;
00070
00071 EAP_LOG(LM_DEBUG,"EapRequestTlsParser::parseRawToApp LENGTH PACKET %d \n ",length_packet);
00072
00073 ACE_Byte flags= *(msg->rd_ptr());
00074
00075 if (!TLS_START(flags))
00076 {
00077 if (length_packet < 6) throw -1;
00078 }
00079 else EAP_LOG(LM_DEBUG,"EapRequestTlsParser::parseRawToApp: START flag\n");
00080
00081 request->set_flags(flags);
00082 msg->rd_ptr(1);
00083
00084 if (TLS_LENGTH_INCLUDED(flags))
00085 { EAP_LOG(LM_DEBUG,"EapRequestTlsParser::parseRawToApp: LENGTH INCLUDED flag\n");
00086 if (length_packet < 10) throw -1;
00087
00088 request->set_tls_message_length(ntohl(*(ACE_UINT32*)msg->rd_ptr()));
00089 msg->rd_ptr(4);
00090 length_data -= 4;
00091 } else request->set_tls_message_length(0);
00092
00093
00094 if (length_data)
00095 {
00096 AAAMessageBlock *data = AAAMessageBlock::Acquire(length_data);
00097 data->copy(msg->rd_ptr(),length_data);
00098
00099 request->set_data(data);
00100 request->set_is_ack(false);
00101 }
00102 else
00103 {
00104 request->set_data(NULL);
00105 if (flags == (ACE_Byte)0x00) request->set_is_ack(true);
00106 }
00107
00108 }
00109
00110 inline void EapRequestTlsParser::parseAppToRaw()
00111 {
00112 AAAMessageBlock *msg = getRawData();
00113 EapRequestTls* request = getAppData();
00114
00115
00116 EapRequestParser requestParser;
00117 requestParser.setRawData(msg);
00118 requestParser.setAppData(request);
00119 requestParser.parseAppToRaw();
00120
00121 ACE_Byte flags = request->get_flags();
00122 *(ACE_Byte*)msg->wr_ptr() = flags;
00123 msg->wr_ptr(1);
00124 if (TLS_LENGTH_INCLUDED(flags))
00125 {
00126 EAP_LOG(LM_DEBUG,"EapRequestTlsParser::parseAppToRaw LENGTH INCLUDED %d\n",request->get_data()->length());
00127
00128 *(ACE_UINT32*)msg->wr_ptr() = htonl(request->get_data()->length());
00129 msg->wr_ptr(4);
00130 }
00131
00132 ACE_UINT32 length_to_copy = msg->end()-msg->wr_ptr();
00133 EAP_LOG(LM_DEBUG,"EapRequestTlsParser::parseAppToRaw LENGTH PACKET %d \n ",length_to_copy);
00134 if (!TLS_START(flags) && (request->get_data() != NULL))
00135 msg->copy(request->get_data()->rd_ptr(),length_to_copy);
00136 }
00137
00138
00139 typedef EapRequestTlsParser EapResponseTlsParser;
00140
00141 #endif