00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifdef HAVE_CONFIG_H
00017 # include <dtn-config.h>
00018 #endif
00019
00020 #if defined(XERCES_C_ENABLED) && defined(EXTERNAL_CL_ENABLED)
00021
00022 #include <exception>
00023 #include <oasys/serialize/XMLSerialize.h>
00024
00025 #include "CLEventHandler.h"
00026
00027
00028 namespace dtn {
00029
00030
00031 void
00032 CLEventHandler::dispatch_cl_event(cl_message* message)
00033 {
00034 #define DISPATCH_MESSAGE(message_name) do { \
00035 if ( message->message_name().present() ) { \
00036 log_debug_p("/dtn/cl/dispatcher", "Dispatching " #message_name); \
00037 handle( message->message_name().get() ); \
00038 } } while (false);
00039
00040 DISPATCH_MESSAGE(cla_add_request);
00041 DISPATCH_MESSAGE(cla_delete_request);
00042 DISPATCH_MESSAGE(cla_params_set_event);
00043 DISPATCH_MESSAGE(interface_created_event);
00044 DISPATCH_MESSAGE(interface_reconfigured_event);
00045 DISPATCH_MESSAGE(eid_reachable_event);
00046 DISPATCH_MESSAGE(link_created_event);
00047 DISPATCH_MESSAGE(link_opened_event);
00048 DISPATCH_MESSAGE(link_closed_event);
00049 DISPATCH_MESSAGE(link_state_changed_event);
00050 DISPATCH_MESSAGE(link_deleted_event);
00051 DISPATCH_MESSAGE(link_attribute_changed_event);
00052 DISPATCH_MESSAGE(contact_attribute_changed_event);
00053 DISPATCH_MESSAGE(link_add_reachable_event);
00054 DISPATCH_MESSAGE(bundle_transmitted_event);
00055 DISPATCH_MESSAGE(bundle_canceled_event);
00056 DISPATCH_MESSAGE(bundle_receive_started_event);
00057 DISPATCH_MESSAGE(bundle_received_event);
00058 DISPATCH_MESSAGE(report_eid_reachable);
00059 DISPATCH_MESSAGE(report_link_attributes);
00060 DISPATCH_MESSAGE(report_interface_attributes);
00061 DISPATCH_MESSAGE(report_cla_parameters);
00062
00063 #undef DISPATCH_MESSAGE
00064 }
00065
00066 void
00067 CLEventHandler::process_cl_event(const char* msg_buffer,
00068 oasys::XercesXMLUnmarshal& parser)
00069 {
00070
00071 parser.reset_error();
00072
00073 std::auto_ptr<cl_message> message;
00074
00075 const xercesc::DOMDocument* document = parser.doc(msg_buffer);
00076 if (!document) {
00077 log_debug_p("/dtn/cl/parse", "Unable to parse document");
00078 return;
00079 }
00080
00081 try { message = cl_message_(*document); }
00082 catch (std::exception& e) {
00083 log_debug_p( "/dtn/cl/parse", "Parse error: %s", e.what() );
00084 return;
00085 }
00086
00087 dispatch_cl_event( message.get() );
00088 }
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 }
00100
00101 #endif // XERCES_C_ENABLED && EXTERNAL_CL_ENABLED